{"thread":{"id":"3668","subject":"How to find a revision's branch name","startedAt":"2006-03-18T06:02:22Z","lastAt":"2006-03-18T08:31:26Z","messageCount":4,"participants":["Marco Costalba","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"17637","messageId":"e5bfff550603172202ia4b69f2he5562b826e491426@mail.gmail.com","threadId":"3668","inReplyTo":null,"subject":"How to find a revision's branch name","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2006-03-18T06:02:22Z","receivedAt":"2006-03-18T06:02:22Z","isPatch":false,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"In today git archive, todo branch.\n\n$ git-rev-list -n1 --header b14e2494b8a70737066f4ade4df1b5559e81b44b\nb14e2494b8a70737066f4ade4df1b5559e81b44b\ntree 1baa1f8405d1fef90fe95f2477133a69adec288b\nparent 8158d510c641e2354cf24a10bc3e994c7a1e3125\nauthor Junio C Hamano <junkio@cox.net> 1137562948 -0800\ncommitter Junio C Hamano <junkio@cox.net> 1137562948 -0800\n\n    TODO updates 2006-01-17.\n\n    Signed-off-by: Junio C Hamano <junkio@cox.net>\n\n\nIs it possible to get branch name from a revision sha?\nSomething like\n\n$ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b\ntodo\n\nI need this to correctly annotate files not in HEAD tree. Currently qgit runs\ngit-rev-list --header --topo-order --parents --remove-empty HEAD -- <path>\n\nto get a file history. But this fails if <path> is not found in HEAD. The right\ncommand to run in our case should be:\ngit-rev-list --header --topo-order --parents --remove-empty todo -- <path>\n\nSo I need to get 'todo' branch name from a given revision sha's.\n\nBTW also git blame fails (gracefully) if revision is not in HEAD:\n\n$ git blame b14e2494b8a70737066f4ade4df1b5559e81b44b\nb14e2494b8a70737066f4ade4df1b5559e81b44b not found in HEAD\n\n\nThanks\nMarco\n"},{"id":"17638","messageId":"7vfylgz29x.fsf@assigned-by-dhcp.cox.net","threadId":"3668","inReplyTo":"e5bfff550603172202ia4b69f2he5562b826e491426@mail.gmail.com","subject":"Re: How to find a revision's branch name","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-18T06:37:46Z","receivedAt":"2006-03-18T06:37:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marco Costalba <mcostalba@gmail.com> writes:\n\n> Is it possible to get branch name from a revision sha?\n> Something like\n>\n> $ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b\n> todo\n\nThat is in general impossible.\n\n        $ git show-branch master~1 next pu\n        ! [master~1] blame: Nicer output\n         ! [next] Merge branch 'jc/cvsimport' into next\n          ! [pu] Merge branch 'jc/cvsimport' into next\n        ---\n         -- [next] Merge branch 'jc/cvsimport' into next\n         ++ [next^2] cvsimport: honor -i and non -i upon subsequent\n         imports\n         -- [next^] Merge branch 'jc/fetch' into next\n         ++ [next^^2] fetch: exit non-zero when fast-forward check\n         fails.\n         -- [next~2] Merge branch 'ew/abbrev' into next\n         ++ [next~2^2] ls-files: add --abbrev[=<n>] option\n         ++ [next~2^2^] ls-tree: add --abbrev[=<n>] option\n         ++ [next^2^] blame: Fix git-blame <directory>\n        +++ [master~1] blame: Nicer output\n        $ git rev-parse --verify master~1\n        88a8b7955666ed8fa5924fadbb3bb58984eaa6af\n\nNow what should this command say?\n\n        $ git branch --tell 88a8b7955666ed8fa5924fadbb3bb58984eaa6af\n\nIt is not head of any branch.  Should it say master~1?\nnext^2~1?  pu^2~1?\n\nThe closest thing is name-rev, which tries to give you the\nsimplest.  It may or may not match what you want:\n\n        $ git name-rev 88a8b7955666ed8fa5924fadbb3bb58984eaa6af\n        88a8b7955666ed8fa5924fadbb3bb58984eaa6af master~1\n        $ git name-rev `git rev-parse --verify b14e24`\n        b14e2494b8a70737066f4ade4df1b5559e81b44b todo~16\n\nHowever.\n\n> I need this to correctly annotate files not in HEAD\n> tree. Currently qgit runs git-rev-list --header --topo-order\n> --parents --remove-empty HEAD -- <path>\n>\n> to get a file history. But this fails if <path> is not found\n> in HEAD. The right command to run in our case should be:\n> git-rev-list --header --topo-order --parents --remove-empty\n> todo -- <path>\n\n... I wonder why you care.  Wouldn't this work just as well?\n\n\t$ git rev-list --header --topo-order --parents --remove-empty \\\n\t  --all -- <path>\n\nIt lists 70 commits at the moment.\n"},{"id":"17642","messageId":"e5bfff550603172335v11ea36a8j9cca2ed2df58b45d@mail.gmail.com","threadId":"3668","inReplyTo":"7vfylgz29x.fsf@assigned-by-dhcp.cox.net","subject":"Re: How to find a revision's branch name","fromName":"Marco Costalba","fromEmail":"mcostalba@gmail.com","sentAt":"2006-03-18T07:35:19Z","receivedAt":"2006-03-18T07:35:19Z","isPatch":false,"sender":{"key":"mcostalba@gmail.com","avatar":null},"body":"On 3/18/06, Junio C Hamano <junkio@cox.net> wrote:\n> Marco Costalba <mcostalba@gmail.com> writes:\n>\n> > Is it possible to get branch name from a revision sha?\n> > Something like\n> >\n> > $ git branch b14e2494b8a70737066f4ade4df1b5559e81b44b\n> > todo\n>\n> That is in general impossible.\n>\n\n>\n> > I need this to correctly annotate files not in HEAD\n> > tree. Currently qgit runs git-rev-list --header --topo-order\n> > --parents --remove-empty HEAD -- <path>\n> >\n> > to get a file history. But this fails if <path> is not found\n> > in HEAD. The right command to run in our case should be:\n> > git-rev-list --header --topo-order --parents --remove-empty\n> > todo -- <path>\n>\n> ... I wonder why you care.  Wouldn't this work just as well?\n>\n>         $ git rev-list --header --topo-order --parents --remove-empty \\\n>           --all -- <path>\n>\n\nYessss!!!\n\nThanks for the fix. I missed that.\n\nMarco\n"},{"id":"17644","messageId":"7v64mcxig1.fsf@assigned-by-dhcp.cox.net","threadId":"3668","inReplyTo":"e5bfff550603172335v11ea36a8j9cca2ed2df58b45d@mail.gmail.com","subject":"Re: How to find a revision's branch name","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-18T08:31:26Z","receivedAt":"2006-03-18T08:31:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marco Costalba <mcostalba@gmail.com> writes:\n\n>> ... I wonder why you care.  Wouldn't this work just as well?\n>>\n>>         $ git rev-list --header --topo-order --parents --remove-empty \\\n>>           --all -- <path>\n>>\n>\n> Yessss!!!\n\nI think I spoke too early.  I think --remove-empty does not\nprevent rev-list from traversing branches that <path> _never_\nappears in their history, so if the <path> given was TODO, it\nwill go all the way back to the very first commit by Linus, and\nthe very first commit for gitk by Paul, without finding a commit\nthat touches that file.\n\nOne option is \"--remove-empty --all\" with <path> to omit heads\nand tags that do _not_ have given <path>s from the set of\nstarting points, but then you cannot grab history of rev-tree.c\nbetween v0.99.7 and 9dcc829 (v0.99.7 was the last tagged commit\nthat had rev-tree.c, but removal of the file happened 39 commits\nafter that), so that is not really an option.\n\nI guess we need to live with this; git.git repository is quite\nspecial.  If you clone from it, you would get todo, html and man\nbranches, so it *appears* that these are part of the same\nrepository, but logically these branches are not part of the\nproject history proper.\n\nThe commits that belong to these three branches do not appear in\nmy private development repository.  The todo branch is pushed\ninto git.git from a completely separate repository from my side,\nand html and man branches are pushed from other separate\nrepositories of their own on a kernel.org machine, automatically\nbuilt after I push new stuff into the \"master\" branch of git.git\nrepository, by the post-update hook.\n\nThe only reason I have these three branches in git.git\nrepository is historical.  I do not have write access on\nkernel.org machine in /pub/scm/git itself. I can only write in\n/pub/scm/git/git.git/, and I never bothered to ask the operators\nto make /pub/scm/git itself writable by me; otherwise I would\nhave made /pub/scm/git/git-{todo,html,man}.git repositories.\n"}]}