Re: How to find a revision's branch name

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

Re: How to find a revision's branch name

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:21

Marco Costalba [off-list ref] writes:
Is it possible to get branch name from a revision sha?
Something like

$ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b
todo
That is in general impossible.

        $ git show-branch master~1 next pu
        ! [master~1] blame: Nicer output
         ! [next] Merge branch 'jc/cvsimport' into next
          ! [pu] Merge branch 'jc/cvsimport' into next
        ---
         -- [next] Merge branch 'jc/cvsimport' into next
         ++ [next^2] cvsimport: honor -i and non -i upon subsequent
         imports
         -- [next^] Merge branch 'jc/fetch' into next
         ++ [next^^2] fetch: exit non-zero when fast-forward check
         fails.
         -- [next~2] Merge branch 'ew/abbrev' into next
         ++ [next~2^2] ls-files: add --abbrev[=<n>] option
         ++ [next~2^2^] ls-tree: add --abbrev[=<n>] option
         ++ [next^2^] blame: Fix git-blame <directory>
        +++ [master~1] blame: Nicer output
        $ git rev-parse --verify master~1
        88a8b7955666ed8fa5924fadbb3bb58984eaa6af

Now what should this command say?

        $ git branch --tell 88a8b7955666ed8fa5924fadbb3bb58984eaa6af

It is not head of any branch.  Should it say master~1?
next^2~1?  pu^2~1?

The closest thing is name-rev, which tries to give you the
simplest.  It may or may not match what you want:

        $ git name-rev 88a8b7955666ed8fa5924fadbb3bb58984eaa6af
        88a8b7955666ed8fa5924fadbb3bb58984eaa6af master~1
        $ git name-rev `git rev-parse --verify b14e24`
        b14e2494b8a70737066f4ade4df1b5559e81b44b todo~16

However.
I need this to correctly annotate files not in HEAD
tree. Currently qgit runs git-rev-list --header --topo-order
--parents --remove-empty HEAD -- <path>

to get a file history. But this fails if <path> is not found
in HEAD. The right command to run in our case should be:
git-rev-list --header --topo-order --parents --remove-empty
todo -- <path>
... I wonder why you care.  Wouldn't this work just as well?

	$ git rev-list --header --topo-order --parents --remove-empty \
	  --all -- <path>

It lists 70 commits at the moment.

Re: How to find a revision's branch name

From: Marco Costalba <hidden>
Date: 2016-06-15 22:42:21

On 3/18/06, Junio C Hamano [off-list ref] wrote:
Marco Costalba [off-list ref] writes:
quoted
Is it possible to get branch name from a revision sha?
Something like

$ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b
todo
That is in general impossible.
quoted
I need this to correctly annotate files not in HEAD
tree. Currently qgit runs git-rev-list --header --topo-order
--parents --remove-empty HEAD -- <path>

to get a file history. But this fails if <path> is not found
in HEAD. The right command to run in our case should be:
git-rev-list --header --topo-order --parents --remove-empty
todo -- <path>
... I wonder why you care.  Wouldn't this work just as well?

        $ git rev-list --header --topo-order --parents --remove-empty \
          --all -- <path>
Yessss!!!

Thanks for the fix. I missed that.

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