From: Jeff King <peff@peff.net>
To: Laszlo Papp <lpapp@kde.org>
Cc: Git List <git@vger.kernel.org>
Subject: Re: git tag --contains for cherry-picks
Date: Thu, 30 Jun 2016 02:22:36 -0400 [thread overview]
Message-ID: <20160630062236.GA15380@sigill.intra.peff.net> (raw)
In-Reply-To: <CAOMwXhNp9SwA_oQ8bE6-m72C+po+28maGtsP8wRFRfBLjSb5NA@mail.gmail.com>
On Wed, Jun 29, 2016 at 12:48:33PM +0100, Laszlo Papp wrote:
> Old releases are maintained with important bug fixes or even new features
> in our case. It sometimes means that we need to cherry-pick commits across
> branches, like from master to a specific release branch.
>
> Cherry-picking changes the hash of the commit, therefore, this may no
> longer work for cherry-picks:
>
> git tag --contains
>
> I am thinking of having something like:
>
> git tag --contains-follow
>
> which would follow cherry-picks. I am not sure how easily and/or
> efficiently this can be implemented, but my gut feeling is that in the vast
> majority of the cases, the content check would bail out already at the
> "subject line".
Git generally considers commits "equivalent" based on the patch-id, whic
his a sha1 of the diff (modulo some canonicalization).
So you could ask right now for the patch-id of a particular commit:
git show $commit | git patch-id >needle
and then the patch-id of all tagged commits:
git log -p --tags | git patch-id | sort >haystack
Each line will have the patch-id followed by the commit id. You can then
correlate them (join is part of GNU coreutils):
join needle haystack | cut -d' ' -f2- >synonyms
That gives you a list of synonym commits, which you can use to ask git
which tags contain any of them:
git tag $(for i in $(cat synonyms); do echo "--contains $i"; done)
The big downside is that generating the haystack is expensive (it has to
do a diff on every commit). But if this is something you do a lot, you
can save the haystack and incrementally update it with new commits.
Of course there are other ways of determining commit equivalence. You
could find ones with duplicate commit messages, or duplicate subjects,
or whatever. But if you have a cherry-picking workflow, I suspect the
easiest thing may be to simply use "git cherry-pick -x", which will
write the sha1 of the original commit into the cherry-picked commit
message. You can then use that to correlate directly.
So there's no specific "--contains-follow" as you want, but the tools
are there to do it (and more flexibly and efficiently, depending on your
needs). That doesn't necessarily mean it's not a good idea to make the
simple case easier, though.
-Peff
next prev parent reply other threads:[~2016-06-30 6:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 11:48 git tag --contains for cherry-picks Laszlo Papp
2016-06-30 6:22 ` Jeff King [this message]
2016-06-30 10:41 ` Jakub Narębski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160630062236.GA15380@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=lpapp@kde.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).