Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Marco Costalba <mcostalba@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How to find a revision's branch name
Date: Fri, 17 Mar 2006 22:37:46 -0800	[thread overview]
Message-ID: <7vfylgz29x.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <e5bfff550603172202ia4b69f2he5562b826e491426@mail.gmail.com> (Marco Costalba's message of "Sat, 18 Mar 2006 07:02:22 +0100")

Marco Costalba <mcostalba@gmail.com> 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.

  reply	other threads:[~2006-03-18  6:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-18  6:02 How to find a revision's branch name Marco Costalba
2006-03-18  6:37 ` Junio C Hamano [this message]
2006-03-18  7:35   ` Marco Costalba
2006-03-18  8:31     ` Junio C Hamano

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=7vfylgz29x.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mcostalba@gmail.com \
    /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