From: Avery Pennarun <apenwarr@gmail.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: "Lasse Kärkkäinen" <tronic+dfhy@trn.iki.fi>, git@vger.kernel.org
Subject: Re: Proper tracking of copies in git log and others
Date: Tue, 7 Jul 2009 10:59:28 -0400 [thread overview]
Message-ID: <32541b130907070759j74831f2au19d90c2a5551e12d@mail.gmail.com> (raw)
In-Reply-To: <4A535244.60502@drmicha.warpmail.net>
On Tue, Jul 7, 2009 at 9:48 AM, Michael J
Gruber<git@drmicha.warpmail.net> wrote:
> While there is a pending patch as Sean pointed out it still has issues.
> For moves, "there is always only one", for copies there are at least
> two. So which one do you follow?
I think this is relatively easy, although the answer depends on
whether you're merging or logging.
Let's take the general case of n:m copies: n is the number of copies
in the second commit, and m is the number in the base commit. So 1:1
is a move, and 2:1 is a copy, and (>2):1 is a multiple copy, and eg.
3:2 is an unclear case where you had more than one identical (or
near-identical) file in the first place.
A) Merges: if it's anything other than 1:1, it's totally non-obvious
what to do, so I'll forgive git for doing pretty much anything. Bonus
points for triggering a conflict so that I have to look at it.
B) Logs:
- if m > 1, choose the base file that's closest to the new one; its
history should be pretty close to the right one, and arguably the new
file could have come from there anyway. If there's more than one file
of the same closeness, just pick one, because their histories are
interchangeable anyway.
- if n > 1, each file needs to have its base selected separately.
It's totally okay for multiple files to have the same base. If files
b, c, and d were all copied from a, I'd expect "git log --follow b c
d" to show the copying operation, and then the history of a.
Similarly for "git log --stat --follow b" for example.
All of this seems to work (at least well enough for me) with the 1:1
move case, and also for copies if you use "git log --stat -C -C" (not
restricting by filename). "git log --stat -C -C b" (restricting by
filename) doesn't work for copies, and --follow doesn't help (the
documentation for that options suggests it's only useful for moves).
Unfortunately this also causes problems with following "effective
move" operations: copy the file in one commit, and delete the original
in the next. I've been known to make this mistake, and it breaks 'git
log -C -C --follow filename', which is no fun.
Thanks,
Avery
prev parent reply other threads:[~2009-07-07 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-04 16:24 Proper tracking of copies in git log and others Lasse Kärkkäinen
2009-07-04 18:31 ` Sean Estabrooks
2009-07-14 12:19 ` Lasse Kärkkäinen
2009-07-07 6:53 ` Graeme Geldenhuys
2009-07-07 13:48 ` Michael J Gruber
2009-07-07 14:59 ` Avery Pennarun [this message]
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=32541b130907070759j74831f2au19d90c2a5551e12d@mail.gmail.com \
--to=apenwarr@gmail.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=tronic+dfhy@trn.iki.fi \
/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).