Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "CDT/git"

< CDT
(Add steps for contributing patches via Bugzilla)
(66 intermediate revisions by 13 users not shown)
Line 1: Line 1:
To make it easier for adoptors and contributors to work with the CDT source, we moved to GIT source control system June 24th 2011. Old CVS repo is read only now.
+
This document is the guide for using Git and EGit with CDT.  
 
+
This document will ultimately be the guide for using git and egit with CDT.  
+
  
 
== Source Repositories  ==
 
== Source Repositories  ==
  
CDT is now broken into two git repos. You can view repos at http://git.eclipse.org/c/.
+
You can view all the Eclipse Git repos at http://git.eclipse.org/c/
Core cdt org.eclipse.cdt.git, EDC repo is org.eclipse.cdt.edc.git. If you want to practice there are also
+
test repos, test3/*...
+
  
 
Committers will want to access the master repository via ssh  
 
Committers will want to access the master repository via ssh  
  
   ssh://userid@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
+
   ssh://commiterId@git.eclipse.org:29418/cdt/org.eclipse.cdt.git
 +
 
 +
where "commiterId" is your commiter login name (what you use with My Foundation Portal).
 +
 
 +
The URL above is good for pull and push to Gerrit for review which is the preferred way to proceed.  It can also be used
 +
to directly push to Git without a review, for committers that wish to do this for small, quick changes.
 +
 
 +
The direct Git URL (ssh://commiterId@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git) has been disabled for pushing as part of [http://eclip.se/491489 Bug 491489].  There should be no reason to use this URL at all.
  
where "userid" is your Commiter login name (what you used with CVS and what you use with My Foundation Portal).  
+
Everyone else will use either of the following URLs (Note: these URLs should only be used in Git, not in a Web browser).
 +
  git://git.eclipse.org:29418/cdt/org.eclipse.cdt.git
 +
  http://git.eclipse.org:29418/cdt/org.eclipse.cdt.git
  
Everyone else will use either of the following URLs
+
If for some reason you have problems with the port id due a firewall limitation, you can use the following:
  
 
   git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
 
   git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
Line 37: Line 42:
 
=== Main CDT ===
 
=== Main CDT ===
  
* Eclipse Setup (tested with Indigo)
+
* Eclipse Setup
** Eclipse Classic 3.7
+
** Get the latest Eclipse Standard (current 4.7) from http://www.eclipse.org/downloads
** Install Cdt on top on eclipse or install a separate copy of CDT 8.0 to establish an API baseline. See [[CDT/policy#Using_API_Tooling]]
+
** Install CDT on top on eclipse or install a separate copy of CDT 9.2 to establish an API baseline. See [[CDT/policy#Using_API_Tooling]]
 
** In Preferences set API baseline (you can set it to its own installation if it has CDT in it)
 
** In Preferences set API baseline (you can set it to its own installation if it has CDT in it)
** Install Egit 1.0 (you can get it from Indigo update site). See docs http://wiki.eclipse.org/EGit/User_Guide
+
** Install Egit (you can get it from the Neon update site). See docs http://wiki.eclipse.org/EGit/User_Guide
** (Optional) If you are using CDT remote launch: Install Remote System Explorer Run-time for build dependencies
+
** Install PDE/API Tools Environment Descriptions from update site http://download.eclipse.org/eclipse/updates/4.6 (see [https://bugs.eclipse.org/361660 Bug 361660])
* Check out build dependencies
+
** To get all other dependencies, use the target definition file by opening org.eclipse.cdt.target/cdt.target then click Set as Target Platform on the top right.
** (Optional) If you are using lp-parsers: from anonymous@dev.eclipse.org:/cvsroot/tools, org.eclipse.orbit, checkout the 1.1 version of net.sourceforge.lpg.lpgjavaruntime
+
** (Optional) If you are using test plugins: anonymous@dev.eclipse.org:/cvsroot/eclipse, checkout the following
+
*** org.eclipse.test.performance
+
 
* Setup Git credentials
 
* Setup Git credentials
** eGit wiki says that it would pop-up dialog for e-mail and name of committer. I did not see it. You have to set it up manually if you did not see the dialog
+
** EGit wiki says that it would pop-up dialog for e-mail and name of committer. I did not see it. You have to set it up manually if you did not see the dialog
 
** Windows->Preferences search Git, select Configuration->User Settings
 
** Windows->Preferences search Git, select Configuration->User Settings
 
** Click New Entry... add key[user.name] value[your name]
 
** Click New Entry... add key[user.name] value[your name]
Line 56: Line 58:
 
** From the Git perspective, select clone repo action
 
** From the Git perspective, select clone repo action
 
*** Cut & Paste url below in the first page of wizard for cloning
 
*** Cut & Paste url below in the first page of wizard for cloning
**** URL for committers - ssh://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
+
**** URL for committers -   ssh://commiterId@git.eclipse.org:29418/cdt/org.eclipse.cdt.git
**** URL - git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
+
**** URL - git://git.eclipse.org:29418/cdt/org.eclipse.cdt.git
 
*** Enter your committer credentials or anonymous (for permanent credentials use ssh keys see below).  
 
*** Enter your committer credentials or anonymous (for permanent credentials use ssh keys see below).  
*** It will ask you what branches to import. If you only care about head select master, if you want to work with other branches select a corresponding branch, for example cdt_8_0.
+
*** It will ask you what branches to import. If you only care about head select master, if you want to work with other branches select a corresponding branch, for example cdt_8_5.
 
*** Press Next. As location where files are stored select a folder inside your workspaces, for example workspace/cdt-git
 
*** Press Next. As location where files are stored select a folder inside your workspaces, for example workspace/cdt-git
 
*** Press Finish (skip Gerrit page)
 
*** Press Finish (skip Gerrit page)
Line 65: Line 67:
 
** From the repo, select Import Projects...
 
** From the repo, select Import Projects...
 
*** Select all the projects or individual. Project filter does not seems to work. It maybe easier select all, then close projects you don't need
 
*** Select all the projects or individual. Project filter does not seems to work. It maybe easier select all, then close projects you don't need
 +
*** Here's a list of projects you could start with:
 +
**** org.eclipse.cdt.codan.checkers
 +
**** org.eclipse.cdt.codan.checkers.ui
 +
**** org.eclipse.cdt.codan.core
 +
**** org.eclipse.cdt.codan.core.cxx
 +
**** org.eclipse.cdt.codan.ui
 +
**** org.eclipse.cdt.codan.ui.cfgview
 +
**** org.eclipse.cdt.codan.ui.cxx
 +
**** org.eclipse.cdt.core
 +
**** org.eclipse.cdt.core.native
 +
**** org.eclipse.cdt.core.linux          (Platform specific, change accordingly)
 +
**** org.eclipse.cdt.core.linux.x86_64  (Platform specific, change accordingly)
 +
**** org.eclipse.cdt.core.win32          (Platform specific, change accordingly)
 +
**** org.eclipse.cdt.core.win32.x86      (Platform specific, change accordingly)
 +
**** org.eclipse.cdt.core.win32.x86_64  (Platform specific, change accordingly)
 +
**** org.eclipse.cdt.debug.core
 +
**** org.eclipse.cdt.debug.mi.core
 +
**** org.eclipse.cdt.debug.mi.ui
 +
**** org.eclipse.cdt.debug.ui
 +
**** org.eclipse.cdt.dsf
 +
**** org.eclipse.cdt.dsf.gdb
 +
**** org.eclipse.cdt.dsf.gdb.ui
 +
**** org.eclipse.cdt.dsf.ui
 +
**** org.eclipse.cdt.gdb
 +
**** org.eclipse.cdt.gdb.ui
 +
**** org.eclipse.cdt.launch
 +
**** org.eclipse.cdt.make.core
 +
**** org.eclipse.cdt.make.ui
 +
**** org.eclipse.cdt.managedbuilder.core
 +
**** org.eclipse.cdt.managedbuilder.gnu.ui
 +
**** org.eclipse.cdt.managedbuilder.ui
 +
**** org.eclipse.cdt.ui
 +
 
** Let the build run. To build properly you should have set API baseline, see comment above about API baseline.
 
** Let the build run. To build properly you should have set API baseline, see comment above about API baseline.
 
* Another video  http://www.youtube.com/user/cdtdoug#p/a/u/1/I5uq6dWdi0w
 
* Another video  http://www.youtube.com/user/cdtdoug#p/a/u/1/I5uq6dWdi0w
Line 75: Line 110:
 
There is also wiki for eclipse/git marriage here - http://wiki.eclipse.org/Git
 
There is also wiki for eclipse/git marriage here - http://wiki.eclipse.org/Git
  
=== EDC ===
+
=== Repository content ===
More for EDC soon.
+
 
 +
{|
 +
|  colspan="2" style="background:#ffdead;" | Contents
 +
|-
 +
| build/
 +
| Build (managed build, make build, autotools)
 +
|-
 +
| codan/
 +
| Static analysis
 +
|-
 +
| core/
 +
| Shared functionality and native plugins
 +
|-
 +
| cross/
 +
| Cross compilation and remote debugging
 +
|-
 +
| debug/
 +
| General debug
 +
|-
 +
| doc/
 +
| Documentation
 +
|-
 +
| dsf/
 +
| Framework for debugger integrations
 +
|-
 +
| dsf-gdb/
 +
| GDB integration for debugging including Multicore Visualizer
 +
|-
 +
| jtag/
 +
| Hardware debugging
 +
|-
 +
| launch/
 +
| Run and Debug launch infrastructure
 +
|-
 +
| llvm/
 +
| Some LLVM support
 +
|-
 +
| lrparser/
 +
| C/C++ C99 LR Parser
 +
|-
 +
| memory/
 +
| Memory view support for debugging
 +
|-
 +
| qt/
 +
| Qt support
 +
|-
 +
| releng/
 +
| Release engineering
 +
|-
 +
| remote/
 +
| Support to run commands on a remote machine
 +
|-
 +
| testsrunner/
 +
| C/C++Unit testing
 +
|-
 +
| upc/
 +
| C/C++ UPC (Unified Parallel C) Support
 +
|-
 +
| util/
 +
| Some miscellaneous utilities
 +
|-
 +
| visualizer/
 +
| Visualizer framework
 +
|-
 +
| windows/
 +
| Some support for Visual C++
 +
|-
 +
| xlc/
 +
| C/C++ IBM XLC Compiler Support
 +
|}
  
 
== Setting up SSH keys for committers ==
 
== Setting up SSH keys for committers ==
Line 84: Line 188:
 
* Generate ssh keys using puttygen or ssh-keygen tools (mingw for windows, native for mac and linux)
 
* Generate ssh keys using puttygen or ssh-keygen tools (mingw for windows, native for mac and linux)
 
* In Windows->Preferences search for SSH and load you key (private one) in the private key list
 
* In Windows->Preferences search for SSH and load you key (private one) in the private key list
 +
 +
Upload keys using web page
 +
* http://wiki.eclipse.org/IT_Infrastructure_Doc#Upload_my_public_key
 +
 +
Manually upload key using shell (you may require to contact admin to get a shell access first)
 
* Login to git.eclipse.org using your committer login and password
 
* Login to git.eclipse.org using your committer login and password
 
  mkdir .ssh
 
  mkdir .ssh
Line 117: Line 226:
 
== Committing to two branches ==
 
== Committing to two branches ==
  
Let say we have a patch and we want to commit fix to cdt_8_0 branch and master
+
Let say we have a patch and we want to commit fix to cdt_9_1 branch and master
 
* Make sure you have both branches in your Local branches list
 
* Make sure you have both branches in your Local branches list
 
** If not create another missing one (from respective remote one)  
 
** If not create another missing one (from respective remote one)  
* Checkout cdt_8_0
+
* Checkout cdt_9_1
 
* Fetch
 
* Fetch
 
* Apply patch
 
* Apply patch
Line 131: Line 240:
 
* Push (make sure both branches are selected in the dialog to push). Both changes would be pushed now.
 
* Push (make sure both branches are selected in the dialog to push). Both changes would be pushed now.
 
* Fetch
 
* Fetch
* Checkout cdt_8_0
+
* Checkout cdt_9_1
  
 
At the end of this beauty your history view should show
 
At the end of this beauty your history view should show
  
 
  [master][origin/master] Bug xxx - your fix
 
  [master][origin/master] Bug xxx - your fix
  [cdt_8_0][origin/cdt_8_0][HEAD] Bug xxx - your fix
+
  [cdt_9_1][origin/cdt_9_1][HEAD] Bug xxx - your fix
  
== Posting patches on Bugzilla ==
+
== Using Gerrit for CDT  ==
  
Until Eclipse provides a Gerrit instance for all projects to use, the mechanism for community contributions remains patches attached to Bugzilla items. So, if you are interested in developing a fix for a particular bug, follow these simple steps:
+
All changes contributed to CDT by non-committers have to go through Gerrit.  Committers and non-committers must sign the new Eclipse CLA before contributing code. Please refer to the [http://wiki.eclipse.org/CDT/contributing contributing page] on how to sign your CLA.
 +
 
 +
Create a Gerrit account:
 +
 
 +
#Go to https://git.eclipse.org/r
 +
#If you are a committer, click <u>Sign In</u>. You will be asked to upload you SSH public key.
 +
#If you are not a committer, you could use your Bugzilla account or click <u>Register</u> and create an account.
 +
## Using the gerrit account settings (top right), you can get your username (not the email you use to register) need to push changes. Also, if you are using HTTS access, you need to generate your password in Settings->HTTS Password
 +
 
 +
Setup a Gerrit remote on your local git repo of CDT. Below is the procedure using EGit:
 +
 
 +
#Open 'git repositories' view
 +
#Expand the repo that corresponds to the CDT repo
 +
#Right-click on 'Remotes' and select "Create remote..."
 +
#Give it a name like "gerrit_eclipse" and leave "configure push" selected 
 +
#select OK
 +
#Click on the 'Change...' button, next to the 'URI' text box
 +
#Use one of the following URI, depending on if you are a committer, and/or you have firewall limitation:
 +
 
 +
ssh://&lt;commiterId&gt;@git.eclipse.org:29418/cdt/org.eclipse.cdt.git
 +
https://git.eclipse.org/r/cdt/org.eclipse.cdt.git
 +
 
 +
**In the Ref mapping section, add a RefSpec specification of
 +
 
 +
HEAD:refs/for/master
 +
 
 +
Once you have setup your gerrit remote you should:
 +
 
 +
*Commit the code you want to review to a branch. That branch does not need to be the master branch, but it should have the latest code (rebased to master). Make sure that the change description starts with a reference to the bug, e.g. "'''Bug 123456. Fixed an NPE in MyClass.java'''".
 +
*When doing the commit, make sure the Gerrit ChangeId is added at the end of the commit comment, to allow to link updated commits to this review.  This is easy to do with EGit: simply press the "Compute ChangeId for Gerrit code review button" when doing your commit, as shown in the figure below (don't worry if the change id is all zeros at first, it will get filled in once the commit is done).
 +
*Also, make sure to press the Signed-off-by button right next to the ChangeId button.  This is now required by the Eclipse contribution process.  Note that you can set a preference to always add "Signed-off-by" when doing a commit with EGit: ''Window->Preferences->Team->Git->Commit Dialog'' and check ''Insert Signed-off-by''.
 +
<br>
 +
[[Image:Changeid.png]]
 +
<br>
 +
*Right-click on the repo in the Git Repositories view and select "Push..."
 +
*Select the Gerrit remote and press Next
 +
*The push should be from the branch that has the changes towards refs/for/master. When using HEAD as the source ref, the branch with the change must be checked-out.
 +
*Authorization should be done to complete the push. You should use the committer password using ssh for Gerrit, but when using http from eclipse, you must use a special password that can be found after logging in to Gerrit from the web [https://git.eclipse.org/r/#/settings/http-password here]. Details on the [http://wiki.eclipse.org/Gerrit#Git_over_HTTPS main eclipse gerrit page].
 +
*Go to https://git.eclipse.org/r/#/q/status:open+project:cdt/org.eclipse.cdt,n,z and you should see the change you just pushed (assuming you are watching the CDT project; if not, you can find it in the All section).
 +
 
 +
=== Pushed without a changeId? ===
 +
If you have committed without a changeId and pushed to Gerrit, fear not, you can still push a new version on that same review.  Gerrit automatically assigns each review a changeId if there is none specified in the commit (see screenshot below).  Use that changeId to update your commit, and when you push to gerrit again, it will know to use the same review.
 +
 
 +
[[Image:CDT_git_gerrit_missing_changeid.png]]
 +
 
 +
=== Miscellaneous  ===
 +
*Automatically insert the changeid for each of your commits
 +
**A changeId in a commit does not have negative impacts but is needed for Gerrit reviews so it is worth always putting one.
 +
**Go to Preferences->Team->Git->Configuration
 +
**Choose the tab "Repository Settings"
 +
**Select the repository you want to do this for (in case you have multiple git repositories)
 +
**Press the button "Add Entry..."
 +
**Key: gerrit.createchangeid
 +
**Value: true
 +
*Cancelling a review
 +
** If you have submitted a patch set for review but want cancel that submission you should 'Abandon' it.  The 'Abandon' button is only available to the submitter and is located below each patch set entry within the review as shown below:
 +
<br>
 +
[[Image:Abandon.png]]
 +
<br><br>
 +
*Un-marking a file that was automatically marked as reviewed
 +
**Select the file
 +
**Select the 'Preferences' menu at the top of the page
 +
**The right-most option is 'review'. You can uncheck that.
 +
<br>
 +
[[Image:CDT Gerrit Unreview.png]]
 +
<br>
 +
 
 +
== Posting patches on Bugzilla ==
  
# Clone the CDT repo as per above if you haven't already done so.
+
The project used to accept patches through Buzilla but now patches should go through Gerrit, see instructions above on how to post it.
# Create a branch for your bug.
+
# Develop the fix.  Commit changes to your branch as required.
+
# Once your work is stable and ready to go, create the patch.  This is easiest done in the History view.
+
## Select the commit from which you want to create the patch.  Probably this is the last on your branch.  [[Image:CDT_contrib_create_patch_menu.png|thumb|none|Create patch menu]]
+
## In the dialog, save the patch to a file.  [[Image:CDT_contrib_create_patch_file.png|thumb|none|Save to a file]]
+
## Make sure that the option to save in Git format is not selected.  This makes it easier for the committers to apply the patch in Eclipse.  [[Image:CDT_contrib_create_patch_Eclipse.png|thumb|none|Eclipse-compatible]]
+
# Now, you have a patch file that you can attach to a Bugzilla as before in when CDT was hosted in a CVS repo.  Be sure to indicate in your Bugzilla comment, to which branch the patch applies so that a prospective reviewer/committer knows which branch to switch to.
+

Revision as of 00:31, 3 April 2017

This document is the guide for using Git and EGit with CDT.

Source Repositories

You can view all the Eclipse Git repos at http://git.eclipse.org/c/

Committers will want to access the master repository via ssh

  ssh://commiterId@git.eclipse.org:29418/cdt/org.eclipse.cdt.git

where "commiterId" is your commiter login name (what you use with My Foundation Portal).

The URL above is good for pull and push to Gerrit for review which is the preferred way to proceed. It can also be used to directly push to Git without a review, for committers that wish to do this for small, quick changes.

The direct Git URL (ssh://commiterId@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git) has been disabled for pushing as part of Bug 491489. There should be no reason to use this URL at all.

Everyone else will use either of the following URLs (Note: these URLs should only be used in Git, not in a Web browser).

  git://git.eclipse.org:29418/cdt/org.eclipse.cdt.git
  http://git.eclipse.org:29418/cdt/org.eclipse.cdt.git

If for some reason you have problems with the port id due a firewall limitation, you can use the following:

  git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git
  http://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git

Click here for further information on the Git repos available to CDT developers

Screencasts

Doug Schaefer has posted numerous screencasts on using git with Eclipse

Setting up your workspace with the CDT Repo

Follow these instructions to get working with the CDT repo out on eclipse.org.

Main CDT

  • Eclipse Setup
  • Setup Git credentials
    • EGit wiki says that it would pop-up dialog for e-mail and name of committer. I did not see it. You have to set it up manually if you did not see the dialog
    • Windows->Preferences search Git, select Configuration->User Settings
    • Click New Entry... add key[user.name] value[your name]
    • Click New Entry... add key[user.email] value[your committer e-mail]
    • Click ok
  • Clone the repo. See either Doug's video http://www.youtube.com/watch?v=O4rDgx6-B6Q here or instructions below:
    • From the Git perspective, select clone repo action
      • Cut & Paste url below in the first page of wizard for cloning
      • Enter your committer credentials or anonymous (for permanent credentials use ssh keys see below).
      • It will ask you what branches to import. If you only care about head select master, if you want to work with other branches select a corresponding branch, for example cdt_8_5.
      • Press Next. As location where files are stored select a folder inside your workspaces, for example workspace/cdt-git
      • Press Finish (skip Gerrit page)
      • This should take about 3-5 minutes
    • From the repo, select Import Projects...
      • Select all the projects or individual. Project filter does not seems to work. It maybe easier select all, then close projects you don't need
      • Here's a list of projects you could start with:
        • org.eclipse.cdt.codan.checkers
        • org.eclipse.cdt.codan.checkers.ui
        • org.eclipse.cdt.codan.core
        • org.eclipse.cdt.codan.core.cxx
        • org.eclipse.cdt.codan.ui
        • org.eclipse.cdt.codan.ui.cfgview
        • org.eclipse.cdt.codan.ui.cxx
        • org.eclipse.cdt.core
        • org.eclipse.cdt.core.native
        • org.eclipse.cdt.core.linux (Platform specific, change accordingly)
        • org.eclipse.cdt.core.linux.x86_64 (Platform specific, change accordingly)
        • org.eclipse.cdt.core.win32 (Platform specific, change accordingly)
        • org.eclipse.cdt.core.win32.x86 (Platform specific, change accordingly)
        • org.eclipse.cdt.core.win32.x86_64 (Platform specific, change accordingly)
        • org.eclipse.cdt.debug.core
        • org.eclipse.cdt.debug.mi.core
        • org.eclipse.cdt.debug.mi.ui
        • org.eclipse.cdt.debug.ui
        • org.eclipse.cdt.dsf
        • org.eclipse.cdt.dsf.gdb
        • org.eclipse.cdt.dsf.gdb.ui
        • org.eclipse.cdt.dsf.ui
        • org.eclipse.cdt.gdb
        • org.eclipse.cdt.gdb.ui
        • org.eclipse.cdt.launch
        • org.eclipse.cdt.make.core
        • org.eclipse.cdt.make.ui
        • org.eclipse.cdt.managedbuilder.core
        • org.eclipse.cdt.managedbuilder.gnu.ui
        • org.eclipse.cdt.managedbuilder.ui
        • org.eclipse.cdt.ui


And that's it. One way to test you have everything is to try and Export the master feature. That'll give you everything our official builds do.

Please also read CDT/policy if you are new committer or want to contribute to CDT. Also check CDT/contributing wiki on how to contribute a patch.

There is also wiki for eclipse/git marriage here - http://wiki.eclipse.org/Git

Repository content

Contents
build/ Build (managed build, make build, autotools)
codan/ Static analysis
core/ Shared functionality and native plugins
cross/ Cross compilation and remote debugging
debug/ General debug
doc/ Documentation
dsf/ Framework for debugger integrations
dsf-gdb/ GDB integration for debugging including Multicore Visualizer
jtag/ Hardware debugging
launch/ Run and Debug launch infrastructure
llvm/ Some LLVM support
lrparser/ C/C++ C99 LR Parser
memory/ Memory view support for debugging
qt/ Qt support
releng/ Release engineering
remote/ Support to run commands on a remote machine
testsrunner/ C/C++Unit testing
upc/ C/C++ UPC (Unified Parallel C) Support
util/ Some miscellaneous utilities
visualizer/ Visualizer framework
windows/ Some support for Visual C++
xlc/ C/C++ IBM XLC Compiler Support

Setting up SSH keys for committers

Doug has video about setting up ssh keys http://www.youtube.com/watch?v=WU9xYP_NScQ&feature=related.

  • To make it work first send request to webmaster@eclipse.org and ask for unrestricted shell, they will give you shell for 24 hours.
  • Generate ssh keys using puttygen or ssh-keygen tools (mingw for windows, native for mac and linux)
  • In Windows->Preferences search for SSH and load you key (private one) in the private key list

Upload keys using web page

Manually upload key using shell (you may require to contact admin to get a shell access first)

  • Login to git.eclipse.org using your committer login and password
mkdir .ssh
chmod 700 .ssh
cd .ssh
cat >> authorized_keys #or open in vi
<paste your public key here>
^D
chmod 600 authorized_keys
  • You can use more than one key if you want to login from diffrent hosts (or you can save key on diffrent hosts - up to you)
  • If you do all this stuff eGit won't ask 10 times for your password anymore!

Updating

  • Analog of svn update is git pull, you can use Pull from git repo
  • However it creates spaghetti like history, so if you only apply one bug a time, cleaner "update" is
    • Fetch
    • Rebase
  • Since it is ugly to do two commands instead of one, you can set up Pull to do that instead of Fetch/Merge
    • You need to set branch.autosetuprebase=always and branch.<name>.rebase=true in git configuration to achieve that

Committing to remote repository

  • Checkout the branch you want to commit changes, for example local:master -> remote:master
  • If it is already checked out, try Fetch to make sure it is in sync
  • Apply patch
  • Commit. Specify Author - contributor of the patch, and yourself as Committer
  • Push.
    • If push failed, you may not be having latest version. In this case Rebase to respective remote branch. It will undo your patch, then fetch, then apply your patch.
  • Fetch. This will synchronize your local branch with latest "push" which is kind of stupid because it was your own push that you just did.

In history view you should see

[master][origin/master][HEAD] Bug xxx - your fix

Committing to two branches

Let say we have a patch and we want to commit fix to cdt_9_1 branch and master

  • Make sure you have both branches in your Local branches list
    • If not create another missing one (from respective remote one)
  • Checkout cdt_9_1
  • Fetch
  • Apply patch
  • Commit patch
  • Checkout master
  • Open History view
  • Make sure button "Show all branches" checked
  • Find your commit
  • Right click on it and Select Cherry Pick, that should apply it to master branch
  • Push (make sure both branches are selected in the dialog to push). Both changes would be pushed now.
  • Fetch
  • Checkout cdt_9_1

At the end of this beauty your history view should show

[master][origin/master] Bug xxx - your fix
[cdt_9_1][origin/cdt_9_1][HEAD] Bug xxx - your fix

Using Gerrit for CDT

All changes contributed to CDT by non-committers have to go through Gerrit. Committers and non-committers must sign the new Eclipse CLA before contributing code. Please refer to the contributing page on how to sign your CLA.

Create a Gerrit account:

  1. Go to https://git.eclipse.org/r
  2. If you are a committer, click Sign In. You will be asked to upload you SSH public key.
  3. If you are not a committer, you could use your Bugzilla account or click Register and create an account.
    1. Using the gerrit account settings (top right), you can get your username (not the email you use to register) need to push changes. Also, if you are using HTTS access, you need to generate your password in Settings->HTTS Password

Setup a Gerrit remote on your local git repo of CDT. Below is the procedure using EGit:

  1. Open 'git repositories' view
  2. Expand the repo that corresponds to the CDT repo
  3. Right-click on 'Remotes' and select "Create remote..."
  4. Give it a name like "gerrit_eclipse" and leave "configure push" selected
  5. select OK
  6. Click on the 'Change...' button, next to the 'URI' text box
  7. Use one of the following URI, depending on if you are a committer, and/or you have firewall limitation:
ssh://<commiterId>@git.eclipse.org:29418/cdt/org.eclipse.cdt.git
https://git.eclipse.org/r/cdt/org.eclipse.cdt.git
    • In the Ref mapping section, add a RefSpec specification of
HEAD:refs/for/master

Once you have setup your gerrit remote you should:

  • Commit the code you want to review to a branch. That branch does not need to be the master branch, but it should have the latest code (rebased to master). Make sure that the change description starts with a reference to the bug, e.g. "Bug 123456. Fixed an NPE in MyClass.java".
  • When doing the commit, make sure the Gerrit ChangeId is added at the end of the commit comment, to allow to link updated commits to this review. This is easy to do with EGit: simply press the "Compute ChangeId for Gerrit code review button" when doing your commit, as shown in the figure below (don't worry if the change id is all zeros at first, it will get filled in once the commit is done).
  • Also, make sure to press the Signed-off-by button right next to the ChangeId button. This is now required by the Eclipse contribution process. Note that you can set a preference to always add "Signed-off-by" when doing a commit with EGit: Window->Preferences->Team->Git->Commit Dialog and check Insert Signed-off-by.


Changeid.png

  • Right-click on the repo in the Git Repositories view and select "Push..."
  • Select the Gerrit remote and press Next
  • The push should be from the branch that has the changes towards refs/for/master. When using HEAD as the source ref, the branch with the change must be checked-out.
  • Authorization should be done to complete the push. You should use the committer password using ssh for Gerrit, but when using http from eclipse, you must use a special password that can be found after logging in to Gerrit from the web here. Details on the main eclipse gerrit page.
  • Go to https://git.eclipse.org/r/#/q/status:open+project:cdt/org.eclipse.cdt,n,z and you should see the change you just pushed (assuming you are watching the CDT project; if not, you can find it in the All section).

Pushed without a changeId?

If you have committed without a changeId and pushed to Gerrit, fear not, you can still push a new version on that same review. Gerrit automatically assigns each review a changeId if there is none specified in the commit (see screenshot below). Use that changeId to update your commit, and when you push to gerrit again, it will know to use the same review.

CDT git gerrit missing changeid.png

Miscellaneous

  • Automatically insert the changeid for each of your commits
    • A changeId in a commit does not have negative impacts but is needed for Gerrit reviews so it is worth always putting one.
    • Go to Preferences->Team->Git->Configuration
    • Choose the tab "Repository Settings"
    • Select the repository you want to do this for (in case you have multiple git repositories)
    • Press the button "Add Entry..."
    • Key: gerrit.createchangeid
    • Value: true
  • Cancelling a review
    • If you have submitted a patch set for review but want cancel that submission you should 'Abandon' it. The 'Abandon' button is only available to the submitter and is located below each patch set entry within the review as shown below:


Abandon.png

  • Un-marking a file that was automatically marked as reviewed
    • Select the file
    • Select the 'Preferences' menu at the top of the page
    • The right-most option is 'review'. You can uncheck that.


CDT Gerrit Unreview.png

Posting patches on Bugzilla

The project used to accept patches through Buzilla but now patches should go through Gerrit, see instructions above on how to post it.

Back to the top