git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHSET] git-reverse-trailer-xrefs: Reverse map cherry-picks and other cross-references

From
THTejun Heo <tj@kernel.org>
Date
Dec 11, 2018, 23:49 UTC
Message-ID
<20181211234909.2855638-1-tj@kernel.org>
Hello,

Some trailers refer to other commits. Let's call them xrefs (cross-references). For example, a cherry pick trailer points to the source commit. It is sometimes useful to build a reverse map of these xrefs - ie. source -> cherry-pick instead of cherry-pick -> source.

This, e.g, can answer which releases a commit ended up in on repositories which cherry-picks fixes back from the development branch. Let's say the repository looks like the following.

	  D'---E'' release-B
	 /
	C'      E' release-D
       /       /
  A---B---C---D---E master
where the followings cherry-picks took place.
  C -> C'
  D -> D'
  E -> E' -> E''

Using the reverse-mapping in this patchset, we can get the following annotated log which succinctly shows which commit ended up where.

  $ git log --notes=xref-cherry-picks --oneline | git name-rev --name-only --stdin
  4b165af commit E
  Notes (xref-cherry-picks):
      Cherry-picked-to: release-D
      Cherry-picked-to:   release-B
  82bf1f3 commit D
  Notes (xref-cherry-picks):
      Cherry-picked-to: release-B~1
  364eccf commit C
  Notes (xref-cherry-picks):
      Cherry-picked-to: release-B~2
  ed3adf3 commit B
  ddd1bf2 commit A

This patchset implements generic trailer cross-reference reverse-mapping and the necessary hooks and samples to keep cherry-pick reverse-maps up-to-date.

diffstat follows.  Thanks.
 Documentation/git-cherry-pick.txt           |    5 
 Documentation/git-fetch.txt                 |    5 
 Documentation/git-notes.txt                 |    8 
 Documentation/git-reverse-trailer-xrefs.txt |  145 +++++++++++++++
 Documentation/githooks.txt                  |   23 ++
 Makefile                                    |    1 
 builtin.h                                   |    1 
 builtin/fetch.c                             |   72 +++++++
 builtin/reverse-trailer-xrefs.c             |  160 +++++++++++++++++
 builtin/revert.c                            |   14 +
 git.c                                       |    1 
 notes-merge.c                               |    9 
 notes-utils.c                               |    2 
 notes-utils.h                               |    3 
 notes.c                                     |  260 +++++++++++++++++++++++++++-
 notes.h                                     |    9 
 t/t3321-notes-xref-cherry-picks.sh          |  124 +++++++++++++
 templates/hooks--post-cherry-pick.sample    |    8 
 templates/hooks--post-fetch.sample          |   30 +++
 trailer.c                                   |  105 +++++++++++
 trailer.h                                   |   38 ++++
 21 files changed, 1015 insertions(+), 8 deletions(-)

-- tejun

Next: Tejun Heo
Message 1 of 17 in “[PATCHSET] git-reverse-trailer-xrefs: Reverse map cherry-picks and other cross-references”
  1. Tejun HeoDec 11, 2018
  2. 1/5 trailer: Implement a helper to reverse-map trailer xrefsTejun Heo, Dec 11, 2018
  3. 2/5 notes: Implement special handlings for refs/notes/xref-Tejun Heo, Dec 11, 2018
  4. 3/5 notes: Implement git-reverse-trailer-xrefsTejun Heo, Dec 11, 2018
  5. 4/5 githooks: Add post-cherry-pick and post-fetch hooksTejun Heo, Dec 11, 2018
  6. 5/5 notes: Implement xref-cherry-picks hooks and testsTejun Heo, Dec 11, 2018
  7. Junio C HamanoDec 12, 2018
  8. Tejun HeoDec 12, 2018
  9. Junio C HamanoDec 13, 2018
  10. Junio C HamanoDec 13, 2018
  11. Tejun HeoDec 13, 2018
  12. Stefan XenosDec 18, 2018
  13. Stefan XenosDec 18, 2018
  14. Tejun HeoDec 18, 2018
  15. Tejun HeoDec 13, 2018
  16. Junio C HamanoDec 13, 2018
  17. Tejun HeoDec 13, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.