git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Eli Barzilay <eli@barzilay.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	Eugene Sajine <euguess@gmail.com>,
	Bo Yang <struggleyb.nku@gmail.com>,
	Jacob Helwig <jacob.helwig@gmail.com>,
	git@vger.kernel.org
Subject: Re: Re: git log -M -- filename is not working?
Date: Fri, 14 May 2010 00:55:22 -0400	[thread overview]
Message-ID: <20100514045522.GE6075@coredump.intra.peff.net> (raw)
In-Reply-To: <19434.48308.815673.263230@winooski.ccs.neu.edu>

On Wed, May 12, 2010 at 10:35:32AM -0400, Eli Barzilay wrote:

> But with `-p' it was doing something confusing: I used two files that
> were recently renamed, and the result was the correct log history, but
> the first patch that was shown (the rename) showed the two files as
> added.  (That's even when I added `-C' and `-M'.)  This happens even
> with a single path.  OTOH, using `--follow' with `-p' and a single
> path without your patch produces the expected result where the first
> patch is a rename (even without `-C'/`-M').

Ah, yeah, I see. The problem is that my code is doing something like:

  1. Do a sha1-only diff with our current path list.

  2. If there were any created files, they might be renames.
     Put aside the old diff results. Do a new diff, looking for renames.

  3. If there are renames, add them to our path list.

  4. Restore the old diff results.

  5. Proceed with other desired diff options (rename detection, showing
     patches, etc).

But the during step (5), remember that we are still working with the old
diff results, which will not include the expanded path. Thus we won't
consider the new path as a rename source, and will fail to find the
rename.

The naive right way would be to re-do step (1) with the expanded path.
But there is an optimization, since we can use the diff results from (2)
directly, including avoiding re-doing the rename detection.

The only "downside" is that it means --follow actually impacts the diff
generation by implying --find-copies-harder. And I put downside in
quotes because it is probably not a big deal. We have already spent the
CPU time to find the answer, so it is silly not to show it. I can't
imagine why somebody would want --follow, but would _not_ want rename
detection in the resulting diff.

Bo's version of the patch does that optimization. When I clean up the
patch (probably sometime next week), I'll take those changes.

-Peff

  parent reply	other threads:[~2010-05-14  4:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07 18:07 git log -M -- filename is not working? Eugene Sajine
2010-05-07 18:10 ` Jacob Helwig
2010-05-07 18:31   ` Eugene Sajine
2010-05-07 18:37     ` Eli Barzilay
2010-05-07 20:25       ` Matthieu Moy
2010-05-07 20:28       ` Jakub Narebski
2010-05-08  4:44       ` Jeff King
2010-05-08  5:12         ` Eli Barzilay
2010-05-08  5:30           ` Jeff King
2010-05-08  5:39           ` Junio C Hamano
2010-05-08  7:08             ` Eli Barzilay
2010-05-12 11:38               ` Jeff King
2010-05-12 12:01                 ` Eli Barzilay
2010-05-12 12:49                   ` Jeff King
2010-05-12 13:03                     ` Jeff King
2010-05-12 14:35                     ` Eli Barzilay
2010-05-12 16:07                       ` Bo Yang
2010-05-12 16:45                         ` Jeff King
2010-05-13  2:12                           ` Bo Yang
2010-05-13  4:39                             ` Eli Barzilay
2010-05-14  4:55                       ` Jeff King [this message]
2010-05-14  5:05                         ` Eli Barzilay
2010-05-12 13:06                   ` Bo Yang
2010-05-12 13:09                     ` Jeff King
2010-05-12 14:42                     ` Eli Barzilay
2010-05-12 14:49                       ` Bo Yang

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=20100514045522.GE6075@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=eli@barzilay.org \
    --cc=euguess@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.helwig@gmail.com \
    --cc=struggleyb.nku@gmail.com \
    /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).