git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 4/6] copy vs rename detection: avoid unnecessary O(n*m) loops
Date: Fri, 26 Oct 2007 16:27:43 -0700	[thread overview]
Message-ID: <7vy7dpv4ls.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.0.999.0710261600510.30120@woody.linux-foundation.org> (Linus Torvalds's message of "Fri, 26 Oct 2007 16:10:09 -0700 (PDT)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> The nice thing about the whole counting thing is that we really don't even 
> care. What happens is:
>
>  - *if* any rename at all happens, the rename detection will increment the 
>    "rename_used" thing even more for the source (once for each rename)
>
>  - so if the rename_used started out non-zero, it will never become zero 
>    in diff_resolve_rename_copy(), and every single detected "rename" will 
>    be considered a copy - exactly like we want.
>
>  - in other words, a "rename_used++" before rename-detection guarantees 
>    that you never see a rename, only a copy of the source.

Ok, and that is because we _know_ a broken pair means that the
path itself remains in the postimage and any other postimage
that takes from its preimage can never "rename the path away".
They can only be copies.  Which makes sense.

> The above is actually true *even*if* the 
>
> 	if (!strcmp(p->one->path, p->two->path))
>
> code in diff_resolve_rename_copy() actually triggers,...
> ..., so not doing 
> the decrement there is equivalent to doing another pre-increment.

Yes, this is what confused me.  So for a broken pair, the actual
value of rename_used does not really matter.  We only care about
it not going down to zero.

  reply	other threads:[~2007-10-26 23:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LFD.0.999.0710251112120.30120@woody.linux-foundation.or g>
2007-10-25 18:15 ` [PATCH 0/6] Cleaned-up rename detection patch-series Linus Torvalds
2007-10-25 18:16   ` [PATCH 1/6] Add 'diffcore.h' to LIB_H Linus Torvalds
2007-10-25 18:17   ` [PATCH 2/6] Split out "exact content match" phase of rename detection Linus Torvalds
2007-10-25 18:19   ` [PATCH 3/6] Ref-count the filespecs used by diffcore Linus Torvalds
2007-10-25 18:20   ` [PATCH 4/6] copy vs rename detection: avoid unnecessary O(n*m) loops Linus Torvalds
2007-10-26 22:53     ` Junio C Hamano
2007-10-26 23:10       ` Linus Torvalds
2007-10-26 23:27         ` Junio C Hamano [this message]
2007-10-26 23:36           ` Linus Torvalds
2007-10-25 18:23   ` [PATCH 5/6] Do linear-time/space rename logic for exact renames Linus Torvalds
2007-10-25 19:43     ` Daniel Barkalow
2007-10-25 19:48       ` Jeff King
2007-10-25 20:23         ` Daniel Barkalow
2007-10-25 20:25       ` Linus Torvalds
2007-10-25 21:37         ` Daniel Barkalow
2007-10-25 18:24   ` [PATCH 6/6] Do exact rename detection regardless of rename limits Linus Torvalds
2007-10-25 18:37   ` [PATCH 0/6] Cleaned-up rename detection patch-series Linus Torvalds
2007-10-25 19:08   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vy7dpv4ls.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).