{"thread":{"id":"11784","subject":"Can git log <file> follow log of its origins?","startedAt":"2008-01-29T17:48:05Z","lastAt":"2008-01-29T21:40:14Z","messageCount":7,"participants":["Max Pollard","Sean","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"66842","messageId":"333479.13589.qm@web45901.mail.sp1.yahoo.com","threadId":"11784","inReplyTo":null,"subject":"Can git log <file> follow log of its origins?","fromName":"Max Pollard","fromEmail":"ajaxsupremo@yahoo.com","sentAt":"2008-01-29T17:48:05Z","receivedAt":"2008-01-29T17:48:05Z","isPatch":false,"sender":{"key":"ajaxsupremo@yahoo.com","avatar":null},"body":"Hi all,\n\nIf I do the following:\n\n     $ git init\n     $ echo \"The brown fox is getting old\" > a.txt\n     $ git add a.txt\n     $ git commit -m \"Commit a.txt\"\n\n     $ cp a.txt b.txt\n     $ git add b.txt\n     $ git commit -m \"Copy a.txt to b.txt\"\n\n     $ git log b.txt\n\nI only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it possible\nto have the above command keep going and show the history of a.txt?  Or at\nleast somehow indicate that b.txt originated from a.txt?\n\n\nThanks,\nMP\n\n\n\n      ____________________________________________________________________________________\nNever miss a thing.  Make Yahoo your home page. \nhttp://www.yahoo.com/r/hs\n"},{"id":"66843","messageId":"BAYC1-PASMTP0711D909B278C305D7F28AAE350@CEZ.ICE","threadId":"11784","inReplyTo":"333479.13589.qm@web45901.mail.sp1.yahoo.com","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2008-01-29T18:17:09Z","receivedAt":"2008-01-29T18:17:09Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Tue, 29 Jan 2008 09:48:05 -0800 (PST)\nMax Pollard <ajaxsupremo@yahoo.com> wrote:\n\n> If I do the following:\n> \n>      $ git init\n>      $ echo \"The brown fox is getting old\" > a.txt\n>      $ git add a.txt\n>      $ git commit -m \"Commit a.txt\"\n> \n>      $ cp a.txt b.txt\n>      $ git add b.txt\n>      $ git commit -m \"Copy a.txt to b.txt\"\n> \n>      $ git log b.txt\n> \n> I only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it possible\n> to have the above command keep going and show the history of a.txt?  Or at\n> least somehow indicate that b.txt originated from a.txt?\n\nHi Max,\n\nNot sure it will leave you feeling totally satisfied but the\nfollowing command will at least show you the copy which\noccurred in that commit:\n\n$ git log --full-diff -C --find-copies-harder --stat -- b.txt\ncommit 578ecbc516e70ce7178545233192a08369a07101\nAuthor: xyz <x@y.z>\nDate:   Tue Jan 29 13:11:16 2008 -0500\n\n    Copy a.txt to b.txt\n\n a.txt => b.txt |    0 \n 1 files changed, 0 insertions(+), 0 deletions(-)\n\nIf you had done a rename instead of a copy, then \"git log --follow b.txt\" would\nhave done what you're looking for, but there is no corresponding option to\nfollow copies.\n\nHTH,\nSean\n"},{"id":"66848","messageId":"146301.84241.qm@web45914.mail.sp1.yahoo.com","threadId":"11784","inReplyTo":"BAYC1-PASMTP0711D909B278C305D7F28AAE350@CEZ.ICE","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Max Pollard","fromEmail":"ajaxsupremo@yahoo.com","sentAt":"2008-01-29T19:47:20Z","receivedAt":"2008-01-29T19:47:20Z","isPatch":false,"sender":{"key":"ajaxsupremo@yahoo.com","avatar":null},"body":"\n--- Sean wrote:\n\n> On Tue, 29 Jan 2008 09:48:05 -0800 (PST)\n> Max Pollard wrote:\n> \n> > I only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it\n> > possible to have the above command keep going and show the history of\n> > a.txt?  Or at least somehow indicate that b.txt originated from a.txt?\n> \n> Hi Max,\n> \n> Not sure it will leave you feeling totally satisfied but the\n> following command will at least show you the copy which\n> occurred in that commit:\n> \n> $ git log --full-diff -C --find-copies-harder --stat -- b.txt\n> commit 578ecbc516e70ce7178545233192a08369a07101\n> Author: xyz <x@y.z>\n> Date:   Tue Jan 29 13:11:16 2008 -0500\n> \n>     Copy a.txt to b.txt\n> \n>  a.txt => b.txt |    0 \n>  1 files changed, 0 insertions(+), 0 deletions(-)\n> \n> If you had done a rename instead of a copy, then \"git log --follow b.txt\"\n> would have done what you're looking for, but there is no corresponding option\n> to follow copies.\n\nMany thanks for that Sean.  I saw all the options in the manual, but couldn't\nfigure out how to put them together.\n\nThis is exactly the information I wanted.  It appears to identify copies in\nboth text & binary files even if contents of b.txt are modified before commit\n(or at least modified in ways the copy-detection logic can identify copies).\n\n\nMP\n\n\n\n      ____________________________________________________________________________________\nBe a better friend, newshound, and \nknow-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ \n"},{"id":"66849","messageId":"7v63xco0w5.fsf@gitster.siamese.dyndns.org","threadId":"11784","inReplyTo":"333479.13589.qm@web45901.mail.sp1.yahoo.com","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-29T20:03:06Z","receivedAt":"2008-01-29T20:03:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Pollard <ajaxsupremo@yahoo.com> writes:\n\n> If I do the following:\n>\n>      $ git init\n>      $ echo \"The brown fox is getting old\" > a.txt\n>      $ git add a.txt\n>      $ git commit -m \"Commit a.txt\"\n>\n>      $ cp a.txt b.txt\n>      $ git add b.txt\n>      $ git commit -m \"Copy a.txt to b.txt\"\n>\n>      $ git log b.txt\n>\n> I only see the log corresponding to the 2nd commit (v1.5.3.5).\n\nThat is what you are asking \"git log\" to show.  \"git log b.txt\"\nmeans \"please simplify the history by throwing away commits that\ndo not have changes to paths that match b.txt, and then show the\nresulting log with the change pertaining to that path\".  The\nfirst commit does not change a path called b.txt (in other\nwords, \"git show --stat HEAD^\" will not give diffstat for \"b.txt\"),\nso that commit is not shown.\n\n$ git log --pretty=oneline --name-status -C -C\n"},{"id":"66853","messageId":"790332.92389.qm@web45907.mail.sp1.yahoo.com","threadId":"11784","inReplyTo":"7v63xco0w5.fsf@gitster.siamese.dyndns.org","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Max Pollard","fromEmail":"ajaxsupremo@yahoo.com","sentAt":"2008-01-29T21:07:50Z","receivedAt":"2008-01-29T21:07:50Z","isPatch":false,"sender":{"key":"ajaxsupremo@yahoo.com","avatar":null},"body":"\n--- Junio C Hamano wrote:\n\n> Max Pollard writes:\n> \n> > I only see the log corresponding to the 2nd commit (v1.5.3.5).\n> \n> That is what you are asking \"git log\" to show.  \"git log b.txt\"\n> means \"please simplify the history by throwing away commits that\n> do not have changes to paths that match b.txt, and then show the\n> resulting log with the change pertaining to that path\".  The\n> first commit does not change a path called b.txt (in other\n> words, \"git show --stat HEAD^\" will not give diffstat for \"b.txt\"),\n> so that commit is not shown.\n> \n> $ git log --pretty=oneline --name-status -C -C\n> \n\nGot it - many thanks.  So -C -C is the answer, with --name-status or --stat to\nactually show the result.  From the code, a status like Cxxx appears to contain\nthe \"similarity percentage\" in xxx; so that C100 would mean an exact copy...\n\n\nMP\n\n\n\n      ____________________________________________________________________________________\nBe a better friend, newshound, and \nknow-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ \n"},{"id":"66854","messageId":"7vr6g0mip2.fsf@gitster.siamese.dyndns.org","threadId":"11784","inReplyTo":"790332.92389.qm@web45907.mail.sp1.yahoo.com","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-29T21:21:29Z","receivedAt":"2008-01-29T21:21:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Pollard <ajaxsupremo@yahoo.com> writes:\n\n>> Max Pollard writes:\n>> \n>> > I only see the log corresponding to the 2nd commit (v1.5.3.5).\n>> \n>> That is what you are asking \"git log\" to show.  \"git log b.txt\"\n>> means \"please simplify the history by throwing away commits that\n>> do not have changes to paths that match b.txt, and then show the\n>> resulting log with the change pertaining to that path\".  The\n>> first commit does not change a path called b.txt (in other\n>> words, \"git show --stat HEAD^\" will not give diffstat for \"b.txt\"),\n>> so that commit is not shown.\n>> \n>> $ git log --pretty=oneline --name-status -C -C\n>> \n>\n> ...  So -C -C is the answer, with --name-status or --stat to\n> actually show the result.\n\nThe real \"answer\" part in that example is not -C -C.  Obviously,\nyou would need double-C aka --find-copies-harder, because you\ndid not change a.txt when creating b.txt, so it is still needed.\n\nBut the essential part of the answer is \"not giving b.txt as the\npathspec, so that whatever _other_ file that could have been\ncopied into it is still visible when the command works\".\n\nIf you say \"git log --name-status -C -C -- b.txt\", you would be\nback to square one.\n"},{"id":"66858","messageId":"743519.95328.qm@web45916.mail.sp1.yahoo.com","threadId":"11784","inReplyTo":"7vr6g0mip2.fsf@gitster.siamese.dyndns.org","subject":"Re: Can git log <file> follow log of its origins?","fromName":"Max Pollard","fromEmail":"ajaxsupremo@yahoo.com","sentAt":"2008-01-29T21:40:14Z","receivedAt":"2008-01-29T21:40:14Z","isPatch":false,"sender":{"key":"ajaxsupremo@yahoo.com","avatar":null},"body":"\n--- Junio C Hamano wrote:\n\n> Max Pollard writes:\n> \n> > ...  So -C -C is the answer, with --name-status or --stat to\n> > actually show the result.\n> \n> The real \"answer\" part in that example is not -C -C.  Obviously,\n> you would need double-C aka --find-copies-harder, because you\n> did not change a.txt when creating b.txt, so it is still needed.\n> \n> But the essential part of the answer is \"not giving b.txt as the\n> pathspec, so that whatever _other_ file that could have been\n> copied into it is still visible when the command works\".\n> \n> If you say \"git log --name-status -C -C -- b.txt\", you would be\n> back to square one.\n\nAha, point taken.  In this case, looks like I can do:\n\n    $ git log -C -C --full-diff --name-status/--stat/--summary -- b.txt\n\nas Sean has suggested to get the copy information back.  Or are you saying that\neven with \"--full-diff\" I can lose copy information in some cases?\n\n\nMP\n\n\n\n      ____________________________________________________________________________________\nLooking for last minute shopping deals?  \nFind them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping\n"}]}