]> git.ipfire.org Git - thirdparty/git.git/commit
Meta/post-applypatch: don't contaminate amlog with useless "reverse mapping"
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Dec 2020 23:58:44 +0000 (15:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Dec 2020 23:58:44 +0000 (15:58 -0800)
commitfa82cf43b1da596d043b5e21fb22a4c5f0456fa4
tree2a94ed1e3fc80a8c3b10a419e896a039cab1f6d4
parent730f2a8a60960c30a79e00ebe034836f60befbf0
Meta/post-applypatch: don't contaminate amlog with useless "reverse mapping"

The notes/amlog database is used to annotate individual commits that
result from "git am" application.  A note is attached to the commit
object and record s the Message-ID of the incoming e-mailed patch
that resulted in the commit, so "git show --notes=amlog" would
easily show where the commit came from.  The rewrite-hook mechanism
can be used to maintain the notes across rebasing and amending (but
cherry-pick does not preserve the note by design---the maintainer
has to be careful to avoid using cherry-pick).  One message can and
does result in multiple commits, and the mapping worked naturally in
this direction.

Originally it felt like a good idea to create a blob object that has
a Message-ID in it, and annotate the blob object with a note message
that has the name of the commit object that results by running "git
am" on the message, and mix such records in the notes database.
When you have a message, from the Message-ID, you can manufacture a
blob that has the Message-ID in it and ask the notes database about
the note attached to it, effectively giving you a reverse mapping.

This was ugly, unnecessary and unworkable at the same time.

 - These blobs with message-ID in them are not anchored by any ref;
   the reverse mapping entries in the notes tree were subject to be
   gc'ed any time.

 - "git grep -e '<message-id>' notes/amlog" essentially gives a
   mechanism that is quick enough to find what commits resulted from
   a message.

 - There is no machinery that helps these reverse mapping notes to
   be maintained across rebases and amends.  Because a single "git
   am" session is often far from enough for an e-mailed patch, these
   "reverse" entries that were created upon the first application
   quickly became stale pointing at commits that have been amended
   away.  There often are more than one commit that result from the
   same message on topic branches while the right base is being
   selected, so "the last one wins" rule, if it were even possible
   to implement, wouldn't have been sufficient.

Since grepping for the Message-ID in the notes database, i.e.  using
the forward mapping, gives an access to the necessary piece of
information reliably and quicly enough, let's retire the failed
attempt to throw reverse mapping entries in to the "amlog" notes.
post-applypatch