* renaming question
@ 2007-08-19 17:58 Aaron Gray
2007-08-19 18:16 ` Florian Weimer
0 siblings, 1 reply; 12+ messages in thread
From: Aaron Gray @ 2007-08-19 17:58 UTC (permalink / raw)
To: Git Mailing List
I have a very large C source project that I am converting from C to C++.
Is it posssible to track changes with renamed files in GIT ?
I really want to enter the C source into GIT then enter the C++ conversion
and have GIT track changes.
Is this possible and if so how do I do it ?
Many thanks in advance,
Aaron
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 17:58 renaming question Aaron Gray
@ 2007-08-19 18:16 ` Florian Weimer
2007-08-19 18:32 ` Aaron Gray
0 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2007-08-19 18:16 UTC (permalink / raw)
To: git
* Aaron Gray:
> I have a very large C source project that I am converting from C to C++.
>
> Is it posssible to track changes with renamed files in GIT ?
You don't need to rename the files if you compile them using g++. If
you still want to rename them, most history-related GIT commands
accept an -M switch which enables rename ("move") detection.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 18:16 ` Florian Weimer
@ 2007-08-19 18:32 ` Aaron Gray
2007-08-19 19:05 ` David Kastrup
2007-08-20 2:11 ` VMiklos
0 siblings, 2 replies; 12+ messages in thread
From: Aaron Gray @ 2007-08-19 18:32 UTC (permalink / raw)
To: git
>* Aaron Gray:
>
>> I have a very large C source project that I am converting from C to C++.
>>
>> Is it posssible to track changes with renamed files in GIT ?
>
> You don't need to rename the files if you compile them using g++. If
> you still want to rename them, most history-related GIT commands
> accept an -M switch which enables rename ("move") detection.
For sanity they have to be renamed.
I am a bit of a GIT newbie. With the -M switch what would be the proceedure
with a single file conversion such as with test.c and test.cpp ?
Would the following do the trick ?
git add test.c
git commit
rename test.c test.cpp *
vi test.cpp
git rm test.c
git add test.cpp
git commit -M
Many thanks in advance,
Aaron
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 18:32 ` Aaron Gray
@ 2007-08-19 19:05 ` David Kastrup
2007-08-19 19:17 ` Aaron Gray
2007-08-20 2:11 ` VMiklos
1 sibling, 1 reply; 12+ messages in thread
From: David Kastrup @ 2007-08-19 19:05 UTC (permalink / raw)
To: Aaron Gray; +Cc: git
"Aaron Gray" <angray@beeb.net> writes:
>>* Aaron Gray:
>>
>>> I have a very large C source project that I am converting from C to C++.
>>>
>>> Is it posssible to track changes with renamed files in GIT ?
>>
>> You don't need to rename the files if you compile them using g++. If
>> you still want to rename them, most history-related GIT commands
>> accept an -M switch which enables rename ("move") detection.
>
> For sanity they have to be renamed.
>
> I am a bit of a GIT newbie. With the -M switch what would be the
> proceedure with a single file conversion such as with test.c and
> test.cpp ?
>
> Would the following do the trick ?
>
> git add test.c
> git commit
>
> rename test.c test.cpp *
> vi test.cpp
>
> git rm test.c
> git add test.cpp
> git commit -M
>
> Many thanks in advance,
There is no such thing as "git commit -M". git does not keep track of
renames. It generates the rename info on the fly when you ask it for
patches, log stats, blame annotations or similar.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 19:05 ` David Kastrup
@ 2007-08-19 19:17 ` Aaron Gray
2007-08-19 19:49 ` David Kastrup
0 siblings, 1 reply; 12+ messages in thread
From: Aaron Gray @ 2007-08-19 19:17 UTC (permalink / raw)
To: git
> "Aaron Gray" <angray@beeb.net> writes:
>
>>>* Aaron Gray:
>>>
>>>> I have a very large C source project that I am converting from C to
>>>> C++.
>>>>
>>>> Is it posssible to track changes with renamed files in GIT ?
>>>
>>> You don't need to rename the files if you compile them using g++. If
>>> you still want to rename them, most history-related GIT commands
>>> accept an -M switch which enables rename ("move") detection.
>>
>> For sanity they have to be renamed.
>>
>> I am a bit of a GIT newbie. With the -M switch what would be the
>> proceedure with a single file conversion such as with test.c and
>> test.cpp ?
>>
>> Would the following do the trick ?
>>
>> git add test.c
>> git commit
>>
>> rename test.c test.cpp *
>> vi test.cpp
>>
>> git rm test.c
>> git add test.cpp
>> git commit -M
>>
>> Many thanks in advance,
>
> There is no such thing as "git commit -M". git does not keep track of
> renames. It generates the rename info on the fly when you ask it for
> patches, log stats, blame annotations or similar.
Could you elaborate maybe with a rough example for generating patches.
Aaron
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 19:17 ` Aaron Gray
@ 2007-08-19 19:49 ` David Kastrup
2007-08-19 20:37 ` Florian Weimer
0 siblings, 1 reply; 12+ messages in thread
From: David Kastrup @ 2007-08-19 19:49 UTC (permalink / raw)
To: Aaron Gray; +Cc: git
"Aaron Gray" <angray@beeb.net> writes:
>> "Aaron Gray" <angray@beeb.net> writes:
>>>
>>> Would the following do the trick ?
>>>
>>> git add test.c
>>> git commit
>>>
>>> rename test.c test.cpp *
>>> vi test.cpp
>>>
>>> git rm test.c
>>> git add test.cpp
>>> git commit -M
>>>
>>> Many thanks in advance,
>>
>> There is no such thing as "git commit -M". git does not keep track
>> of renames. It generates the rename info on the fly when you ask
>> it for patches, log stats, blame annotations or similar.
>
> Could you elaborate maybe with a rough example for generating
> patches.
Uh, is that a trick question?
git-format-patch -M
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 19:49 ` David Kastrup
@ 2007-08-19 20:37 ` Florian Weimer
2007-08-20 0:45 ` Steven Grimm
0 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2007-08-19 20:37 UTC (permalink / raw)
To: git
* David Kastrup:
>> Could you elaborate maybe with a rough example for generating
>> patches.
> git-format-patch -M
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.)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 20:37 ` Florian Weimer
@ 2007-08-20 0:45 ` Steven Grimm
2007-08-20 1:30 ` Aaron Gray
2007-08-20 1:56 ` Shawn O. Pearce
0 siblings, 2 replies; 12+ messages in thread
From: Steven Grimm @ 2007-08-20 0:45 UTC (permalink / raw)
To: Florian Weimer; +Cc: git, angray
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-20 0:45 ` Steven Grimm
@ 2007-08-20 1:30 ` Aaron Gray
2007-08-20 1:56 ` Shawn O. Pearce
1 sibling, 0 replies; 12+ messages in thread
From: Aaron Gray @ 2007-08-20 1:30 UTC (permalink / raw)
To: Steven Grimm; +Cc: git
> 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.
Okay.
> 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
That makes things alot clearer, thanks.
> 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".
Thats great, exactly what I want to do.
> 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.)
Okay. The documentation, or what I have read does not really explain this
properly or concisely.
Thanks alot Steve.
Aaron
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-20 0:45 ` Steven Grimm
2007-08-20 1:30 ` Aaron Gray
@ 2007-08-20 1:56 ` Shawn O. Pearce
1 sibling, 0 replies; 12+ messages in thread
From: Shawn O. Pearce @ 2007-08-20 1:56 UTC (permalink / raw)
To: Steven Grimm; +Cc: Florian Weimer, git, angray
Steven Grimm <koreth@midwinter.com> wrote:
> 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.)
And if you have a GUI available, try `git gui blame $file`. It runs
git-blame twice to show you not only where the content originally
came from, but also who put it where it is now. Still needs more
polish, but its quite useful as it is.
--
Shawn.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-19 18:32 ` Aaron Gray
2007-08-19 19:05 ` David Kastrup
@ 2007-08-20 2:11 ` VMiklos
2007-08-20 2:40 ` Aaron Gray
1 sibling, 1 reply; 12+ messages in thread
From: VMiklos @ 2007-08-20 2:11 UTC (permalink / raw)
To: Aaron Gray; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 221 bytes --]
Hello,
Na Sun, Aug 19, 2007 at 07:32:01PM +0100, Aaron Gray <angray@beeb.net> pisal(a):
> rename test.c test.cpp *
> vi test.cpp
> git rm test.c
> git add test.cpp
or just git mv test.c test.cpp
- VMiklos
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: renaming question
2007-08-20 2:11 ` VMiklos
@ 2007-08-20 2:40 ` Aaron Gray
0 siblings, 0 replies; 12+ messages in thread
From: Aaron Gray @ 2007-08-20 2:40 UTC (permalink / raw)
To: VMiklos; +Cc: git
Hello,
>Na Sun, Aug 19, 2007 at 07:32:01PM +0100, Aaron Gray <angray@beeb.net>
>pisal(a):
>> rename test.c test.cpp *
>> vi test.cpp
>> git rm test.c
>> git add test.cpp
>or just git mv test.c test.cpp
Yes I gathered that.
followed by 'vi test.cpp' :)
GIT's looking great, cannot wait to really start using it.
Aaron
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2007-08-20 2:40 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).