From: Steven Grimm <koreth@midwinter.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: git@vger.kernel.org, angray@beeb.net
Subject: Re: renaming question
Date: Mon, 20 Aug 2007 08:45:21 +0800 [thread overview]
Message-ID: <46C8E421.8000408@midwinter.com> (raw)
In-Reply-To: <87mywn8dm0.fsf@mid.deneb.enyo.de>
Florian Weimer wrote:
> Or, for more control about what gets put into patch, git-diff -M.
> (As I wrote, most of the relevant commands accept an -M switch.)
>
The key point, and where the original writer is probably confused, is
that in git, renames are inferred from information in the repository.
You do not ever need to explicitly tell git about a rename. There is a
"git mv" command which is simply a convenience command; it is equivalent to
mv a b
git add b
git rm a
When you query history with the -M flag or do merges, git will notice
that the contents of the new file "b" are very similar to the old file
"a" and will treat it as a rename. (The contents don't have to match
exactly; they just have to be substantially similar.)
This is not a perfect system -- there are known cases where it fails --
but it has major advantages too. For example, you can unpack a
third-party tarfile into a git repository, commit it, then unpack the
next version's tarfile and commit that. Since you are using tar, nothing
will have told git about files that the upstream people renamed in
between versions, but git will detect them after the fact just as if
you'd done "git mv".
Not only that, git can detect movement of content *within* files. Try
moving some code from one file to another and running "git blame -M -C
-C" on the target file; you will see git tell you that the content
originally came from the first file. Pretty sweet. (It's not the default
since it makes "git blame" slower.)
-Steve
next prev parent reply other threads:[~2007-08-20 0:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-19 17:58 renaming question Aaron Gray
2007-08-19 18:16 ` Florian Weimer
2007-08-19 18:32 ` Aaron Gray
2007-08-19 19:05 ` David Kastrup
2007-08-19 19:17 ` Aaron Gray
2007-08-19 19:49 ` David Kastrup
2007-08-19 20:37 ` Florian Weimer
2007-08-20 0:45 ` Steven Grimm [this message]
2007-08-20 1:30 ` Aaron Gray
2007-08-20 1:56 ` Shawn O. Pearce
2007-08-20 2:11 ` VMiklos
2007-08-20 2:40 ` Aaron Gray
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=46C8E421.8000408@midwinter.com \
--to=koreth@midwinter.com \
--cc=angray@beeb.net \
--cc=fw@deneb.enyo.de \
--cc=git@vger.kernel.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).