Add notes on how to show gerrit merge order
[openafs-wiki.git] / devel / GitGerritOrder.mdwn
1
2 This is a way to show gerrit commit ordering by gerrit number. This method does
3 not require any extra software, only gerrit access, git, and a bit of shell.
4
5 For a set of open gerrits on a single linear stack, you can see the order in
6 the "Related Commits" tab.  The newest are listed at the top and the oldest are
7 listed at the bottom.  However, the gerrit numbers are not listed in that tab
8 (you need to check each link to see the gerrit number), and the list could
9 include other gerrits depending on the situation.
10
11 To see the commit order by gerrit number, you can create a local repo and fetch
12 the changes to your local repo using the method Ben mentioned in the past, and
13 then use the git log command with the `--decorate` option to show the gerrit
14 numbers associated with each commit.
15
16 Create a sandbox repo. This should normally be separate from your
17 working repo, since we will be fetching a large number of branches.
18
19     $ git clone https://gerrit.openafs.org/openafs.git openafs-gerrits
20     $ cd openafs-gerrits
21
22 Add an additional 'fetch' to your `.git/config` to fetch the gerrit branches.
23
24     [remote "origin"]
25         url = https://gerrit.openafs.org/openafs.git
26         fetch = +refs/heads/*:refs/remotes/origin/*
27         fetch = +refs/changes/*:refs/remotes/origin/changes/*
28
29 Fetch the changes.
30
31     $ gerrit fetch
32     (... snip ...)
33     * [new ref]             refs/changes/99/99/4     -> origin/changes/99/99/4
34     * [new ref]             refs/changes/99/99/5     -> origin/changes/99/99/5
35     * [new ref]             refs/changes/99/999/1    -> origin/changes/99/999/1
36
37 At this point your local repo has branches for all of the gerrits, even the ones
38 already merged. The format of the branch names is:
39
40     origin/changes/{gerrit mod 100}/{gerrit}/{patchset}
41
42 Find the top commit of the stack. I normally do this by looking at the "Related
43 Changes" tab in gerrit.  The current top commit for 1.8.x is 14946 (Linux-5.17:
44 Kernel build uses -Wcast-function-type).  The patchset number is listed under
45 "Patchsets" (top right). The current patchset number is 5, so the branch name
46 is:
47
48     origin/changes/46/14946/5
49
50
51 List the changes with gerrit numbers of commits not merged onto the release
52 branch. This is done by providing a range of commits, from the current release
53 branch to the top gerrit. We can pipe through `nl` to add a merge order number.
54
55     $ git log  \
56         --reverse \
57         --oneline \
58         --decorate \
59         origin/openafs-stable-1_8_x..origin/changes/46/14946/5 \
60       | nl
61
62          1      0937ab044d (origin/changes/64/14964/1) configure.ac: Add missing double include guard
63          2      0d6ca2205d (origin/changes/65/14965/1) autoconf: Remove/update obsolete autoconf macros
64          3      4c319a35b1 (origin/changes/94/14594/4) warn when starting without keys
65          (... snip ...)
66         45      8148e2d5d7 (origin/changes/45/14945/5) Linux-5.17: kernel func complete_and_exit renamed
67         46      dd996b738a (origin/changes/46/14946/5) Linux-5.17: Kernel build uses -Wcast-function-type
68
69 Optionally, we can use some shell to clean up the output.  This shows the
70 gerrits in the order to be merged without conflicts.
71
72     $ git log  \
73         --reverse \
74         --oneline \
75         --decorate \
76         origin/openafs-stable-1_8_x..origin/changes/46/14946/5 \
77       nl |
78       while read i h b s; do g=$(echo $b | cut -f4 -d/); echo $i $g $s; done
79
80     1 14964 configure.ac: Add missing double include guard
81     2 14965 autoconf: Remove/update obsolete autoconf macros
82     3 14594 warn when starting without keys
83     (... snip ...)
84     45 14945 Linux-5.17: kernel func complete_and_exit renamed
85     46 14946 Linux-5.17: Kernel build uses -Wcast-function-type