{"thread":{"id":"35796","subject":"git log history simplification problem","startedAt":"2014-02-04T17:37:14Z","lastAt":"2014-02-04T20:11:08Z","messageCount":5,"participants":["Miklos Vajna","Jonathan Nieder","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"234207","messageId":"20140204173713.GC17861@collabora.co.uk","threadId":"35796","inReplyTo":null,"subject":"git log history simplification problem","fromName":"Miklos Vajna","fromEmail":"vmiklos@collabora.co.uk","sentAt":"2014-02-04T17:37:14Z","receivedAt":"2014-02-04T17:37:14Z","isPatch":false,"sender":{"key":"vmiklos@collabora.co.uk","avatar":null},"body":"Hi,\n\nI was trying to understand the history of a piece of code in LibreOffice\nand I'm facing a behaviour of git-log which is not something I can\nexplain. I'm not sure if this is a git bug or a user error. ;)\n\nHere is the situation:\n\ngit clone git://anongit.freedesktop.org/libreoffice/core\ncd core\ngit log --full-history -p -S'mnTitleBarHeight =' sd/source/ui/dlg/PaneDockingWindow.cxx\n\nHere the first output I get from git-log is\nb390fae1706b9c511158a03e4fd61f263be4e511, where you can see that the\ncommit *added* that string. So it should be there on master, I would\nassume.\n\nBut then I run:\n\ngit grep 'mnTitleBarHeight =' sd\n\nand it's not there. Am I missing something, as in e.g. even with\n--full-history git-log does some simplification?\n\nThanks,\n\nMiklos\n"},{"id":"234214","messageId":"20140204190516.GD17861@collabora.co.uk","threadId":"35796","inReplyTo":"20140204173713.GC17861@collabora.co.uk","subject":"Re: git log history simplification problem","fromName":"Miklos Vajna","fromEmail":"vmiklos@collabora.co.uk","sentAt":"2014-02-04T19:05:18Z","receivedAt":"2014-02-04T19:05:18Z","isPatch":false,"sender":{"key":"vmiklos@collabora.co.uk","avatar":null},"body":"On Tue, Feb 04, 2014 at 06:37:13PM +0100, Miklos Vajna <vmiklos@collabora.co.uk> wrote:\n> But then I run:\n> \n> git grep 'mnTitleBarHeight =' sd\n> \n> and it's not there. Am I missing something, as in e.g. even with\n> --full-history git-log does some simplification?\n\nI tried to reproduce this with a repo from scratch, and it seems my\nproblem is the following:\n\n1) \"A\" creates a feature branch\n2) \"A\" works on it, and in the meantime master progresses as well\n3) \"A\" merges master to the feature branch\n4) \"A\" does some additional changes, and -- in an evil way -- uses \"git\ncommit -a --amend\" to squeeze these into the merge commit\n5) \"B\" (that's me) comes and try to find out where a string got deleted,\nbut can't.\n\nHere is a reproducer script:\n\n----\nrm -rf scratch\nmkdir scratch\ncd scratch\ngit init\necho -e \"a\\na\\na\\na\\na\\na\\na\\na\\n\" > a\ngit add a\ngit commit -m init\ngit branch feature\necho \"b\" >> a\ngit add a\ngit commit -m \"more master changes\"\ngit checkout feature\nsed -i '1iXXX' a # insert first row\ngit add a\ngit commit -m \"feature\"\ngit merge -m merge master\nsed -i '1d' a # delete first row\ngit add a\ngit commit --amend -m \"merge\"\n----\n\nI now know that the XXX got removed by the merge commit, but how can I\nsee it that I'm right? If I run 'git log --all -p' in the result, I see\nthat XXX got inserted by one commit, now I don't have it, but I don't\nsee any deletion, which confuses me.\n\nAny ideas? :-)\n\nThanks,\n\nMiklos\n"},{"id":"234217","messageId":"20140204194842.GM30398@google.com","threadId":"35796","inReplyTo":"20140204173713.GC17861@collabora.co.uk","subject":"Re: git log history simplification problem","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-02-04T19:48:42Z","receivedAt":"2014-02-04T19:48:42Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nMiklos Vajna wrote:\n\n> git clone git://anongit.freedesktop.org/libreoffice/core\n> cd core\n> git log --full-history -p -S'mnTitleBarHeight =' sd/source/ui/dlg/PaneDockingWindow.cxx\n>\n> Here the first output I get from git-log is\n> b390fae1706b9c511158a03e4fd61f263be4e511, where you can see that the\n> commit *added* that string. So it should be there on master, I would\n> assume.\n\ndf76bfb0695d19d201936df80192108e7ce51b8c (a merge) removed it.\n\nPlain 'git log' doesn't notice because in the default mode it skips\nmerges.\n\nSince the culprit commit is not in the first-parent history of HEAD,\nmy usual approach doesn't help, either:\n\n\t$ git log -m --first-parent -S'mnTitleBarHeight =' \\\n\t\t-- sd/source/ui/dlg/PaneDockingWindow.cxx\n\t$ \n\nUsing -c or --cc produces too many hits.\n\nLuckily '-m -p' without --first-parent worked and the first commit it\nshowed was the right one.  It produces more hits than I'd like, too,\nthough.\n\nThe -L option doesn't interact well enough with --reverse to handle\nthis case:\n\n\t$ git grep -p -e'mnTitleBarHeight =' b390fae1 -- sd/source/ui/dlg/PaneDockingWindow.cxx\n\tb390fae1:sd/source/ui/dlg/PaneDockingWindow.cxx=void PaneDockingWindow::Layout (void)\n\tb390fae1:sd/source/ui/dlg/PaneDockingWindow.cxx:    mnTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight();\n\tb390fae1:sd/source/ui/dlg/PaneDockingWindow.cxx:            mnTitleBarHeight = aToolBoxSize.Height();\n\tb390fae1:sd/source/ui/dlg/PaneDockingWindow.cxx:        mnTitleBarHeight = aToolBoxSize.Height();\n\t$ git log --reverse b390fae1..HEAD \\\n\t\t-L:Layout:sd/source/ui/dlg/PaneDockingWindow.cxx\n\tfatal: -L parameter 'Layout' starting at line 1: no match\n\nThanks for a useful example.\nJonathan\n"},{"id":"234219","messageId":"20140204200703.GE17861@collabora.co.uk","threadId":"35796","inReplyTo":"20140204194842.GM30398@google.com","subject":"Re: git log history simplification problem","fromName":"Miklos Vajna","fromEmail":"vmiklos@collabora.co.uk","sentAt":"2014-02-04T20:07:04Z","receivedAt":"2014-02-04T20:07:04Z","isPatch":false,"sender":{"key":"vmiklos@collabora.co.uk","avatar":null},"body":"Hi Jonathan,\n\nOn Tue, Feb 04, 2014 at 11:48:42AM -0800, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Luckily '-m -p' without --first-parent worked and the first commit it\n> showed was the right one.  It produces more hits than I'd like, too,\n> though.\n\nAh, excellent! :-) '-m' does what I need.\n\nThanks a lot,\n\nMiklos\n"},{"id":"234223","messageId":"xmqqiosu8wpv.fsf@gitster.dls.corp.google.com","threadId":"35796","inReplyTo":"20140204173713.GC17861@collabora.co.uk","subject":"Re: git log history simplification problem","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-04T20:11:08Z","receivedAt":"2014-02-04T20:11:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@collabora.co.uk> writes:\n\n> Hi,\n>\n> I was trying to understand the history of a piece of code in LibreOffice\n> and I'm facing a behaviour of git-log which is not something I can\n> explain. I'm not sure if this is a git bug or a user error. ;)\n>\n> Here is the situation:\n>\n> git clone git://anongit.freedesktop.org/libreoffice/core\n> cd core\n> git log --full-history -p -S'mnTitleBarHeight =' sd/source/ui/dlg/PaneDockingWindow.cxx\n\nLack of -m is what I would first suspect when somebody\nmisunderstands \"merge simplification\".  I am not saying that will be\nthe issue, but merely pointing out that that is the first thing that\njumps at me when I view the above command line.\n\n\n>\n> Here the first output I get from git-log is\n> b390fae1706b9c511158a03e4fd61f263be4e511, where you can see that the\n> commit *added* that string. So it should be there on master, I would\n> assume.\n>\n> But then I run:\n>\n> git grep 'mnTitleBarHeight =' sd\n>\n> and it's not there. Am I missing something, as in e.g. even with\n> --full-history git-log does some simplification?\n>\n> Thanks,\n>\n> Miklos\n"}]}