Require padded atom data for PME GPU
[gromacs.git] / docs / dev-manual / change-management.rst
blob9e281654f5a9baf4eb537182a69d37d0f79e9828
1 .. _gmx-gerrit:
3 =========================
4 GROMACS change management
5 =========================
7 This documentation assumes the reader is already familiary with using ``git``
8 for managing file revisions.
10 .. contents::
11    :local:
13 Getting started
14 ===============
16 #.  Go to https://gerrit.gromacs.org
17 #.  Click Register (you can choose any OpenID provider including any
18     existing Google/Yahoo account. If you manually enter the URL make sure
19     to start with ``http(s)://``)
20 #.  Choose a username and add an ssh key
22 See `here <https://gerrit.gromacs.org/Documentation/intro-quick.html>`_ for
23 a quick intro into Gerrit.
25 Creating the SSH key for Gerrit
26 -------------------------------
28 In order to push your commits to gerrit server, you must have an SSH key
29 in your computer which matches with the one registered in your Gerrit
30 user account. To do so, you first need to create this unique SSH
31 key. You will be asked to enter a passphrase. *This is
32 optional with respect to Gerrit, but it is a good security practice to have
33 it.*
35 To proceed with the creation of the SSH key, type the following commands
36 from your terminal window:
40     $ cd ~/.ssh
42     $ ssh-keygen -t rsa -C "your.email@address.com"
44 Please substitute the email string in the command above
45 with the same email address which you used to register the account in
46 Gerrit.
48 Now you have created your public SSH key, which you need to copy/paste
49 into your Gerrit profile. First, open it with the following command:
53     $ cat id_rsa.pub
55 Copy all the contents of the file id_rsa.pub in your clipboard, and
56 switch to your favorite web browser where you logged in to Gerrit
57 GROMACS page. Click on your username at the top right corner of the
58 Gerrit webpage and select "Settings". You should now be in your Gerrit
59 profile settings page, where you should see a vertical menu.
61 From this vertical menu, select "SSH Public Keys", then click the button
62 "Add Key ..." and an edit box will appear below the button. Here you
63 need to paste the contents of id_rsa.pub file, which you previously
64 copied to your clipboard.
66 Now you are ready to operate!
68 Setting up a local repository to work with gerrit
69 -------------------------------------------------
71 Either clone using::
73     $ git clone ssh://USER@gerrit.gromacs.org/gromacs.git
75 (replace **USER** \ with your username)
77 or change the remote url using:
81     $ git remote set-url origin ssh://USER@gerrit.gromacs.org/gromacs.git
83 (change **USER** with the username you've registered)
85 Or add a new remote url using:
89     $ git remote add upload ssh://USER@gerrit.gromacs.org/gromacs.git
91 If you are working with a GROMACS repository other than the source code,
92 then you should substitute e.g. regressiontests.git or releng.git
93 instead of gromacs.git above.
95 Be sure to configure your user name and e-mail to match those registered to Gerrit::
97        git config [--global] user.name "Your Name"
98        git config [--global] user.email "your.name@domain.org"
100 It is optional if you want to set those settings for git on a global
101 level, or just for the current repository.
103 If necessary, register the e-mail address you want to use
104 with Gerrit.
106 Install the commit hook
107 -----------------------
109 Differently from a simple usage of git, with Gerrit a Change-ID is
110 needed at the end of each commit message. Gerrit uses Change-IDs to
111 understand whether your new commit is patching a previous commit or it
112 should be regarded as a separate, different patch, uncorrelated with
113 your previously pushed commits.
115 To allow git to append such Change-IDs automatically after each commit,
116 type the following command:
120     $ scp -p USER@gerrit.gromacs.org:hooks/commit-msg .git/hooks/
122 (change **USER** with the username you've registered in Gerrit)
124 .. Note::
126    This commit hook needs to be added to the repo where the
127    commit will occur, not the repo where the push to upstream will occur
128    (should they be different).
130 Uploading a commit for review
131 -----------------------------
133 Make sure your HEAD is up to date (use ``git pull --rebase origin`` if
134 someone else has committed since you last pulled), check that your commit
135 message follows the :doc:`commitstyle`, make your commit and then use
139     $ git push origin HEAD:refs/for/BRANCH
141 Replace ``BRANCH`` with the branch it should be committed to.
142 Master has a number of sub branches that can be used to show
143 what the patch is relevant to such as OpenCL and tools-cleanup.
144 These can be pushed to by specifying them after the branch,
145 for example ``BRANCH/domdec-cleanup``.
147 When updating/replacing an existing change, make sure the commit message
148 has the same Change-ID. Please see the section `Ammending a change <gmx-ammend-change>`
149 below.
151 Uploading a Work-In-Progress (WIP) or Private commit for review
152 ---------------------------------------------------------------
154 You can use the WIP or Private workflow on Gerrit to upload changes
155 that might not be ready yet for public review and merging.
156 Those changes will only be visible to people explicitly added as reviewers,
157 and will not automatically trigger Jenkins if the reviewer "Jenkins Buildbot"
158 is not added manually to them.
160 For uploading a new private change, push to refs/for/master%private
161 (substituting master with the branch you want to push to). To remove the private
162 flag when uploading a new patch set, use refs/for/master%remove-private.
163 To mark change as Work-In-Progress, push to refs/for/master%wip,
164 to unmark push to refs/for/master%ready.
165 You can also mark and unmark changes as Private or WIP in the Gerrit web-interface.
167 To manually trigger Jenkins on a WIP or Private change, you need to log in
168 to Jenkis after adding the "Jenkins Buildbot" reviewer. In Jenkins, navigate to
169 http://jenkins.gromacs.org/gerrit_manual_trigger/ and tell it to
170 search for the commit for which you want to trigger the build agents.
171 For example, https://gerrit.gromacs.org/#/c/1238/ is 1238 (but maybe
172 SHA or ChangeID will work, too).
173 Any change made to the commit after "Jenkins Buildbot" was added to the
174 list of reviewers will also trigger Jenkins.
176 After uploading a commit
177 ------------------------
183     $ git reset --keep HEAD^
185 to reset your branch to the HEAD before the commit you just uploaded.
186 This allows you to keep your repo in sync with what every other repo
187 thinks is the HEAD. In particular, if you have another patch to upload
188 (or worse, have to pull in other people's patches, and then have a new
189 patch), you probably do not want to have the second patch depend on the
190 first one. If the first one is rejected, you have made extra work for
191 yourself sorting out the mess. Your repo still knows about the commit,
192 and you can cherry-pick it to somewhere if you want to use it.
194 Code Review
195 ===========
197 Reviewing someone else's uploaded commit
198 ----------------------------------------
200 The reviewing workflow is the following:
202 #. https://gerrit.gromacs.org/#q/status:open shows all open changes
203 #. A change needs a +2 and usually +1 review, as well as a +2 verified
204    to be allowed to be merged.
205 #. Usually a patch goes through several cycles of voting, commenting and
206    updating before it becomes merged, with votes from the developers indicating
207    if they think that change hat progressed enough to be included.
208 #. A change is submitted for merging and post-submit testing
209    by clicking "Submit" by one of the main developers. This should be done by
210    the reviewer after voting +2. After a patch is submitted it is
211    replicated to the main git server.
213 Do not review your own code. The point of the policy is that at least
214 two non-authors have voted +1, and that the issues are resolved in the
215 opinion of the person who applies a +2 before a merge. If you have
216 uploaded a minor fix to someone else's patch, use your judgement in
217 whether to vote on the patch +1.
219 Guide for reviewing
220 -------------------
222 -  First and foremost, check correctness to the extent possible;
223 -  As portability and performance are the most important things (after
224    correctness) do check for potential issues;
225 -  Check adherence to the :ref:`GROMACS coding
226    standards <style-guidelines>`;
227 -  We should try to ensure that commits that implement bugfixes (as
228    well as important features and tasks) get a `Redmine`_ entry created
229    and linked. The linking is done **automatically** by
230    `Redmine`_ **if the commit message contains** keyword
231    "#issueID", the valid syntax is explained below.
232 -  If the commit is a **bugfix**\ :
234    -  if present in Redmine it has to contain a valid reference to the
235       issue;
236    -  if it's a **major bug**, there has to be a bug report filed in
237       `Redmine`_  (with urgent or
238       immediate priority) and referenced appropriately.
240 -  If the commit is a **feature/task** implementation:
242    -  if it's present in `Redmine`_ it
243       has to contain a valid reference to the issue;
244    -  If no current issue is currently present and the change
245       would benefit of one for future explanation on why it was
246       added, a new redmine issue should be created.
248 Use of Verify
249 -------------
251 Jenkins has been installed for automated build testing. So it isn't
252 required to vote "verify +2" anymore. As the testing is not always
253 perfect, and because test coverage can be spotty, developers can still
254 manually vote to indicate that a change performs as intended. Please note
255 that this should not be abused to bypass Jenkins testing. The vote from
256 the test suite should only be discarded if failures are caused by unrelated
257 issues.
259 Further information
260 -------------------
262 Currently it is possible to review your own code. It is undesirable to
263 review your own code, because that defeats the point. It will be
264 deactivated if it is being abused and those responsible may lose
265 their voting rights.
267 For further documentation:
269 -  |Gromacs| `specific manual <https://gerrit.gromacs.org/Documentation/index.html>`__
270 -  `General tutorials <https://gerrit-documentation.storage.googleapis.com/Documentation/2.15.3/index.html#_tutorials>`__
272 FAQs
273 ====
275 How do I access gerrit behind a proxy?
276 --------------------------------------
278 If you are behind a firewall blocking port 22, you can use socat to
279 overcome this problem by adding the following block to your
280 ``~/.ssh/config``
284     Host gerrit.gromacs.org
285            User USER
286            Hostname gerrit.gromacs.org
287            ProxyCommand socat - PROXY:YOURPROXY:gerrit.gromacs.org,proxyport=PORT
289 Replace ``YOURPROXY``, ``PORT`` and ``USER``, (but not ``PROXY``!) with your own
290 settings.
292 How do I link fixes with Redmine issues?
293 ----------------------------------------
295 The linking of commits that relate to an existing issue is
296 done automatically by `Redmine`_ if
297 the git commit message contains a reference to the Redmine entry
298 through the issueID, the numeric ID of the respective issue (bug,
299 feature, task). The general syntax of a git comit reference is [keyword]
300 #issueID.
302 The following two types of refereces are possible:
304 -  For bugfix commits the issueID should be preceeded by
305    the "Fixes" keyword;
306 -  For commits related to a general issue (e.g. partial implementation of
307    feature or partial fix), the issueID should be preceeded by the "Refs" keyword;
309 An example commit message header::
311     This commit refs #1, #2 and fixes #3
313 How can I submit conflicting changes?
314 -------------------------------------
316 When there are several, mutually conflicting changes in gerrit pending
317 for review, the submission of the 2nd and subsequent ones will fail.
318 Those need to be resolved locally and updated by
322     $ git pull --rebase
324 Then fix the conflicts and use
328     $ git push
330 Please add a comment (review without voting) saying that it was rebased
331 with/without conflicts, to help the reviewer.
334 .. _gmx-ammend-change:
336 How do I upload an update to a pending change?
337 ----------------------------------------------
339 First, obtain the code you want to update. If you haven't changed your
340 local repository, then you already have it. Maybe you can check out the
341 branch again, or consult your git reflog. Otherwise, you should go to
342 gerrit, select the latest patch set (remembering that others may have
343 contributed to your work), and use the "Download" link to give you a
344 "Checkout" command that you can run, e.g.
348     $ git fetch ssh://USER@gerrit.gromacs.org/gromacs refs/changes/?/?/? && git checkout FETCH_HEAD
350 Make your changes, then add them to the index, and use
354     $ git commit --amend
355     $ git push origin HEAD:refs/for/BRANCH
357 When amending the previous commit message, leave the "Change-Id" intact
358 so that gerrit can recognize this is an update and not open a new issue.
360 DO NOT rebase your patch set and update it in one step. If both are done
361 in one step, the diff between patch set versions has both kinds of
362 changes. This makes it difficult for the reviewer, because it is not
363 clear what parts have to be re-reviewed. If you need to update and
364 rebase your change please do it in two steps (order doesn't matter).
365 gerrit has a feature that allows you to rebase within gerrit, which
366 creates the desired independent patch for that rebase (if the rebase is
367 clean).
369 How do I get a copy of my commit for which someone else has uploaded a patch?
370 -----------------------------------------------------------------------------
372 Gerrit makes this easy. You can download the updated commit in various
373 ways, and even copy a magic git command to your clipboard to use in your
374 shell.
376 You can select the kind of git operation you want to do (cherry-pick is
377 best if you are currently in the commit that was the parent, checkout is
378 best if you just want to get the commit and not worry about the current
379 state of your checked out git branch) and how you want to get it. The
380 icon on the far right will paste the magic shell command into your
381 clipboard, for you to paste into a terminal to use.
383 How do I submit lots of independent commits (e.g. bug fixes)?
384 -------------------------------------------------------------
386 Simply pushing a whole commit tree of unrelated fixes creates
387 dependencies between them that make for trouble when one of them needs
388 to be changed. Instead, from an up-to-date repo, create and commit the
389 first change (or git cherry-pick it from an existing other branch).
390 Upload it to gerrit. Then do
394     $ git reset --keep HEAD^
396 This will revert to the old HEAD, and allow you to work on a new commit
397 that will be independent of the one you've already uploaded. The one
398 you've uploaded won't appear in the commit history until it's been
399 reviewed and accepted on gerrit and you've pulled from the main repo,
400 however the version of it you uploaded still exists in your repo. You
401 can see it with git show or git checkout using its hash - which you can
402 get from the gerrit server or by digging in the internals of your repo.
404 How can I avoid needing to remember all these arcane git commands?
405 ------------------------------------------------------------------
407 In your ``.gitconfig``, having set the git remote for the gerrit repo to
408 upload, use something like the following to make life easier:
412     [alias]
413             upload-r2018  = push origin HEAD:refs/for/release-2018
414             upload-r2016  = push origin HEAD:refs/for/release-2016
415             upload-master = push origin HEAD:refs/for/master
416             upload-reset  = reset --keep HEAD^
419 How can I get my patch in gerrit to have a different parent?
420 ------------------------------------------------------------
422 Sometimes, some other patch under review is a relevant point from which
423 to start work. For simple changes without conflicts to the previous
424 work, you can use the Gerrit web UI to either rebase or cherry-pick
425 the change you are working on.
427 If this is not possible, you can still use
428 the canned gerrit checkouts to (say) checkout out patch 2117 and start work:
432     git fetch https://gerrit.gromacs.org/gromacs refs/changes/17/2117/2 && git checkout FETCH_HEAD
434 Other times you might have already uploaded a patch (e.g. patch 1 of
435 2145), but now see that some concurrent work makes more sense as a
436 parent commit (e.g. patch 2 of 2117), so check it out as above, and then
437 use the canned gerrit **cherry-pick**:
441     git fetch https://gerrit.gromacs.org/gromacs refs/changes/45/2145/1 && git cherry-pick FETCH_HEAD
443 Resolve any merge commits, check things look OK, and then upload.
444 Because the ChangeId of 2145 hasn't changed, and nothing about 2117 has
445 changed, the second patch set of 2145 will reflect the state of 2145 now
446 having 2117 as a parent.
448 This can also be useful for constructing a short development branch
449 where the commits are somehow dependent, but should be separated for
450 review purposes. This technique is useful when constructing a series of
451 commits that will contribute to a release.
453 How can I revert a change back to an old patchset?
454 --------------------------------------------------
456 If a change accidentally gets updated or when a patchset is incorrect,
457 you might want to revert to an older patchset. This can be done by
458 fetching an old patchset, running git commit --amend to update the time
459 stamp in the commit and pushing the commit back up to gerrit. Note that
460 without the amending you will get an error from the remote telling you
461 that there are no new changes.
463 How do I handle common errors
464 -----------------------------
466 .. rubric:: error: server certificate verification failed. CAfile...
468 If you try to cherry-pick a change from the server, you'll probably get
469 the error:
473     $ git fetch https://gerrit.gromacs.org/p/gromacs refs/changes/09/109/1 && git cherry-pick FETCH_HEAD
474     error: server certificate verification failed.
475     CAfile: /etc/ssl/certs/ca-certificates.crt
476     CRLfile: none while accessing https://gerrit.gromacs.org/p/gromacs/info/refs
478     fatal: HTTP request failed
480 As explained
481 `here <http://code.google.com/p/chromium-os/issues/detail?id=13402>`__,
482 the problem is with git not trusting the certificate and as a workaround
483 one can set globally
487     $ git config --global --add http.sslVerify false
489 or prepend GIT_SSL_NO_VERIFY=1 to the command
493     $ GIT_SSL_NO_VERIFY=1  git fetch https://gerrit.gromacs.org/p/gromacs refs/changes/09/109/1 \
494      && git cherry-pick FETCH_HEAD
496 .. rubric:: Various error messages and their meanings
498 http://review.coreboot.org/Documentation/error-messages.html
500 More git tips
501 =============
503 .. rubric:: Q: Are there some other useful git configuration settings?
505 A: If you need to work with
506 branches that have large
507 differences (in particular, if a
508 lot of files have moved), it can
509 be helpful to set
513     git config diff.renamelimit 5000
515 to increase the limit of inexact
516 renames that Git considers. The
517 default value is not sufficient,
518 for example, if you need to do a
519 merge or a cherry-pick from
520 a release branch to master.
522 .. rubric:: Q: How do I use git rebase (also ``git pull --rebase``)?
524 A: Assume you have a local
525 feature branch checked out, that
526 it is based on master, and master
527 has gotten new commits. You can
528 then do
532     git rebase master
534 to move your commits on top of
535 the newest commit in master. This
536 will save each commit you did,
537 and replay them on top of master.
538 If any commit results in
539 conflicts, you need to resolve
540 them as usual (including marking
541 them as resolved using git add),
542 and then use
546     git rebase --continue
548 Note that unless you are sure
549 about what you are doing, you
550 should not use any commands that
551 create or delete commits (git
552 commit, or git checkout or git
553 reset without paths). ``git rebase
554 --continue`` will create the commit
555 after conflicts have been
556 resolved, with the original
557 commit message (you will get a
558 chance to edit it).
560 If you realize that the conflicts
561 are too messy to resolve (or that
562 you made a mistake that resulted
563 in messy conflicts), you can use
567     git rebase --abort
569 to get back into the state you
570 started from (before the
571 original git rebase master
572 invocation). If the rebase is
573 already finished, and you realize
574 you made a mistake, you can get
575 back where you started with
576 (use git
577 log <my-branch>@{1} and/or git
578 reflog <my-branch> to check that
579 this is where you want to go)
583     git reset --hard <my-branch>@{1}
585 .. rubric:: Q: How do I prepare several commits at once?
587 A: Assume I have multiple independent changes in my working tree.
592     git add [-p] [file]
594 to add one independent change at
595 a time to the index. Use
599     git diff --cached
601 to check that the index contains
602 the changes you want. You can
603 then commit this one change:
607     git commit
609  If you want to test that the
610 change works, use to temporarily
611 store away other changes, and do
612 your testing.
616     git stash
618 If the testing fails, you can
619 amend your existing commit with
620 ``git commit --amend``. After you are
621 satisfied, you can push the
622 commit into gerrit for review. If
623 you stashed away your changes and
624 you want the next change to be
625 reviewed independently, do
629     git reset --hard HEAD^
630     git stash pop
632 (only do this if you pushed the
633 previous change to gerrit,
634 otherwise it is difficult to get
635 the old changes back!) and repeat
636 until each independent change is
637 in its own commit. If you skip
638 the ``git reset --hard`` step, you
639 can also prepare a local feature
640 branch from your changes.
642 .. rubric:: Q: How do I edit an earlier commit?
644 A: If you want to edit the latest
645 commit, you can simply do the
646 changes and use
650     git commit --amend
652 If you want to edit some other
653 commit, and commits after that
654 have not changed the same lines,
655 you can do the changes as usual
656 and use
660     git commit --fixup <commit>
666     git commit --squash <commit>
668 where <commit> is the commit you
669 want to change (the difference is
670 that ``--fixup`` keeps the original
671 commit message, while ``--squash``
672 allows you to input additional
673 notes and then edit the original
674 commit message during ``git rebase
675 -i``). You can do multiple commits
676 in this way. You can also mix
677 ``--fixup/--squash`` commits with
678 normal commits. When you are
679 done, use
683     git rebase -i --autosquash <base-branch>
685 to merge the ``--fixup/--squash``
686 commits to the commits they
687 amend. See separate question on
688 ``git rebase -i`` on how to choose
689 <base-branch>.
691 In this kind of workflow, you
692 should try to avoid to change the
693 same lines in multiple commits
694 (except in ``--fixup/--squash``
695 commits), but if you have already
696 changed some lines and want to
697 edit an earlier commit, you can
702     git rebase -i <base-branch>
704 but you likely need to resolve
705 some conflicts later. See ``git
706 rebase -i`` question later.
708 .. rubric:: Q: How do I split a commit?
710 A: The instructions below apply
711 to splitting the HEAD commit; see
712 above how to use ``git rebase -i`` to
713 get an earlier commit as HEAD to
714 split it.
716 The simplest case is if you want
717 to split a commit A into a chain
718 A'-B-C, where A' is the first new
719 commit, and contains most of the
720 original commit, including the
721 commit message. Then you can do
725     git reset -p HEAD^ [-- <paths>]
726     git commit --amend
728 to selectively remove parts from
729 commit A, but leave them in your
730 working tree. Then you can create
731 one or more commits of the
732 remaining changes as described in
733 other tips.
735 If you want to split a commit A
736 into a chain where the original
737 commit message is reused for
738 something else than the first
739 commit (e.g., B-A'-C), then you
740 can do
744     git reset HEAD^
746 to remove the HEAD commit, but
747 leave everything in your working
748 tree. Then you can create your
749 commits as described in other
750 tips. When you come to a point
751 where you want to reuse the
752 original commit message, you can
757     git reflog
759 to find how to refer to your
760 original commit as ``HEAD@{n}``, and
761 then do
765     git commit -c HEAD@{n}
767 .. rubric:: Q: How do I use git rebase -i to only edit local commits?
769 A: Assume that you have a local
770 feature branch checked out, this
771 branch has three commits, and
772 that it is based on master.
773 Further, assume that master has
774 gotten a few more commits after
775 you branched off. If you want to
776 use ``git rebase -i`` to edit your
777 feature branch (see above), you
778 probably want to do
782     git rebase -i HEAD~3
784 followed by a separate
788     git rebase master
790 The first command allows you to
791 edit your local branch without
792 getting conflicts from changes in
793 master. The latter allows you to
794 resolve those conflicts in a
795 separate rebase run. If you feel
796 brave enough, you can also do
797 both at the same time using
801     git rebase -i master
803 .. rubric:: Interacting with Gerrit
804    :name: interacting-with-gerrit
805    :class: editable
807 This section is intended for
808 using git to interact with
809 gerrit; interacting with the web
810 UI may be better dealt with on a
811 separate page.
813 .. rubric:: Q: How do I move a change from a branch to another?
815 A: Moving one or a few changes is
816 most easily done using ``git
817 cherry-pick``. To move a single
818 change, first do
822     git checkout <target-branch>
824 Then, open the change/patch set
825 in Gerrit that you want to move,
826 select "cherry-pick" in the
827 Download section for that patch
828 set, and copy/paste the given
829 command:
833     git fetch ... refs/changes/... && git cherry-pick FETCH_HEAD
835 Resolve any conflicts and do
839     git commit [-a]
841 You can also cherry-pick multiple
842 changes this way to move a small
843 topic branch. Before pushing the
844 change to Gerrit, remove the
845 lines about conflicts from the
846 commit message, as they don't
847 serve any useful purpose in the
848 history. You can type that
849 information into the change as a
850 Gerrit comment if it helps the
851 review process. Note that Gerrit
852 creates a new change for the
853 target branch, even if Change-Ids
854 are same in the commits. You need
855 to manually abandon the change in
856 the wrong branch.