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 15:53:21 -0700 [thread overview]
Message-ID: <7vabq5wkri.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.0.999.0710251119120.30120@woody.linux-foundation.org> (Linus Torvalds's message of "Thu, 25 Oct 2007 11:20:56 -0700 (PDT)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> @@ -2640,27 +2640,21 @@ static void diff_resolve_rename_copy(void)
> * either in-place edit or rename/copy edit.
> */
> else if (DIFF_PAIR_RENAME(p)) {
> + /*
> + * A rename might have re-connected a broken
> + * pair up, causing the pathnames to be the
> + * same again. If so, that's not a rename at
> + * all, just a modification..
> + *
> + * Otherwise, see if this source was used for
> + * multiple renames, in which case we decrement
> + * the count, and call it a copy.
> */
> + if (!strcmp(p->one->path, p->two->path))
> + p->status = DIFF_STATUS_MODIFIED;
> + else if (--p->one->rename_used > 0)
> p->status = DIFF_STATUS_COPIED;
> + else
> p->status = DIFF_STATUS_RENAMED;
> }
> else if (hashcmp(p->one->sha1, p->two->sha1) ||
The interaction between the above and ...
> @@ -338,15 +320,25 @@ void diffcore_rename(struct diff_options *options)
> locate_rename_dst(p->two, 1);
> }
> else if (!DIFF_FILE_VALID(p->two)) {
> + /*
> + * If the source is a broken "delete", and
> * they did not really want to get broken,
> * that means the source actually stays.
> + * So we increment the "rename_used" score
> + * by one, to indicate ourselves as a user
> + */
> + if (p->broken_pair && !p->score)
> + p->one->rename_used++;
> + register_rename_src(p->one, p->score);
> + }
> + else if (detect_rename == DIFF_DETECT_COPY) {
> + /*
> + * Increment the "rename_used" score by
> + * one, to indicate ourselves as a user.
> */
> + p->one->rename_used++;
> + register_rename_src(p->one, p->score);
> }
> }
> if (rename_dst_nr == 0 || rename_src_nr == 0)
> goto cleanup; /* nothing to do */
... this part feels a bit too subtle for a still-jet-lagged
brain to grok. I wonder what happens if the preimage of a
broken pair is used as the rename source for more than two
postimages.
next prev parent reply other threads:[~2007-10-26 22:53 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 [this message]
2007-10-26 23:10 ` Linus Torvalds
2007-10-26 23:27 ` Junio C Hamano
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=7vabq5wkri.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.