How do I quickly check what heads a particular commit is in?

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

How do I quickly check what heads a particular commit is in?

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:42:24

In the middle of a merge of 2 of a bunch of closely related heads, I
found a few odd things, so I've pickaxe'd and found the (potentially
bogus) commits. I am using gitk, and while I do find the commit, it's
not very clear what heads have the dodgy commit. They've probably been
for a few months in there <sigh>.

Is there a practical way to ask in what heads they are?



martin

Re: How do I quickly check what heads a particular commit is in?

From: Jeff King <hidden>
Date: 2016-06-15 22:42:24

On Mon, Apr 24, 2006 at 04:23:24PM +1200, Martin Langhoff wrote:
Is there a practical way to ask in what heads they are?
This should work:

$ cat <<'EOF' >find-commit
#!/bin/sh
commit=$1; shift
for i in "$@"; do
  git rev-list $i | fgrep -q $commit && echo $i
done
EOF
$ sh find-commit full-40char-sha1-of-commit head1 head2 ...

You potentially end up traversing parts of the history multiple times
(if they are shared by multiple heads) but git is fast enough that
performance is fine.

I don't know of a way to do it all in a git command without the fgrep.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help