* How to find a revision's branch name
@ 2006-03-18 6:02 Marco Costalba
2006-03-18 6:37 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Marco Costalba @ 2006-03-18 6:02 UTC (permalink / raw)
To: junkio; +Cc: git
In today git archive, todo branch.
$ git-rev-list -n1 --header b14e2494b8a70737066f4ade4df1b5559e81b44b
b14e2494b8a70737066f4ade4df1b5559e81b44b
tree 1baa1f8405d1fef90fe95f2477133a69adec288b
parent 8158d510c641e2354cf24a10bc3e994c7a1e3125
author Junio C Hamano <junkio@cox.net> 1137562948 -0800
committer Junio C Hamano <junkio@cox.net> 1137562948 -0800
TODO updates 2006-01-17.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Is it possible to get branch name from a revision sha?
Something like
$ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b
todo
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>
So I need to get 'todo' branch name from a given revision sha's.
BTW also git blame fails (gracefully) if revision is not in HEAD:
$ git blame b14e2494b8a70737066f4ade4df1b5559e81b44b
b14e2494b8a70737066f4ade4df1b5559e81b44b not found in HEAD
Thanks
Marco
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: How to find a revision's branch name 2006-03-18 6:02 How to find a revision's branch name Marco Costalba @ 2006-03-18 6:37 ` Junio C Hamano 2006-03-18 7:35 ` Marco Costalba 0 siblings, 1 reply; 4+ messages in thread From: Junio C Hamano @ 2006-03-18 6:37 UTC (permalink / raw) To: Marco Costalba; +Cc: git 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to find a revision's branch name 2006-03-18 6:37 ` Junio C Hamano @ 2006-03-18 7:35 ` Marco Costalba 2006-03-18 8:31 ` Junio C Hamano 0 siblings, 1 reply; 4+ messages in thread From: Marco Costalba @ 2006-03-18 7:35 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On 3/18/06, Junio C Hamano <junkio@cox.net> wrote: > 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. > > > > 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to find a revision's branch name 2006-03-18 7:35 ` Marco Costalba @ 2006-03-18 8:31 ` Junio C Hamano 0 siblings, 0 replies; 4+ messages in thread From: Junio C Hamano @ 2006-03-18 8:31 UTC (permalink / raw) To: Marco Costalba; +Cc: Junio C Hamano, git Marco Costalba <mcostalba@gmail.com> writes: >> ... I wonder why you care. Wouldn't this work just as well? >> >> $ git rev-list --header --topo-order --parents --remove-empty \ >> --all -- <path> >> > > Yessss!!! I think I spoke too early. I think --remove-empty does not prevent rev-list from traversing branches that <path> _never_ appears in their history, so if the <path> given was TODO, it will go all the way back to the very first commit by Linus, and the very first commit for gitk by Paul, without finding a commit that touches that file. One option is "--remove-empty --all" with <path> to omit heads and tags that do _not_ have given <path>s from the set of starting points, but then you cannot grab history of rev-tree.c between v0.99.7 and 9dcc829 (v0.99.7 was the last tagged commit that had rev-tree.c, but removal of the file happened 39 commits after that), so that is not really an option. I guess we need to live with this; git.git repository is quite special. If you clone from it, you would get todo, html and man branches, so it *appears* that these are part of the same repository, but logically these branches are not part of the project history proper. The commits that belong to these three branches do not appear in my private development repository. The todo branch is pushed into git.git from a completely separate repository from my side, and html and man branches are pushed from other separate repositories of their own on a kernel.org machine, automatically built after I push new stuff into the "master" branch of git.git repository, by the post-update hook. The only reason I have these three branches in git.git repository is historical. I do not have write access on kernel.org machine in /pub/scm/git itself. I can only write in /pub/scm/git/git.git/, and I never bothered to ask the operators to make /pub/scm/git itself writable by me; otherwise I would have made /pub/scm/git/git-{todo,html,man}.git repositories. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-03-18 8:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-03-18 6:02 How to find a revision's branch name Marco Costalba 2006-03-18 6:37 ` Junio C Hamano 2006-03-18 7:35 ` Marco Costalba 2006-03-18 8:31 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox