Git development
 help / color / mirror / Atom feed
* git confused by rename
@ 2008-10-10 14:41 Michael P. Soulier
  2008-10-10 15:44 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Michael P. Soulier @ 2008-10-10 14:41 UTC (permalink / raw)
  To: git

# On branch ajax-callrecording
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   js/urls.py
#       modified:   js/views.py
#       modified:   scrc/urls.py
#       modified:   scrc/views.py
#       new file:   templates/js/scrc.js
#       modified:   templates/js/teleworker.js
#       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html
#       modified:   templates/scrc/index.html

Looking at the last two lines here, there is obviously an issue.

I created a new cres_taps.html file, and modified the index.html file, and for
some reason Git thinks that I renamed index.html.

Looks like a bug, unless I'm missing something.

Mike
-- 
Michael P. Soulier <msoulier@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git confused by rename
  2008-10-10 14:41 git confused by rename Michael P. Soulier
@ 2008-10-10 15:44 ` Junio C Hamano
  2008-10-10 15:54   ` Junio C Hamano
  2008-10-10 16:08   ` [PATCH] git-status: Detect copies as well as renames Björn Steinbrink
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2008-10-10 15:44 UTC (permalink / raw)
  To: Michael P. Soulier; +Cc: git

"Michael P. Soulier" <msoulier@digitaltorque.ca> writes:

> #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html
> #       modified:   templates/scrc/index.html
>
> Looking at the last two lines here, there is obviously an issue.

I am puzzled.

Looking at wt-status.c "renamed: A -> B" will be shown only when A and B
are similar enough *and* there is no A remaining in the final result, and
in such a case, "modified: A" should not be shown.  Because git does not
care how you created B (IOW, it does not matter if B was typed from
scratch with copying and pasting, or created by copying and editing), the
"renamed: A -> B" entry itself is not surprising nor look like a bug at
all, but its presense at the same time as "modified: A" does feel very
fishy.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git confused by rename
  2008-10-10 15:44 ` Junio C Hamano
@ 2008-10-10 15:54   ` Junio C Hamano
  2008-10-10 16:19     ` Björn Steinbrink
  2008-10-10 22:08     ` Michael P. Soulier
  2008-10-10 16:08   ` [PATCH] git-status: Detect copies as well as renames Björn Steinbrink
  1 sibling, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2008-10-10 15:54 UTC (permalink / raw)
  To: Michael P. Soulier; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

> "Michael P. Soulier" <msoulier@digitaltorque.ca> writes:
>
>> #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html
>> #       modified:   templates/scrc/index.html
>>
>> Looking at the last two lines here, there is obviously an issue.
>
> I am puzzled.

Not anymore.

> Looking at wt-status.c "renamed: A -> B" will be shown only when A and B
> are similar enough *and* there is no A remaining in the final result, and
> in such a case, "modified: A" should not be shown.

Except for one case.

> Because git does not
> care how you created B (IOW, it does not matter if B was typed from
> scratch with copying and pasting, or created by copying and editing), the
> "renamed: A -> B" entry itself is not surprising nor look like a bug at
> all,...

The above observation of mine is correct, but I forgot that "git status"
(and the comment in the commit template from "git commit") is generated
internally with "diff-index -B -M".  So if

 (0) had A but not B in the HEAD commit;
 (1) you created B that is very similar to the original A; and
 (2) you modified A beyond recognition;

then git will say "A was modified and B was created by renaming A".

> ... but its presense at the same time as "modified: A" does feel very
> fishy.

So this is not fishy anymore.

This however makes me wonder if "diff-index -B -M" should say B is copied
(instead of being renamed) from A and A is modified in such a case.  I do
not think we would want to make such a change without thinking things,
through.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] git-status: Detect copies as well as renames
  2008-10-10 15:44 ` Junio C Hamano
  2008-10-10 15:54   ` Junio C Hamano
@ 2008-10-10 16:08   ` Björn Steinbrink
  1 sibling, 0 replies; 6+ messages in thread
From: Björn Steinbrink @ 2008-10-10 16:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael P. Soulier, git

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
On 2008.10.10 08:44:08 -0700, Junio C Hamano wrote:
> "Michael P. Soulier" <msoulier@digitaltorque.ca> writes:
> 
> > #       renamed:    templates/scrc/index.html -> templates/scrc/cres_taps.html
> > #       modified:   templates/scrc/index.html
> >
> > Looking at the last two lines here, there is obviously an issue.
> 
> I am puzzled.
> 
> Looking at wt-status.c "renamed: A -> B" will be shown only when A and
> B are similar enough *and* there is no A remaining in the final
> result, and in such a case, "modified: A" should not be shown.
> Because git does not care how you created B (IOW, it does not matter
> if B was typed from scratch with copying and pasting, or created by
> copying and editing), the "renamed: A -> B" entry itself is not
> surprising nor look like a bug at all, but its presense at the same
> time as "modified: A" does feel very fishy.

Maybe something like this is required? The "1" meant that only renames
were to be detected, so I'm quite puzzled why it detects copies in some
cases at all. At least some trivial:

cp Makefile Makefile2
echo 123 >> Makefile
git add Makefile*

Now correctly shows the Makefile2 being a copy of Makefile, while the
old behaviour was to simply show it as a new file. _BUT_ when you also
did:

git mv Makefile Makefile3

You see a rename of Makefile and a copy of Makefile. Even though we
didn't request copy detection... Hu?

I feel like stabbing in the dark though, so I intentionally left out a
description in the commit message that tells why this change is good. I
simply have no idea, it just _felt_ better. ;-)

Björn

 wt-status.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 889e50f..3d645b9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -210,7 +210,7 @@ static void wt_status_print_updated(struct wt_status *s)
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_print_updated_cb;
 	rev.diffopt.format_callback_data = s;
-	rev.diffopt.detect_rename = 1;
+	rev.diffopt.detect_rename = DIFF_DETECT_COPY;
 	rev.diffopt.rename_limit = 200;
 	rev.diffopt.break_opt = 0;
 	run_diff_index(&rev, 1);
@@ -310,7 +310,7 @@ static void wt_status_print_verbose(struct wt_status *s)
 	init_revisions(&rev, NULL);
 	setup_revisions(0, NULL, &rev, s->reference);
 	rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
-	rev.diffopt.detect_rename = 1;
+	rev.diffopt.detect_rename = DIFF_DETECT_COPY;
 	rev.diffopt.file = s->fp;
 	rev.diffopt.close_file = 0;
 	run_diff_index(&rev, 1);
-- 
1.6.0.2.307.gc427.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: git confused by rename
  2008-10-10 15:54   ` Junio C Hamano
@ 2008-10-10 16:19     ` Björn Steinbrink
  2008-10-10 22:08     ` Michael P. Soulier
  1 sibling, 0 replies; 6+ messages in thread
From: Björn Steinbrink @ 2008-10-10 16:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael P. Soulier, git

On 2008.10.10 08:54:50 -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> > Because git does not care how you created B (IOW, it does not matter
> > if B was typed from scratch with copying and pasting, or created by
> > copying and editing), the "renamed: A -> B" entry itself is not
> > surprising nor look like a bug at all,...
> 
> The above observation of mine is correct, but I forgot that "git status"
> (and the comment in the commit template from "git commit") is generated
> internally with "diff-index -B -M".  So if
> 
>  (0) had A but not B in the HEAD commit;
>  (1) you created B that is very similar to the original A; and
>  (2) you modified A beyond recognition;
> 
> then git will say "A was modified and B was created by renaming A".
> 
> > ... but its presense at the same time as "modified: A" does feel very
> > fishy.
> 
> So this is not fishy anymore.
> 
> This however makes me wonder if "diff-index -B -M" should say B is copied
> (instead of being renamed) from A and A is modified in such a case.  I do
> not think we would want to make such a change without thinking things,
> through.

Oh, heh, my patch doesn't help in that case. It's still modify + rename
with it, of course, as -B still breaks the stuff apart. Me being
confused about -M reporting copies in some cases remains though, I had
really expected that only -C would detect copies. Of course, this
confusion is purely from a user's point of view, I have zero knowledge
about the involved code...

Björn

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git confused by rename
  2008-10-10 15:54   ` Junio C Hamano
  2008-10-10 16:19     ` Björn Steinbrink
@ 2008-10-10 22:08     ` Michael P. Soulier
  1 sibling, 0 replies; 6+ messages in thread
From: Michael P. Soulier @ 2008-10-10 22:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On 10/10/08 Junio C Hamano said:
> The above observation of mine is correct, but I forgot that "git status"
> (and the comment in the commit template from "git commit") is generated
> internally with "diff-index -B -M".  So if
> 
>  (0) had A but not B in the HEAD commit;
>  (1) you created B that is very similar to the original A; and
>  (2) you modified A beyond recognition;

Which, FTR, is what I did. 

I copied A -> B for its boilerplate, and then hacked them both up, although B
consisted mostly of content that I removed from A (a refactoring exercise).

> This however makes me wonder if "diff-index -B -M" should say B is copied
> (instead of being renamed) from A and A is modified in such a case.  I do
> not think we would want to make such a change without thinking things,
> through.

Gotcha. Indeed though, I did cp A -> B, and if A still exists then it
obviously was not renamed.

Thanks,
Mike
-- 
Michael P. Soulier <msoulier@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein

[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-10-10 22:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 14:41 git confused by rename Michael P. Soulier
2008-10-10 15:44 ` Junio C Hamano
2008-10-10 15:54   ` Junio C Hamano
2008-10-10 16:19     ` Björn Steinbrink
2008-10-10 22:08     ` Michael P. Soulier
2008-10-10 16:08   ` [PATCH] git-status: Detect copies as well as renames Björn Steinbrink

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox