{"thread":{"id":"24251","subject":"git reflog delete / manpage confusion","startedAt":"2010-07-01T09:38:04Z","lastAt":"2010-07-01T13:09:41Z","messageCount":4,"participants":["Mahesh Vaidya","Jeff King","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144576","messageId":"AANLkTik3bApuScgjXtr-VjhmY4NIuakoX_RZaYLqqpwL@mail.gmail.com","threadId":"24251","inReplyTo":null,"subject":"git reflog delete / manpage confusion","fromName":"Mahesh Vaidya","fromEmail":"forvaidya@gmail.com","sentAt":"2010-07-01T09:38:04Z","receivedAt":"2010-07-01T09:38:04Z","isPatch":false,"sender":{"key":"forvaidya@gmail.com","avatar":null},"body":"git reflog delete HEAD{4} indeed deletes  HEAD{5} or N+1 ; is there a\nbug manpage or my interpretation ?\n\n>From Manpage\nTo delete single entries from the reflog, use the subcommand \"delete\"\nand specify the exact entry (e.g. \"git\n       reflog delete master@{2}\").\n\n-Mahesh\n"},{"id":"144579","messageId":"20100701101613.GA1961@sigill.intra.peff.net","threadId":"24251","inReplyTo":"AANLkTik3bApuScgjXtr-VjhmY4NIuakoX_RZaYLqqpwL@mail.gmail.com","subject":"Re: git reflog delete / manpage confusion","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-07-01T10:16:13Z","receivedAt":"2010-07-01T10:16:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jul 01, 2010 at 03:08:04PM +0530, Mahesh Vaidya wrote:\n\n> git reflog delete HEAD{4} indeed deletes  HEAD{5} or N+1 ; is there a\n> bug manpage or my interpretation ?\n\nHmm. I don't think the deletion is wrong, but rather the walker. Try:\n\n  mkdir repo && cd repo && git init\n  for i in 1 2 3 4 5; do\n    echo $i >file && git add file && git commit -m file\n  done\n  git reflog -g --oneline >old\n  git reflog delete HEAD@{3}\n  git reflog -g --oneline >new\n  diff -u old new\n\nI get:\n\n  --- old 2010-07-01 05:54:48.000000000 -0400\n  +++ new 2010-07-01 05:54:48.000000000 -0400\n  @@ -1,5 +1,4 @@\n   01bb1c7 HEAD@{0}: commit: file\n   c8020a8 HEAD@{1}: commit: file\n   d82df6b HEAD@{2}: commit: file\n  -364bcc0 HEAD@{3}: commit: file\n  -2993260 HEAD@{4}: commit (initial): file\n  +364bcc0 HEAD@{3}: commit (initial): file\n\nSo we give the proper reflog message (but note that HEAD@{4} has become\nHEAD@{3}, because we always number compactly). But the sha1 still refers\nto the deleted entry! We show the initial commit as creating 364bcc0,\nwhen it didn't.\n\nWhat happens is that there is a gap in the reflog (apologies for the\nlong lines):\n\n  $ cat .git/logs/HEAD\n  0000000000000000000000000000000000000000 299326064426c58bfec68b44b50a37fe7ec4e15e Jeff King <peff@peff.net> 1277978088 -0400    commit (initial): file\n  364bcc0479c8b2d3a8a4be0cd67e46c81afafb03 d82df6b185d19134c7330cb93a7eb7c630b0714a Jeff King <peff@peff.net> 1277978088 -0400    commit: file\n  d82df6b185d19134c7330cb93a7eb7c630b0714a c8020a8ead949ab725abc0dfe2345b2aeca6c145 Jeff King <peff@peff.net> 1277978088 -0400    commit: file\n  c8020a8ead949ab725abc0dfe2345b2aeca6c145 01bb1c78a68703338810a559cdef270e10192fc3 Jeff King <peff@peff.net> 1277978088 -0400    commit: file\n\nIf I do \"git show HEAD@{3}\" I will properly get 2993260, and a warning:\n\n  warning: Log .git/logs/HEAD has gap after Thu, 1 Jul 2010 05:54:48 -0400.\n\nSo I think that delete is behaving properly, but the reflog walker in\n\"git log -g\" should be using the second field of HEAD@{3} to determine\nthe commit sha1, not the first field from HEAD@{2}. In the normal case\nthey are the same, but with a gap, they will be different (which should\nalso probably provoke us to print a gap warning as above).\n\nI took a look at how hard this would be to fix. It looks like the wrong\nsha1 is actually printed by the regular pretty-printer, which then calls\nshow_reflog_message() to show the actual entry. Which means we probably\nneed some special case hackery in show_log() to handle this case.\n\nShawn, any thoughts?\n\n-Peff\n"},{"id":"144584","messageId":"AANLkTilaKwB1BYTNIJ49M0CZAJGrsPetQDOxZj_RHRv3@mail.gmail.com","threadId":"24251","inReplyTo":"20100701101613.GA1961@sigill.intra.peff.net","subject":"Re: git reflog delete / manpage confusion","fromName":"Mahesh Vaidya","fromEmail":"forvaidya@gmail.com","sentAt":"2010-07-01T10:58:46Z","receivedAt":"2010-07-01T10:58:46Z","isPatch":false,"sender":{"key":"forvaidya@gmail.com","avatar":null},"body":"Hi I am confused again as it indeed removed HEAD{4}\n\n -2993260 HEAD@{4}: commit (initial)\n\n>  mkdir repo && cd repo && git init\n>  for i in 1 2 3 4 5; do\n>    echo $i >file && git add file && git commit -m file\n>  done\n>  git reflog -g --oneline >old\n>  git reflog delete HEAD@{3}\n>  git reflog -g --oneline >new\n>  diff -u old new\n>\n> I get:\n>\n>  --- old 2010-07-01 05:54:48.000000000 -0400\n>  +++ new 2010-07-01 05:54:48.000000000 -0400\n>  @@ -1,5 +1,4 @@\n>   01bb1c7 HEAD@{0}: commit: file\n>   c8020a8 HEAD@{1}: commit: file\n>   d82df6b HEAD@{2}: commit: file\n>  -364bcc0 HEAD@{3}: commit: file\n>  -2993260 HEAD@{4}: commit (initial): file\n>  +364bcc0 HEAD@{3}: commit (initial): file\n"},{"id":"144589","messageId":"4C2C9395.1080900@drmicha.warpmail.net","threadId":"24251","inReplyTo":"AANLkTilaKwB1BYTNIJ49M0CZAJGrsPetQDOxZj_RHRv3@mail.gmail.com","subject":"Re: git reflog delete / manpage confusion","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-07-01T13:09:41Z","receivedAt":"2010-07-01T13:09:41Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Mahesh Vaidya venit, vidit, dixit 01.07.2010 12:58:\n> Hi I am confused again as it indeed removed HEAD{4}\n> \n>  -2993260 HEAD@{4}: commit (initial)\n\nIt didn't, that's what Jeff explained and what the content of\n.git/logs/HEAD showed (which you chose to cut; also, please don't top-post).\n\nIt really deleted the line for 364bcc0, but when showing the reflog git\nmistakenly shows 364bcc0 rather than 2993260 (for the new HEAD{@3}) in\nthis case.\n\nMichael\n"}]}