{"thread":{"id":"8219","subject":"Commits gone AWOL, but not reported by git-fsck --unreachable","startedAt":"2007-05-19T10:30:11Z","lastAt":"2007-05-22T06:17:32Z","messageCount":17,"participants":["Robin H. Johnson","Jeff King","Anand Kumria","Matthieu Moy","Brian Gernhardt","Junio C Hamano","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"42611","messageId":"20070519103011.GU17511@curie-int.orbis-terrarum.net","threadId":"8219","inReplyTo":null,"subject":"Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2007-05-19T10:30:11Z","receivedAt":"2007-05-19T10:30:11Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"Background:\n-----------\nUsing git-svn to work with an external project (non-public), and the\nother day I happened to run 'git-svn dcommit' right as their SVN went\ndown for a moment (under 5 seconds) for the snapshot-backup. I recall\nswearing profusely at the time, but thought nothing of it after that,\nuntil now, when I saw that parts of my tree weren't as they should be.\n\nProblem:\n--------\nA bunch of my commits are NOT present in git-log, git-rev-list, or any\ntool that provides the history of my branches.\n\nIf I hack around and recover the commitid, I can pass it to git-show,\nand the commit does still exist in the data.\n\ngit-fsck --unreachable does not list the commit in question either, but\ndoes list other blobs and trees.\n\nLuckily, since the entire tree had ~900 commits, I was able to work some\nmagic and recovery my work:\n1. Hack to get list of all commits\n2. Exclude all commits that had git-svn-id in their description.\n3. Exclude all merges.\n4. Manually review all remaining commits (~70).\n\nThe following questions are mainly things that would have made my\nrecovery far easier.\n\nQuestions:\n----------\n1. Is there a plumbing tool to list EVERY single object of a given type\n   (blob, tree, commit, tag) that git is aware of, regardless of it\n   being reachable? (Right now I have a hack to read the pack index, and\n   use find to find the non-packed object ids, then git-cat-file -t for\n   the type).\n2. A sane way to view an ordered set of commits, so that it should be\n   possible to spot when there's a path of commits that went off and\n   isn't used anymore.\n3. Given a set of commits, list which are actually unique (in my tree,\n   git-svn uses rebase often, so I have a lot of commits that are\n   identical bar the commitid).\n4. Strongly related to #4, given everything a commit, tell me what other\n   identical commits exist in the tree.\n\n-- \nRobin Hugh Johnson\nGentoo Linux Developer & Council Member\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"42615","messageId":"20070519115245.GA10035@coredump.intra.peff.net","threadId":"8219","inReplyTo":"20070519103011.GU17511@curie-int.orbis-terrarum.net","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-05-19T11:52:45Z","receivedAt":"2007-05-19T11:52:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, May 19, 2007 at 03:30:11AM -0700, Robin H. Johnson wrote:\n\n> Problem:\n> --------\n> A bunch of my commits are NOT present in git-log, git-rev-list, or any\n> tool that provides the history of my branches.\n> \n> If I hack around and recover the commitid, I can pass it to git-show,\n> and the commit does still exist in the data.\n> \n> git-fsck --unreachable does not list the commit in question either, but\n> does list other blobs and trees.\n\nAre you sure it isn't in your reflog? Try 'git reflog show' or 'git log\n-g'.\n\n-Peff\n"},{"id":"42618","messageId":"20070519120933.GW17511@curie-int.orbis-terrarum.net","threadId":"8219","inReplyTo":"20070519115245.GA10035@coredump.intra.peff.net","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2007-05-19T12:09:33Z","receivedAt":"2007-05-19T12:09:33Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"On Sat, May 19, 2007 at 07:52:45AM -0400, Jeff King wrote:\n> On Sat, May 19, 2007 at 03:30:11AM -0700, Robin H. Johnson wrote:\n> > Problem:\n> > --------\n> > A bunch of my commits are NOT present in git-log, git-rev-list, or any\n> > tool that provides the history of my branches.\n> > \n> > If I hack around and recover the commitid, I can pass it to git-show,\n> > and the commit does still exist in the data.\n> > \n> > git-fsck --unreachable does not list the commit in question either, but\n> > does list other blobs and trees.\n> Are you sure it isn't in your reflog? Try 'git reflog show' or 'git log\n> -g'.\nAhh, they do show up there (and I learnt a new git command now, thanks)\n- the ones that I can remember the Subject lines for anyway.\n\nAny hints for the future on finding stuff that is in the reflog but not\nin the tree? (Remembering every subject line isn't feasible).\n\n-- \nRobin Hugh Johnson\nGentoo Linux Developer & Council Member\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"42619","messageId":"20070519121154.GA10268@coredump.intra.peff.net","threadId":"8219","inReplyTo":"20070519120933.GW17511@curie-int.orbis-terrarum.net","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-05-19T12:11:54Z","receivedAt":"2007-05-19T12:11:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, May 19, 2007 at 05:09:33AM -0700, Robin H. Johnson wrote:\n\n> Ahh, they do show up there (and I learnt a new git command now, thanks)\n> - the ones that I can remember the Subject lines for anyway.\n> \n> Any hints for the future on finding stuff that is in the reflog but not\n> in the tree? (Remembering every subject line isn't feasible).\n\nTry 'git-fsck --unreachable --no-reflogs'. :)\n\n-Peff\n"},{"id":"42626","messageId":"pan.2007.05.19.15.45.46@progsoc.org","threadId":"8219","inReplyTo":"20070519121154.GA10268@coredump.intra.peff.net","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Anand Kumria","fromEmail":"wildfire@progsoc.org","sentAt":"2007-05-19T15:45:49Z","receivedAt":"2007-05-19T15:45:49Z","isPatch":false,"sender":{"key":"wildfire@progsoc.org","avatar":null},"body":"On Sat, 19 May 2007 08:11:54 -0400, Jeff King wrote:\n\n> On Sat, May 19, 2007 at 05:09:33AM -0700, Robin H. Johnson wrote:\n> \n>> Ahh, they do show up there (and I learnt a new git command now, thanks)\n>> - the ones that I can remember the Subject lines for anyway.\n>> \n>> Any hints for the future on finding stuff that is in the reflog but not\n>> in the tree? (Remembering every subject line isn't feasible).\n> \n> Try 'git-fsck --unreachable --no-reflogs'. :)\n\nWhat version? git 1.5.1.4 doesn't seem to have that.\n\nAnand\n"},{"id":"42628","messageId":"vpq646opzio.fsf@bauges.imag.fr","threadId":"8219","inReplyTo":"pan.2007.05.19.15.45.46@progsoc.org","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-05-19T16:08:15Z","receivedAt":"2007-05-19T16:08:15Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Anand Kumria <wildfire@progsoc.org> writes:\n\n> On Sat, 19 May 2007 08:11:54 -0400, Jeff King wrote:\n>\n>> On Sat, May 19, 2007 at 05:09:33AM -0700, Robin H. Johnson wrote:\n>> \n>>> Ahh, they do show up there (and I learnt a new git command now, thanks)\n>>> - the ones that I can remember the Subject lines for anyway.\n>>> \n>>> Any hints for the future on finding stuff that is in the reflog but not\n>>> in the tree? (Remembering every subject line isn't feasible).\n>> \n>> Try 'git-fsck --unreachable --no-reflogs'. :)\n>\n> What version? git 1.5.1.4 doesn't seem to have that.\n\nThe commit introducing it is 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\nand I'd say it's in git 1.5.1:\n\n$ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b                                                                                     \nv1.5.1-34-g566842f\n\n-- \nMatthieu\n"},{"id":"42629","messageId":"A04FB6C2-20B2-4263-9D58-6C281C04C6C4@silverinsanity.com","threadId":"8219","inReplyTo":"vpq646opzio.fsf@bauges.imag.fr","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2007-05-19T16:20:56Z","receivedAt":"2007-05-19T16:20:56Z","isPatch":false,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn May 19, 2007, at 12:08 PM, Matthieu Moy wrote:\n\n> The commit introducing it is 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\n> and I'd say it's in git 1.5.1:\n>\n> $ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b\n> v1.5.1-34-g566842f\n\nActually, I think that means it's 34 commits *after* v1.5.1, not  \nbefore.  It's in 1.5.2-rc0, but none of the 1.5.1.* series.\n\n~~ Brian\n"},{"id":"42633","messageId":"vpq8xbkoir8.fsf@bauges.imag.fr","threadId":"8219","inReplyTo":"A04FB6C2-20B2-4263-9D58-6C281C04C6C4@silverinsanity.com","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-05-19T16:55:39Z","receivedAt":"2007-05-19T16:55:39Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Brian Gernhardt <benji@silverinsanity.com> writes:\n\n> On May 19, 2007, at 12:08 PM, Matthieu Moy wrote:\n>\n>> The commit introducing it is 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\n>> and I'd say it's in git 1.5.1:\n>>\n>> $ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b\n>> v1.5.1-34-g566842f\n>\n> Actually, I think that means it's 34 commits *after* v1.5.1, not\n> before.  It's in 1.5.2-rc0, but none of the 1.5.1.* series.\n\nYou're right. Then, is there any easy way to ask git the oldest tag(s)\nthat a commit is an ancestor of? In other words, which command should\nI have typed above?\n\n-- \nMatthieu\n"},{"id":"42634","messageId":"839C7D1E-E1D0-4EA1-8221-789C418CB242@silverinsanity.com","threadId":"8219","inReplyTo":"vpq8xbkoir8.fsf@bauges.imag.fr","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2007-05-19T17:13:47Z","receivedAt":"2007-05-19T17:13:47Z","isPatch":false,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn May 19, 2007, at 12:55 PM, Matthieu Moy wrote:\n\n> Brian Gernhardt <benji@silverinsanity.com> writes:\n>\n>> On May 19, 2007, at 12:08 PM, Matthieu Moy wrote:\n>>\n>>> The commit introducing it is  \n>>> 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\n>>> and I'd say it's in git 1.5.1:\n>>>\n>>> $ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b\n>>> v1.5.1-34-g566842f\n>>\n>> Actually, I think that means it's 34 commits *after* v1.5.1, not\n>> before.  It's in 1.5.2-rc0, but none of the 1.5.1.* series.\n>\n> You're right. Then, is there any easy way to ask git the oldest tag(s)\n> that a commit is an ancestor of? In other words, which command should\n> I have typed above?\n\nI did it the hard way with \"git log v1.5.1..v.1.5.1.1\", \"..1.5.1.2\",  \nand using grep to look for 566842.  Anybody better at constructing  \nthese incantations want to chime in?\n\n~~ Brian\n"},{"id":"42637","messageId":"7vfy5sy91f.fsf@assigned-by-dhcp.cox.net","threadId":"8219","inReplyTo":"839C7D1E-E1D0-4EA1-8221-789C418CB242@silverinsanity.com","subject":"Re: Commits gone AWOL, but not reported by git-fsck --unreachable","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-19T18:15:24Z","receivedAt":"2007-05-19T18:15:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brian Gernhardt <benji@silverinsanity.com> writes:\n\n> On May 19, 2007, at 12:55 PM, Matthieu Moy wrote:\n>\n>> Brian Gernhardt <benji@silverinsanity.com> writes:\n>>\n>>> On May 19, 2007, at 12:08 PM, Matthieu Moy wrote:\n>>>\n>>>> The commit introducing it is\n>>>> 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\n>>>> and I'd say it's in git 1.5.1:\n>>>>\n>>>> $ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b\n>>>> v1.5.1-34-g566842f\n>>>\n>>> Actually, I think that means it's 34 commits *after* v1.5.1, not\n>>> before.  It's in 1.5.2-rc0, but none of the 1.5.1.* series.\n>>\n>> You're right. Then, is there any easy way to ask git the oldest tag(s)\n>> that a commit is an ancestor of? In other words, which command should\n>> I have typed above?\n>\n> I did it the hard way with \"git log v1.5.1..v.1.5.1.1\", \"..1.5.1.2\",\n> and using grep to look for 566842.  Anybody better at constructing\n> these incantations want to chime in?\n\nPerhaps \"git-name-rev --refs='refs/tags/v*' $it\"?\n"},{"id":"42705","messageId":"vpq7ir3658t.fsf_-_@bauges.imag.fr","threadId":"8219","inReplyTo":"7vfy5sy91f.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Cross-reference the manpages for git-name-rev and git-describe (was Re: Commits gone AWOL, but not reported by git-fsck --unreachable)","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-05-20T12:37:06Z","receivedAt":"2007-05-20T12:37:06Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Brian Gernhardt <benji@silverinsanity.com> writes:\n>\n>> On May 19, 2007, at 12:55 PM, Matthieu Moy wrote:\n>>\n>>> Brian Gernhardt <benji@silverinsanity.com> writes:\n>>>\n>>>> On May 19, 2007, at 12:08 PM, Matthieu Moy wrote:\n>>>>\n>>>>> The commit introducing it is\n>>>>> 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b,\n>>>>> and I'd say it's in git 1.5.1:\n>>>>>\n>>>>> $ git-describe --tags 566842f62bdf1f16c2e94fb431445d2e6c0f3f0b\n>>>>> v1.5.1-34-g566842f\n>>>>\n>>>> Actually, I think that means it's 34 commits *after* v1.5.1, not\n>>>> before.  It's in 1.5.2-rc0, but none of the 1.5.1.* series.\n>>>\n>>> You're right. Then, is there any easy way to ask git the oldest tag(s)\n>>> that a commit is an ancestor of? In other words, which command should\n>>> I have typed above?\n>>\n>> I did it the hard way with \"git log v1.5.1..v.1.5.1.1\", \"..1.5.1.2\",\n>> and using grep to look for 566842.  Anybody better at constructing\n>> these incantations want to chime in?\n>\n> Perhaps \"git-name-rev --refs='refs/tags/v*' $it\"?\n\nYes, that's the one I was looking for (I knew it, but mixed name-rev\nand describe).\n\nHow about this documentation patch then?\n\n\n>From c280d7db974faacf388314e0396c9d50b40d55aa Mon Sep 17 00:00:00 2001\nFrom: Matthieu Moy <Matthieu.Moy@imag.fr>\nDate: Sun, 20 May 2007 14:33:44 +0200\nSubject: [PATCH] Cross-reference the manpages for git-name-rev and git-describe\n\nBoth commands achieve a very similar goal.\n---\n Documentation/git-describe.txt |    4 ++++\n Documentation/git-name-rev.txt |    4 ++++\n 2 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\nindex 47a583d..ff8383d 100644\n--- a/Documentation/git-describe.txt\n+++ b/Documentation/git-describe.txt\n@@ -105,6 +105,10 @@ selected and output.  Here fewest commits different is defined as\n the number of commits which would be shown by \"git log tag..input\"\n will be the smallest number of commits possible.\n \n+See Also\n+--------\n+gitlink:git-name-rev[1] (very similar to git-describe, but searches\n+the succesors of the commit)\n \n Author\n ------\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex d6c8bf8..bdb0b27 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -57,6 +57,10 @@ Another nice thing you can do is:\n % git log | git name-rev --stdin\n ------------\n \n+See Also\n+--------\n+gitlink:git-describe[1] (very similar to git-name-rev, but searches\n+the ancestors of the commit)\n \n Author\n ------\n-- \n1.5.2.rc3.32.ga3b1\n\n\n\n-- \nMatthieu\n"},{"id":"42855","messageId":"20070521072025.GO3141@spearce.org","threadId":"8219","inReplyTo":"7vsl9rmkm0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-21T07:20:25Z","receivedAt":"2007-05-21T07:20:25Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> wouldn't this be useful?\n> \n> $ git-describe --contains --tags 1b600e659\n> v1.5.0-rc3~34\n\nLike this?  ;-)\n\n-->8--\nTeach git-describe how to run name-rev\n\nOften users want to know not which tagged version a commit came\nafter, but which tagged version a commit is contained within.\nThis latter task is the job of git-name-rev, but most users are\nlooking to git-describe to do the job.\n\nJunio suggested we make `git describe --contains` run the correct\ntool, `git name-rev`, and that's exactly what we do here.  The output\nof name-rev was adjusted slightly through the new --name-only option,\nallowing describe to execv into name-rev and maintain its current\noutput format.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n Documentation/git-describe.txt |    7 ++++++-\n Documentation/git-name-rev.txt |    7 +++++++\n builtin-describe.c             |   15 +++++++++++++++\n builtin-name-rev.c             |   23 +++++++++++++++++------\n 4 files changed, 45 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\nindex 47a583d..dc47b65 100644\n--- a/Documentation/git-describe.txt\n+++ b/Documentation/git-describe.txt\n@@ -8,7 +8,7 @@ git-describe - Show the most recent tag that is reachable from a commit\n \n SYNOPSIS\n --------\n-'git-describe' [--all] [--tags] [--abbrev=<n>] <committish>...\n+'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...\n \n DESCRIPTION\n -----------\n@@ -31,6 +31,11 @@ OPTIONS\n \tInstead of using only the annotated tags, use any tag\n \tfound in `.git/refs/tags`.\n \n+--contains::\n+\tInstead of finding the tag that predates the commit, find\n+\tthe tag that comes after the commit, and thus contains it.\n+\tAutomatically implies --tags.\n+\n --abbrev=<n>::\n \tInstead of using the default 8 hexadecimal digits as the\n \tabbreviated object name, use <n> digits.\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex d6c8bf8..9a1645d 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -34,6 +34,13 @@ OPTIONS\n \tRead from stdin, append \"(<rev_name>)\" to all sha1's of nameable\n \tcommits, and pass to stdout\n \n+--name-only::\n+\tInstead of printing both the SHA-1 and the name, print only\n+\tthe name.  If given with --tags the usual tag prefix of\n+\t\"tags/\" is also ommitted from the name, matching the output\n+\tof gitlink::git-describe[1] more closely.  This option\n+\tcannot be combined with --stdin.\n+\n EXAMPLE\n -------\n \ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex 165917e..efbd43f 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -3,6 +3,7 @@\n #include \"tag.h\"\n #include \"refs.h\"\n #include \"builtin.h\"\n+#include \"exec_cmd.h\"\n \n #define SEEN\t\t(1u<<0)\n #define MAX_TAGS\t(FLAG_BITS - 1)\n@@ -242,12 +243,15 @@ static void describe(const char *arg, int last_one)\n int cmd_describe(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n+\tint contains = 0;\n \n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \n \t\tif (*arg != '-')\n \t\t\tbreak;\n+\t\telse if (!strcmp(arg, \"--contains\"))\n+\t\t\tcontains = 1;\n \t\telse if (!strcmp(arg, \"--debug\"))\n \t\t\tdebug = 1;\n \t\telse if (!strcmp(arg, \"--all\"))\n@@ -272,6 +276,17 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \n \tsave_commit_buffer = 0;\n \n+\tif (contains) {\n+\t\tconst char **nr = xmalloc((4 + argc - i) * sizeof(char*));\n+\t\tnr[0] = \"name-rev\";\n+\t\tnr[1] = \"--name-only\";\n+\t\tnr[2] = \"--tags\";\n+\t\tmemcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));\n+\t\tnr[3 + argc - i] = NULL;\n+\t\texecv_git_cmd(nr);\n+\t\tdie(\"unable to start %s\", nr[0]);\n+\t}\n+\n \tif (argc <= i)\n \t\tdescribe(\"HEAD\", 1);\n \telse\ndiff --git a/builtin-name-rev.c b/builtin-name-rev.c\nindex ef16385..a639e2f 100644\n--- a/builtin-name-rev.c\n+++ b/builtin-name-rev.c\n@@ -83,6 +83,7 @@ copy_data:\n \n struct name_ref_data {\n \tint tags_only;\n+\tint name_only;\n \tconst char *ref_filter;\n };\n \n@@ -110,6 +111,10 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void\n \n \t\tif (!prefixcmp(path, \"refs/heads/\"))\n \t\t\tpath = path + 11;\n+\t\telse if (data->tags_only\n+\t\t    && data->name_only\n+\t\t    && !prefixcmp(path, \"refs/tags/\"))\n+\t\t\tpath = path + 10;\n \t\telse if (!prefixcmp(path, \"refs/\"))\n \t\t\tpath = path + 5;\n \n@@ -149,7 +154,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = { 0, 0, NULL };\n \tint as_is = 0, all = 0, transform_stdin = 0;\n-\tstruct name_ref_data data = { 0, NULL };\n+\tstruct name_ref_data data = { 0, 0, NULL };\n \n \tgit_config(git_default_config);\n \n@@ -165,6 +170,9 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\tif (!strcmp(*argv, \"--\")) {\n \t\t\t\tas_is = 1;\n \t\t\t\tcontinue;\n+\t\t\t} else if (!strcmp(*argv, \"--name-only\")) {\n+\t\t\t\tdata.name_only = 1;\n+\t\t\t\tcontinue;\n \t\t\t} else if (!strcmp(*argv, \"--tags\")) {\n \t\t\t\tdata.tags_only = 1;\n \t\t\t\tcontinue;\n@@ -263,14 +271,17 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\tstruct object * obj = get_indexed_object(i);\n \t\t\tif (!obj)\n \t\t\t\tcontinue;\n-\t\t\tprintf(\"%s %s\\n\", sha1_to_hex(obj->sha1), get_rev_name(obj));\n+\t\t\tif (!data.name_only)\n+\t\t\t\tprintf(\"%s \", sha1_to_hex(obj->sha1));\n+\t\t\tprintf(\"%s\\n\", get_rev_name(obj));\n \t\t}\n \t} else {\n \t\tint i;\n-\t\tfor (i = 0; i < revs.nr; i++)\n-\t\t\tprintf(\"%s %s\\n\",\n-\t\t\t\trevs.objects[i].name,\n-\t\t\t\tget_rev_name(revs.objects[i].item));\n+\t\tfor (i = 0; i < revs.nr; i++) {\n+\t\t\tif (!data.name_only)\n+\t\t\t\tprintf(\"%s \", revs.objects[i].name);\n+\t\t\tprintf(\"%s\\n\", get_rev_name(revs.objects[i].item));\n+\t\t}\n \t}\n \n \treturn 0;\n-- \n1.5.2.14.g45bde-dirty\n\n-- \nShawn.\n"},{"id":"42860","messageId":"7viramfwkq.fsf@assigned-by-dhcp.cox.net","threadId":"8219","inReplyTo":"20070521072025.GO3141@spearce.org","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-21T07:46:29Z","receivedAt":"2007-05-21T07:46:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> wouldn't this be useful?\n>> \n>> $ git-describe --contains --tags 1b600e659\n>> v1.5.0-rc3~34\n>\n> Like this?  ;-)\n\nYeah, something like that.\n\nNow we need to make sure that the name of the option --contains\nis sane, I guess.\n"},{"id":"42863","messageId":"20070521075413.GQ3141@spearce.org","threadId":"8219","inReplyTo":"7viramfwkq.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-21T07:54:13Z","receivedAt":"2007-05-21T07:54:13Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> > Junio C Hamano <junkio@cox.net> wrote:\n> >> wouldn't this be useful?\n> >> \n> >> $ git-describe --contains --tags 1b600e659\n> >> v1.5.0-rc3~34\n> \n> Now we need to make sure that the name of the option --contains\n> is sane, I guess.\n\nI think its sane.  I wanted to do a --contains option to describe\na while back, for this reason, but just didn't get around to it.\nYou also suggested it.  Looks like at least two people came up with\nthat option independently.  That's not too bad.\n\nFeel free to edit the patch if something else better comes up.\n\n-- \nShawn.\n"},{"id":"42867","messageId":"vpqr6pafvw6.fsf@bauges.imag.fr","threadId":"8219","inReplyTo":"7viramfwkq.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-05-21T08:01:13Z","receivedAt":"2007-05-21T08:01:13Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n>\n>> Junio C Hamano <junkio@cox.net> wrote:\n>>> wouldn't this be useful?\n>>> \n>>> $ git-describe --contains --tags 1b600e659\n>>> v1.5.0-rc3~34\n\n[ I didn't receive this message, and gmane doesn't seem to have it.\n  Strange ]\n\n>> Like this?  ;-)\n>\n> Yeah, something like that.\n>\n> Now we need to make sure that the name of the option --contains\n> is sane, I guess.\n\nIt seems OK to me. Perhaps --forward (optionally with a --backward\noverriding it) could do too.\n\n-- \nMatthieu\n"},{"id":"42947","messageId":"7vhcq59yiy.fsf@assigned-by-dhcp.cox.net","threadId":"8219","inReplyTo":"20070521072025.GO3141@spearce.org","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-22T06:13:09Z","receivedAt":"2007-05-22T06:13:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Teach git-describe how to run name-rev\n>\n> Often users want to know not which tagged version a commit came\n> after, but which tagged version a commit is contained within.\n> This latter task is the job of git-name-rev, but most users are\n> looking to git-describe to do the job.\n>\n> Junio suggested we make `git describe --contains` run the correct\n> tool, `git name-rev`, and that's exactly what we do here.  The output\n> of name-rev was adjusted slightly through the new --name-only option,\n> allowing describe to execv into name-rev and maintain its current\n> output format.\n>\n> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>\n> ...\n> diff --git a/builtin-describe.c b/builtin-describe.c\n> index 165917e..efbd43f 100644\n> --- a/builtin-describe.c\n> +++ b/builtin-describe.c\n> ...\n> @@ -272,6 +276,17 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n>  \n>  \tsave_commit_buffer = 0;\n>  \n> +\tif (contains) {\n> +\t\tconst char **nr = xmalloc((4 + argc - i) * sizeof(char*));\n> +\t\tnr[0] = \"name-rev\";\n> +\t\tnr[1] = \"--name-only\";\n> +\t\tnr[2] = \"--tags\";\n> +\t\tmemcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));\n> +\t\tnr[3 + argc - i] = NULL;\n> +\t\texecv_git_cmd(nr);\n> +\t\tdie(\"unable to start %s\", nr[0]);\n> +\t}\n> +\n>  \tif (argc <= i)\n>  \t\tdescribe(\"HEAD\", 1);\n>  \telse\n\nSorry for a belated question, but is there a reason not to do\nthis (on top)?\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex efbd43f..2a32af6 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -283,8 +283,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\tnr[2] = \"--tags\";\n \t\tmemcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));\n \t\tnr[3 + argc - i] = NULL;\n-\t\texecv_git_cmd(nr);\n-\t\tdie(\"unable to start %s\", nr[0]);\n+\t\treturn cmd_name_rev(3 + argc - i, nr, prefix);\n \t}\n \n \tif (argc <= i)\n"},{"id":"42949","messageId":"20070522061732.GC11636@spearce.org","threadId":"8219","inReplyTo":"7vhcq59yiy.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-22T06:17:32Z","receivedAt":"2007-05-22T06:17:32Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > Teach git-describe how to run name-rev\n> \n> Sorry for a belated question, but is there a reason not to do\n> this (on top)?\n\nNope, I just completely missed it.  Please make it so!  ;-)\n \n> diff --git a/builtin-describe.c b/builtin-describe.c\n> index efbd43f..2a32af6 100644\n> --- a/builtin-describe.c\n> +++ b/builtin-describe.c\n> @@ -283,8 +283,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n>  \t\tnr[2] = \"--tags\";\n>  \t\tmemcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));\n>  \t\tnr[3 + argc - i] = NULL;\n> -\t\texecv_git_cmd(nr);\n> -\t\tdie(\"unable to start %s\", nr[0]);\n> +\t\treturn cmd_name_rev(3 + argc - i, nr, prefix);\n>  \t}\n>  \n>  \tif (argc <= i)\n> \n\n-- \nShawn.\n"}]}