{"thread":{"id":"46557","subject":"Not understanding with git wants to copy one file to another","startedAt":"2017-08-10T17:03:43Z","lastAt":"2017-08-14T19:21:47Z","messageCount":7,"participants":["Harry Putnam","Stefan Beller","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"326033","messageId":"87mv7773tp.fsf@local.lan","threadId":"46557","inReplyTo":null,"subject":"Not understanding with git wants to copy one file to another","fromName":"Harry Putnam","fromEmail":"reader@newsguy.com","sentAt":"2017-08-10T17:03:30Z","receivedAt":"2017-08-10T17:03:43Z","isPatch":false,"sender":{"key":"reader@newsguy.com","avatar":null},"body":"I ran into a line in git commit ouput I had not see before\n\n  #copied:     d0/etc/hosts -> misc/old-readerHOSTvcs-files/etc/hosts\n\nSo googling I learned that this might happen if git thinks the two\nfiles are the same.\n\nI was pretty sure they were not the same so checked them>\n\n <inside git repo>\n\ndiff d0/etc/host misc/old-readerHOSTvcs-files/etc/hosts\n\nThe output is a bit long but shows them being quite different.\n\nSome 2 dozen or so lines that dramatically differ.\n\nHere are two that are at least kind of similar but would never be seen\nas the same:\n\n< 192.168.1.43      m2.local.lan       m2       # 00-90-F5-A1-F9-E5\n> 192.168.1.43    m2.local.lan        m2         # win 7\n\nNot to mention they are quite different lines as well.\n\nSo what is going on and what should I be looking at?\n\n"},{"id":"326040","messageId":"CAGZ79kbgb2P7KT_b9xuMj1pN1+jsPfH7YSJNDyDB5dY3cwXCQg@mail.gmail.com","threadId":"46557","inReplyTo":"87mv7773tp.fsf@local.lan","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-08-10T17:36:44Z","receivedAt":"2017-08-10T17:36:51Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Aug 10, 2017 at 10:03 AM, Harry Putnam <reader@newsguy.com> wrote:\n> I ran into a line in git commit ouput I had not see before\n>\n>   #copied:     d0/etc/hosts -> misc/old-readerHOSTvcs-files/etc/hosts\n>\n> So googling I learned that this might happen if git thinks the two\n> files are the same.\n>\n> I was pretty sure they were not the same so checked them>\n>\n>  <inside git repo>\n>\n> diff d0/etc/host misc/old-readerHOSTvcs-files/etc/hosts\n>\n> The output is a bit long but shows them being quite different.\n>\n> Some 2 dozen or so lines that dramatically differ.\n>\n> Here are two that are at least kind of similar but would never be seen\n> as the same:\n>\n> < 192.168.1.43      m2.local.lan       m2       # 00-90-F5-A1-F9-E5\n>> 192.168.1.43    m2.local.lan        m2         # win 7\n>\n> Not to mention they are quite different lines as well.\n>\n> So what is going on and what should I be looking at?\n\nThe diff machinery has a threshold for when it assumes\na copy/move of a file. (e.g. \"A file is assumed copied when\nat least 55% of lines are equal\")\n\nhttps://git-scm.com/docs/git-diff\n\nSee -C and -M option.\n\ngit-status seems to use this machinery as well, but does\nnot expose the options?\n"},{"id":"326051","messageId":"87efsj70d7.fsf@local.lan","threadId":"46557","inReplyTo":"CAGZ79kbgb2P7KT_b9xuMj1pN1+jsPfH7YSJNDyDB5dY3cwXCQg@mail.gmail.com","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Harry Putnam","fromEmail":"reader@newsguy.com","sentAt":"2017-08-10T18:18:12Z","receivedAt":"2017-08-10T18:18:45Z","isPatch":false,"sender":{"key":"reader@newsguy.com","avatar":null},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Thu, Aug 10, 2017 at 10:03 AM, Harry Putnam <reader@newsguy.com> wrote:\n\n[...]\n\nHarry wrote:\n>> Here are two that are at least kind of similar but would never be seen\n>> as the same:\n>>\n>> < 192.168.1.43      m2.local.lan       m2       # 00-90-F5-A1-F9-E5\n>>> 192.168.1.43    m2.local.lan        m2         # win 7\n\n Stefan B replied:\n> The diff machinery has a threshold for when it assumes\n> a copy/move of a file. (e.g. \"A file is assumed copied when\n> at least 55% of lines are equal\")\n>\n> https://git-scm.com/docs/git-diff\n>\n> See -C and -M option.\n>\n> git-status seems to use this machinery as well, but does\n> not expose the options?\n\nWell, now I'm even more confused.  What actually happens? Is either\nfile changed? Is only one file kept?\n\nOn the surface it sounds like complete anathema to what git is all\nabout.\n\nHowever, I know a tool this sophisticated is not doing something just\noutright stupid... so must be really missing the point here.\n\nI get the way you can make -M stricter or not... but I didn't call\ngit-diff to see that copy thing comeup.\n\nI called git commit.\n\nThere must be some way to set stricter guidlines to calling things\ncopies.\n\nBut then I must really not get it because it still seems almost silly\nto consider one file a copy of another if only 55% is the same.\n\nWhat am I missing?\n\n\n\n"},{"id":"326063","messageId":"CAGZ79kZN1-DuiaS=bFgNUXBonAR3BHqtAFSqoJ+MJ4esMdmz-g@mail.gmail.com","threadId":"46557","inReplyTo":"87efsj70d7.fsf@local.lan","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-08-10T18:47:57Z","receivedAt":"2017-08-10T18:48:04Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Aug 10, 2017 at 11:18 AM, Harry Putnam <reader@newsguy.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> On Thu, Aug 10, 2017 at 10:03 AM, Harry Putnam <reader@newsguy.com> wrote:\n>\n> [...]\n>\n> Harry wrote:\n>>> Here are two that are at least kind of similar but would never be seen\n>>> as the same:\n>>>\n>>> < 192.168.1.43      m2.local.lan       m2       # 00-90-F5-A1-F9-E5\n>>>> 192.168.1.43    m2.local.lan        m2         # win 7\n>\n>  Stefan B replied:\n>> The diff machinery has a threshold for when it assumes\n>> a copy/move of a file. (e.g. \"A file is assumed copied when\n>> at least 55% of lines are equal\")\n>>\n>> https://git-scm.com/docs/git-diff\n>>\n>> See -C and -M option.\n>>\n>> git-status seems to use this machinery as well, but does\n>> not expose the options?\n>\n> Well, now I'm even more confused.  What actually happens? Is either\n> file changed? Is only one file kept?\n>\n> On the surface it sounds like complete anathema to what git is all\n> about.\n>\n> However, I know a tool this sophisticated is not doing something just\n> outright stupid... so must be really missing the point here.\n>\n> I get the way you can make -M stricter or not... but I didn't call\n> git-diff to see that copy thing comeup.\n>\n> I called git commit.\n\nAh. Sorry for confusing even more.\nBy pointing out the options for git-diff, I just wanted to point out that\nsuch a mechanism (\"rename/copy detection\") exists.\n\nThe output of git-status is similar to a dry run of git-commit,\nand apparently this detection is used there.\n\n>\n> There must be some way to set stricter guidlines to calling things\n> copies.\n\nWell from Gits perspective it is really hard to tell if it was a copy, or\nif it was similar incidentally (because the format/content of these files\nhappen to follow some strict guidelines).\n\nThe user could have moved/copied a file outside of Git (instead of\ngit-mv, you'd use tools provided by your operating system to copy a\nfile). Or the user could have written a file that is similar by chance.\n\nHowever that doesn't really matter, as Git tracks the content, and not\nhow the file evolved.\n\nConsider the copy/move/rename detection as a heuristic, that wants\nto help the user, but may be mistaken.\n\n>\n> But then I must really not get it because it still seems almost silly\n> to consider one file a copy of another if only 55% is the same.\n>\n> What am I missing?\n>\n\nhttps://www.reddit.com/r/git/comments/3ogkk1/beginner_disable_rename_detection/\n\n\"Rename detection is just GUI sugar\".\n"},{"id":"326168","messageId":"87shgx3khv.fsf@local.lan","threadId":"46557","inReplyTo":"CAGZ79kZN1-DuiaS=bFgNUXBonAR3BHqtAFSqoJ+MJ4esMdmz-g@mail.gmail.com","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Harry Putnam","fromEmail":"reader@newsguy.com","sentAt":"2017-08-11T20:41:32Z","receivedAt":"2017-08-11T20:41:48Z","isPatch":false,"sender":{"key":"reader@newsguy.com","avatar":null},"body":"Stefan Beller <sbeller@google.com> writes:\n\n\n[...]\n\n> Ah. Sorry for confusing even more.\n> By pointing out the options for git-diff, I just wanted to point out that\n> such a mechanism (\"rename/copy detection\") exists.\n\n\n[...]\n\n>> What am I missing?\n>>\n>\n> https://www.reddit.com/r/git/comments/3ogkk1/beginner_disable_rename_detection/\n>\n> \"Rename detection is just GUI sugar\".\n\nThanks there is a nice full explanation at the cited url.\n\nWhat is still a bit puzzling is that in that same commit, there are\nfiles that are true copies of each other, just in different locations,\nBut nothing pops up about them in a git commit.\n\n\n"},{"id":"326291","messageId":"CAGZ79kaCuaxgGwuw7AHKTjsmwsTBuv=gWzeGDJv3TJv+b25Uvw@mail.gmail.com","threadId":"46557","inReplyTo":"87shgx3khv.fsf@local.lan","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-08-14T18:07:29Z","receivedAt":"2017-08-14T18:07:35Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Aug 11, 2017 at 1:41 PM, Harry Putnam <reader@newsguy.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>\n> [...]\n>\n>> Ah. Sorry for confusing even more.\n>> By pointing out the options for git-diff, I just wanted to point out that\n>> such a mechanism (\"rename/copy detection\") exists.\n>\n>\n> [...]\n>\n>>> What am I missing?\n>>>\n>>\n>> https://www.reddit.com/r/git/comments/3ogkk1/beginner_disable_rename_detection/\n>>\n>> \"Rename detection is just GUI sugar\".\n>\n> Thanks there is a nice full explanation at the cited url.\n>\n> What is still a bit puzzling is that in that same commit, there are\n> files that are true copies of each other, just in different locations,\n> But nothing pops up about them in a git commit.\n>\n\nThe heuristic to find the renames/copies only looks at modified files\nto be fast(, the assumption is that each commit only touches few\nfiles, but the project consists of a lot of files).\n\nFor that git-diff knows about '--find-copies-harder' that looks at\nall files even those not modified. This would point out the true\ncopies, I would assume.\n\nI don't think we'd want to include the '--find-copies-harder' flag\nto status or commit, as it may take some time in large projects.\n"},{"id":"326298","messageId":"xmqqfucuuf9e.fsf@gitster.mtv.corp.google.com","threadId":"46557","inReplyTo":"CAGZ79kaCuaxgGwuw7AHKTjsmwsTBuv=gWzeGDJv3TJv+b25Uvw@mail.gmail.com","subject":"Re: Not understanding with git wants to copy one file to another","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-14T19:21:33Z","receivedAt":"2017-08-14T19:21:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Fri, Aug 11, 2017 at 1:41 PM, Harry Putnam <reader@newsguy.com> wrote:\n>> Stefan Beller <sbeller@google.com> writes:\n>>\n>>\n>> [...]\n>>\n>>> Ah. Sorry for confusing even more.\n>>> By pointing out the options for git-diff, I just wanted to point out that\n>>> such a mechanism (\"rename/copy detection\") exists.\n>>\n>>\n>> [...]\n>>\n>>>> What am I missing?\n>>>>\n>>>\n>>> https://www.reddit.com/r/git/comments/3ogkk1/beginner_disable_rename_detection/\n>>>\n>>> \"Rename detection is just GUI sugar\".\n>>\n>> Thanks there is a nice full explanation at the cited url.\n>>\n>> What is still a bit puzzling is that in that same commit, there are\n>> files that are true copies of each other, just in different locations,\n>> But nothing pops up about them in a git commit.\n>>\n>\n> The heuristic to find the renames/copies only looks at modified files\n> to be fast(, the assumption is that each commit only touches few\n> files, but the project consists of a lot of files).\n>\n> For that git-diff knows about '--find-copies-harder' that looks at\n> all files even those not modified. This would point out the true\n> copies, I would assume.\n>\n> I don't think we'd want to include the '--find-copies-harder' flag\n> to status or commit, as it may take some time in large projects.\n\nYeah, thanks for helping in this discussion.\n\n"}]}