{"thread":{"id":"15853","subject":"git confused by rename","startedAt":"2008-10-10T14:41:54Z","lastAt":"2008-10-10T22:08:39Z","messageCount":6,"participants":["Michael P. Soulier","Junio C Hamano","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92756","messageId":"fb6605670810100741k7cff25c7y4df66834cf7482a0@mail.gmail.com","threadId":"15853","inReplyTo":null,"subject":"git confused by rename","fromName":"Michael P. Soulier","fromEmail":"msoulier@digitaltorque.ca","sentAt":"2008-10-10T14:41:54Z","receivedAt":"2008-10-10T14:41:54Z","isPatch":false,"sender":{"key":"msoulier@digitaltorque.ca","avatar":"https://gravatar.com/avatar/f32ca317cc5c1787a51e1f2388f33303ce743b458fd67669c3d14a21fd5dabc7?d=mp&s=160"},"body":"# On branch ajax-callrecording\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       modified:   js/urls.py\n#       modified:   js/views.py\n#       modified:   scrc/urls.py\n#       modified:   scrc/views.py\n#       new file:   templates/js/scrc.js\n#       modified:   templates/js/teleworker.js\n#       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html\n#       modified:   templates/scrc/index.html\n\nLooking at the last two lines here, there is obviously an issue.\n\nI created a new cres_taps.html file, and modified the index.html file, and for\nsome reason Git thinks that I renamed index.html.\n\nLooks like a bug, unless I'm missing something.\n\nMike\n-- \nMichael P. Soulier <msoulier@digitaltorque.ca>\n\"Any intelligent fool can make things bigger and more complex... It takes a\ntouch of genius - and a lot of courage to move in the opposite direction.\"\n--Albert Einstein\n"},{"id":"92761","messageId":"7vabdcmp4n.fsf@gitster.siamese.dyndns.org","threadId":"15853","inReplyTo":"fb6605670810100741k7cff25c7y4df66834cf7482a0@mail.gmail.com","subject":"Re: git confused by rename","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-10T15:44:08Z","receivedAt":"2008-10-10T15:44:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael P. Soulier\" <msoulier@digitaltorque.ca> writes:\n\n> #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html\n> #       modified:   templates/scrc/index.html\n>\n> Looking at the last two lines here, there is obviously an issue.\n\nI am puzzled.\n\nLooking at wt-status.c \"renamed: A -> B\" will be shown only when A and B\nare similar enough *and* there is no A remaining in the final result, and\nin such a case, \"modified: A\" should not be shown.  Because git does not\ncare how you created B (IOW, it does not matter if B was typed from\nscratch with copying and pasting, or created by copying and editing), the\n\"renamed: A -> B\" entry itself is not surprising nor look like a bug at\nall, but its presense at the same time as \"modified: A\" does feel very\nfishy.\n"},{"id":"92763","messageId":"7v3aj4momt.fsf@gitster.siamese.dyndns.org","threadId":"15853","inReplyTo":"7vabdcmp4n.fsf@gitster.siamese.dyndns.org","subject":"Re: git confused by rename","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-10T15:54:50Z","receivedAt":"2008-10-10T15:54:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"Michael P. Soulier\" <msoulier@digitaltorque.ca> writes:\n>\n>> #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html\n>> #       modified:   templates/scrc/index.html\n>>\n>> Looking at the last two lines here, there is obviously an issue.\n>\n> I am puzzled.\n\nNot anymore.\n\n> Looking at wt-status.c \"renamed: A -> B\" will be shown only when A and B\n> are similar enough *and* there is no A remaining in the final result, and\n> in such a case, \"modified: A\" should not be shown.\n\nExcept for one case.\n\n> Because git does not\n> care how you created B (IOW, it does not matter if B was typed from\n> scratch with copying and pasting, or created by copying and editing), the\n> \"renamed: A -> B\" entry itself is not surprising nor look like a bug at\n> all,...\n\nThe above observation of mine is correct, but I forgot that \"git status\"\n(and the comment in the commit template from \"git commit\") is generated\ninternally with \"diff-index -B -M\".  So if\n\n (0) had A but not B in the HEAD commit;\n (1) you created B that is very similar to the original A; and\n (2) you modified A beyond recognition;\n\nthen git will say \"A was modified and B was created by renaming A\".\n\n> ... but its presense at the same time as \"modified: A\" does feel very\n> fishy.\n\nSo this is not fishy anymore.\n\nThis however makes me wonder if \"diff-index -B -M\" should say B is copied\n(instead of being renamed) from A and A is modified in such a case.  I do\nnot think we would want to make such a change without thinking things,\nthrough.\n"},{"id":"92764","messageId":"20081010160804.GA24515@atjola.homenet","threadId":"15853","inReplyTo":"7vabdcmp4n.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] git-status: Detect copies as well as renames","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-10-10T16:08:04Z","receivedAt":"2008-10-10T16:08:04Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>\n---\nOn 2008.10.10 08:44:08 -0700, Junio C Hamano wrote:\n> \"Michael P. Soulier\" <msoulier@digitaltorque.ca> writes:\n> \n> > #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html\n> > #       modified:   templates/scrc/index.html\n> >\n> > Looking at the last two lines here, there is obviously an issue.\n> \n> I am puzzled.\n> \n> Looking at wt-status.c \"renamed: A -> B\" will be shown only when A and\n> B are similar enough *and* there is no A remaining in the final\n> result, and in such a case, \"modified: A\" should not be shown.\n> Because git does not care how you created B (IOW, it does not matter\n> if B was typed from scratch with copying and pasting, or created by\n> copying and editing), the \"renamed: A -> B\" entry itself is not\n> surprising nor look like a bug at all, but its presense at the same\n> time as \"modified: A\" does feel very fishy.\n\nMaybe something like this is required? The \"1\" meant that only renames\nwere to be detected, so I'm quite puzzled why it detects copies in some\ncases at all. At least some trivial:\n\ncp Makefile Makefile2\necho 123 >> Makefile\ngit add Makefile*\n\nNow correctly shows the Makefile2 being a copy of Makefile, while the\nold behaviour was to simply show it as a new file. _BUT_ when you also\ndid:\n\ngit mv Makefile Makefile3\n\nYou see a rename of Makefile and a copy of Makefile. Even though we\ndidn't request copy detection... Hu?\n\nI feel like stabbing in the dark though, so I intentionally left out a\ndescription in the commit message that tells why this change is good. I\nsimply have no idea, it just _felt_ better. ;-)\n\nBjörn\n\n wt-status.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 889e50f..3d645b9 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -210,7 +210,7 @@ static void wt_status_print_updated(struct wt_status *s)\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_print_updated_cb;\n \trev.diffopt.format_callback_data = s;\n-\trev.diffopt.detect_rename = 1;\n+\trev.diffopt.detect_rename = DIFF_DETECT_COPY;\n \trev.diffopt.rename_limit = 200;\n \trev.diffopt.break_opt = 0;\n \trun_diff_index(&rev, 1);\n@@ -310,7 +310,7 @@ static void wt_status_print_verbose(struct wt_status *s)\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, s->reference);\n \trev.diffopt.output_format |= DIFF_FORMAT_PATCH;\n-\trev.diffopt.detect_rename = 1;\n+\trev.diffopt.detect_rename = DIFF_DETECT_COPY;\n \trev.diffopt.file = s->fp;\n \trev.diffopt.close_file = 0;\n \trun_diff_index(&rev, 1);\n-- \n1.6.0.2.307.gc427.dirty\n"},{"id":"92766","messageId":"20081010161922.GH3671@atjola.homenet","threadId":"15853","inReplyTo":"7v3aj4momt.fsf@gitster.siamese.dyndns.org","subject":"Re: git confused by rename","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-10-10T16:19:22Z","receivedAt":"2008-10-10T16:19:22Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.10.10 08:54:50 -0700, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> > Because git does not care how you created B (IOW, it does not matter\n> > if B was typed from scratch with copying and pasting, or created by\n> > copying and editing), the \"renamed: A -> B\" entry itself is not\n> > surprising nor look like a bug at all,...\n> \n> The above observation of mine is correct, but I forgot that \"git status\"\n> (and the comment in the commit template from \"git commit\") is generated\n> internally with \"diff-index -B -M\".  So if\n> \n>  (0) had A but not B in the HEAD commit;\n>  (1) you created B that is very similar to the original A; and\n>  (2) you modified A beyond recognition;\n> \n> then git will say \"A was modified and B was created by renaming A\".\n> \n> > ... but its presense at the same time as \"modified: A\" does feel very\n> > fishy.\n> \n> So this is not fishy anymore.\n> \n> This however makes me wonder if \"diff-index -B -M\" should say B is copied\n> (instead of being renamed) from A and A is modified in such a case.  I do\n> not think we would want to make such a change without thinking things,\n> through.\n\nOh, heh, my patch doesn't help in that case. It's still modify + rename\nwith it, of course, as -B still breaks the stuff apart. Me being\nconfused about -M reporting copies in some cases remains though, I had\nreally expected that only -C would detect copies. Of course, this\nconfusion is purely from a user's point of view, I have zero knowledge\nabout the involved code...\n\nBjörn\n"},{"id":"92774","messageId":"20081010220839.GA38499@kanga.digitaltorque.ca","threadId":"15853","inReplyTo":"7v3aj4momt.fsf@gitster.siamese.dyndns.org","subject":"Re: git confused by rename","fromName":"Michael P. Soulier","fromEmail":"msoulier@digitaltorque.ca","sentAt":"2008-10-10T22:08:39Z","receivedAt":"2008-10-10T22:08:39Z","isPatch":false,"sender":{"key":"msoulier@digitaltorque.ca","avatar":"https://gravatar.com/avatar/f32ca317cc5c1787a51e1f2388f33303ce743b458fd67669c3d14a21fd5dabc7?d=mp&s=160"},"body":"On 10/10/08 Junio C Hamano said:\n> The above observation of mine is correct, but I forgot that \"git status\"\n> (and the comment in the commit template from \"git commit\") is generated\n> internally with \"diff-index -B -M\".  So if\n> \n>  (0) had A but not B in the HEAD commit;\n>  (1) you created B that is very similar to the original A; and\n>  (2) you modified A beyond recognition;\n\nWhich, FTR, is what I did. \n\nI copied A -> B for its boilerplate, and then hacked them both up, although B\nconsisted mostly of content that I removed from A (a refactoring exercise).\n\n> This however makes me wonder if \"diff-index -B -M\" should say B is copied\n> (instead of being renamed) from A and A is modified in such a case.  I do\n> not think we would want to make such a change without thinking things,\n> through.\n\nGotcha. Indeed though, I did cp A -> B, and if A still exists then it\nobviously was not renamed.\n\nThanks,\nMike\n-- \nMichael P. Soulier <msoulier@digitaltorque.ca>\n\"Any intelligent fool can make things bigger and more complex... It\ntakes a touch of genius - and a lot of courage to move in the opposite\ndirection.\" --Albert Einstein\n"}]}