{"thread":{"id":"9575","subject":"renaming question","startedAt":"2007-08-19T17:58:20Z","lastAt":"2007-08-20T02:40:24Z","messageCount":12,"participants":["Aaron Gray","Florian Weimer","David Kastrup","Steven Grimm","Shawn O. Pearce","VMiklos"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51004","messageId":"03a701c7e28a$87914fc0$0600a8c0@ze4427wm","threadId":"9575","inReplyTo":null,"subject":"renaming question","fromName":"Aaron Gray","fromEmail":"angray@beeb.net","sentAt":"2007-08-19T17:58:20Z","receivedAt":"2007-08-19T17:58:20Z","isPatch":false,"sender":{"key":"angray@beeb.net","avatar":null},"body":"I have a very large C source project that I am converting from C to C++.\n\nIs it posssible to track changes with renamed files in GIT ?\n\nI really want to enter the C source into GIT then enter the C++ conversion \nand have GIT track changes.\n\nIs this possible and if so how do I do it ?\n\nMany thanks in advance,\n\nAaron\n"},{"id":"51005","messageId":"87vebbo0f1.fsf@mid.deneb.enyo.de","threadId":"9575","inReplyTo":"03a701c7e28a$87914fc0$0600a8c0@ze4427wm","subject":"Re: renaming question","fromName":"Florian Weimer","fromEmail":"fw@deneb.enyo.de","sentAt":"2007-08-19T18:16:02Z","receivedAt":"2007-08-19T18:16:02Z","isPatch":false,"sender":{"key":"fw@deneb.enyo.de","avatar":null},"body":"* Aaron Gray:\n\n> I have a very large C source project that I am converting from C to C++.\n>\n> Is it posssible to track changes with renamed files in GIT ?\n\nYou don't need to rename the files if you compile them using g++.  If\nyou still want to rename them, most history-related GIT commands\naccept an -M switch which enables rename (\"move\") detection.\n"},{"id":"51007","messageId":"03b401c7e28f$3c7304c0$0600a8c0@ze4427wm","threadId":"9575","inReplyTo":"87vebbo0f1.fsf@mid.deneb.enyo.de","subject":"Re: renaming question","fromName":"Aaron Gray","fromEmail":"angray@beeb.net","sentAt":"2007-08-19T18:32:01Z","receivedAt":"2007-08-19T18:32:01Z","isPatch":false,"sender":{"key":"angray@beeb.net","avatar":null},"body":">* Aaron Gray:\n>\n>> I have a very large C source project that I am converting from C to C++.\n>>\n>> Is it posssible to track changes with renamed files in GIT ?\n>\n> You don't need to rename the files if you compile them using g++.  If\n> you still want to rename them, most history-related GIT commands\n> accept an -M switch which enables rename (\"move\") detection.\n\nFor sanity they have to be renamed.\n\nI am a bit of a GIT newbie. With the -M switch what would be the proceedure \nwith a single file conversion such as with test.c and test.cpp ?\n\nWould the following do the trick ?\n\n    git add test.c\n    git commit\n\n    rename test.c test.cpp *\n    vi test.cpp\n\n    git rm test.c\n    git add test.cpp\n    git commit -M\n\nMany thanks in advance,\n\nAaron\n"},{"id":"51010","messageId":"85sl6fqr9n.fsf@lola.goethe.zz","threadId":"9575","inReplyTo":"03b401c7e28f$3c7304c0$0600a8c0@ze4427wm","subject":"Re: renaming question","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-19T19:05:24Z","receivedAt":"2007-08-19T19:05:24Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"\"Aaron Gray\" <angray@beeb.net> writes:\n\n>>* Aaron Gray:\n>>\n>>> I have a very large C source project that I am converting from C to C++.\n>>>\n>>> Is it posssible to track changes with renamed files in GIT ?\n>>\n>> You don't need to rename the files if you compile them using g++.  If\n>> you still want to rename them, most history-related GIT commands\n>> accept an -M switch which enables rename (\"move\") detection.\n>\n> For sanity they have to be renamed.\n>\n> I am a bit of a GIT newbie. With the -M switch what would be the\n> proceedure with a single file conversion such as with test.c and\n> test.cpp ?\n>\n> Would the following do the trick ?\n>\n>    git add test.c\n>    git commit\n>\n>    rename test.c test.cpp *\n>    vi test.cpp\n>\n>    git rm test.c\n>    git add test.cpp\n>    git commit -M\n>\n> Many thanks in advance,\n\nThere is no such thing as \"git commit -M\".  git does not keep track of\nrenames.  It generates the rename info on the fly when you ask it for\npatches, log stats, blame annotations or similar.\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"51011","messageId":"03bd01c7e295$976a2970$0600a8c0@ze4427wm","threadId":"9575","inReplyTo":"85sl6fqr9n.fsf@lola.goethe.zz","subject":"Re: renaming question","fromName":"Aaron Gray","fromEmail":"angray@beeb.net","sentAt":"2007-08-19T19:17:31Z","receivedAt":"2007-08-19T19:17:31Z","isPatch":false,"sender":{"key":"angray@beeb.net","avatar":null},"body":"> \"Aaron Gray\" <angray@beeb.net> writes:\n>\n>>>* Aaron Gray:\n>>>\n>>>> I have a very large C source project that I am converting from C to \n>>>> C++.\n>>>>\n>>>> Is it posssible to track changes with renamed files in GIT ?\n>>>\n>>> You don't need to rename the files if you compile them using g++.  If\n>>> you still want to rename them, most history-related GIT commands\n>>> accept an -M switch which enables rename (\"move\") detection.\n>>\n>> For sanity they have to be renamed.\n>>\n>> I am a bit of a GIT newbie. With the -M switch what would be the\n>> proceedure with a single file conversion such as with test.c and\n>> test.cpp ?\n>>\n>> Would the following do the trick ?\n>>\n>>    git add test.c\n>>    git commit\n>>\n>>    rename test.c test.cpp *\n>>    vi test.cpp\n>>\n>>    git rm test.c\n>>    git add test.cpp\n>>    git commit -M\n>>\n>> Many thanks in advance,\n>\n> There is no such thing as \"git commit -M\".  git does not keep track of\n> renames.  It generates the rename info on the fly when you ask it for\n> patches, log stats, blame annotations or similar.\n\nCould you elaborate maybe with a rough example for generating patches.\n\nAaron\n"},{"id":"51014","messageId":"85odh3qp8j.fsf@lola.goethe.zz","threadId":"9575","inReplyTo":"03bd01c7e295$976a2970$0600a8c0@ze4427wm","subject":"Re: renaming question","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-19T19:49:16Z","receivedAt":"2007-08-19T19:49:16Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"\"Aaron Gray\" <angray@beeb.net> writes:\n\n>> \"Aaron Gray\" <angray@beeb.net> writes:\n>>>\n>>> Would the following do the trick ?\n>>>\n>>>    git add test.c\n>>>    git commit\n>>>\n>>>    rename test.c test.cpp *\n>>>    vi test.cpp\n>>>\n>>>    git rm test.c\n>>>    git add test.cpp\n>>>    git commit -M\n>>>\n>>> Many thanks in advance,\n>>\n>> There is no such thing as \"git commit -M\".  git does not keep track\n>> of renames.  It generates the rename info on the fly when you ask\n>> it for patches, log stats, blame annotations or similar.\n>\n> Could you elaborate maybe with a rough example for generating\n> patches.\n\nUh, is that a trick question?\n\ngit-format-patch -M\n\n-- \nDavid Kastrup, Kriemhildstr. 15, 44793 Bochum\n"},{"id":"51016","messageId":"87mywn8dm0.fsf@mid.deneb.enyo.de","threadId":"9575","inReplyTo":"85odh3qp8j.fsf@lola.goethe.zz","subject":"Re: renaming question","fromName":"Florian Weimer","fromEmail":"fw@deneb.enyo.de","sentAt":"2007-08-19T20:37:43Z","receivedAt":"2007-08-19T20:37:43Z","isPatch":false,"sender":{"key":"fw@deneb.enyo.de","avatar":null},"body":"* David Kastrup:\n\n>> Could you elaborate maybe with a rough example for generating\n>> patches.\n\n> git-format-patch -M\n\nOr, for more control about what gets put into patch, git-diff -M.\n(As I wrote, most of the relevant commands accept an -M switch.)\n"},{"id":"51031","messageId":"46C8E421.8000408@midwinter.com","threadId":"9575","inReplyTo":"87mywn8dm0.fsf@mid.deneb.enyo.de","subject":"Re: renaming question","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-08-20T00:45:21Z","receivedAt":"2007-08-20T00:45:21Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Florian Weimer wrote:\n> Or, for more control about what gets put into patch, git-diff -M.\n> (As I wrote, most of the relevant commands accept an -M switch.)\n>   \n\nThe key point, and where the original writer is probably confused, is \nthat in git, renames are inferred from information in the repository. \nYou do not ever need to explicitly tell git about a rename. There is a \n\"git mv\" command which is simply a convenience command; it is equivalent to\n\nmv a b\ngit add b\ngit rm a\n\nWhen you query history with the -M flag or do merges, git will notice \nthat the contents of the new file \"b\" are very similar to the old file \n\"a\" and will treat it as a rename. (The contents don't have to match \nexactly; they just have to be substantially similar.)\n\nThis is not a perfect system -- there are known cases where it fails -- \nbut it has major advantages too. For example, you can unpack a \nthird-party tarfile into a git repository, commit it, then unpack the \nnext version's tarfile and commit that. Since you are using tar, nothing \nwill have told git about files that the upstream people renamed in \nbetween versions, but git will detect them after the fact just as if \nyou'd done \"git mv\".\n\nNot only that, git can detect movement of content *within* files. Try \nmoving some code from one file to another and running \"git blame -M -C \n-C\" on the target file; you will see git tell you that the content \noriginally came from the first file. Pretty sweet. (It's not the default \nsince it makes \"git blame\" slower.)\n\n-Steve\n"},{"id":"51034","messageId":"045a01c7e2c9$c1ccd940$0600a8c0@ze4427wm","threadId":"9575","inReplyTo":"46C8E421.8000408@midwinter.com","subject":"Re: renaming question","fromName":"Aaron Gray","fromEmail":"angray@beeb.net","sentAt":"2007-08-20T01:30:54Z","receivedAt":"2007-08-20T01:30:54Z","isPatch":false,"sender":{"key":"angray@beeb.net","avatar":null},"body":"> Florian Weimer wrote:\n>> Or, for more control about what gets put into patch, git-diff -M.\n>> (As I wrote, most of the relevant commands accept an -M switch.)\n>>\n>\n> The key point, and where the original writer is probably confused, is that \n> in git, renames are inferred from information in the repository.\n\nOkay.\n\n> You do not ever need to explicitly tell git about a rename. There is a \n> \"git mv\" command which is simply a convenience command; it is equivalent \n> to\n>\n> mv a b\n> git add b\n> git rm a\n\nThat makes things alot clearer, thanks.\n\n> When you query history with the -M flag or do merges, git will notice that \n> the contents of the new file \"b\" are very similar to the old file \"a\" and \n> will treat it as a rename. (The contents don't have to match exactly; they \n> just have to be substantially similar.)\n>\n> This is not a perfect system -- there are known cases where it fails -- \n> but it has major advantages too. For example, you can unpack a third-party \n> tarfile into a git repository, commit it, then unpack the next version's \n> tarfile and commit that. Since you are using tar, nothing will have told \n> git about files that the upstream people renamed in between versions, but \n> git will detect them after the fact just as if you'd done \"git mv\".\n\nThats great, exactly what I want to do.\n\n> Not only that, git can detect movement of content *within* files. Try \n> moving some code from one file to another and running \"git blame -M -C -C\" \n> on the target file; you will see git tell you that the content originally \n> came from the first file. Pretty sweet. (It's not the default since it \n> makes \"git blame\" slower.)\n\nOkay. The documentation, or what I have read does not really explain this \nproperly or concisely.\n\nThanks alot Steve.\n\nAaron\n"},{"id":"51035","messageId":"20070820015621.GX27913@spearce.org","threadId":"9575","inReplyTo":"46C8E421.8000408@midwinter.com","subject":"Re: renaming question","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-08-20T01:56:21Z","receivedAt":"2007-08-20T01:56:21Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Steven Grimm <koreth@midwinter.com> wrote:\n> Not only that, git can detect movement of content *within* files. Try \n> moving some code from one file to another and running \"git blame -M -C \n> -C\" on the target file; you will see git tell you that the content \n> originally came from the first file. Pretty sweet. (It's not the default \n> since it makes \"git blame\" slower.)\n\nAnd if you have a GUI available, try `git gui blame $file`.  It runs\ngit-blame twice to show you not only where the content originally\ncame from, but also who put it where it is now.  Still needs more\npolish, but its quite useful as it is.\n\n-- \nShawn.\n"},{"id":"51036","messageId":"20070820021109.GB768@genesis.frugalware.org","threadId":"9575","inReplyTo":"03b401c7e28f$3c7304c0$0600a8c0@ze4427wm","subject":"Re: renaming question","fromName":"VMiklos","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-08-20T02:11:09Z","receivedAt":"2007-08-20T02:11:09Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Hello,\n\nNa Sun, Aug 19, 2007 at 07:32:01PM +0100, Aaron Gray <angray@beeb.net> pisal(a):\n>    rename test.c test.cpp *\n>    vi test.cpp\n\n>    git rm test.c\n>    git add test.cpp\n\nor just git mv test.c test.cpp\n\n- VMiklos\n"},{"id":"51039","messageId":"04a501c7e2d3$75c26740$0600a8c0@ze4427wm","threadId":"9575","inReplyTo":"20070820021109.GB768@genesis.frugalware.org","subject":"Re: renaming question","fromName":"Aaron Gray","fromEmail":"angray@beeb.net","sentAt":"2007-08-20T02:40:24Z","receivedAt":"2007-08-20T02:40:24Z","isPatch":false,"sender":{"key":"angray@beeb.net","avatar":null},"body":"Hello,\n\n>Na Sun, Aug 19, 2007 at 07:32:01PM +0100, Aaron Gray <angray@beeb.net> \n>pisal(a):\n>>    rename test.c test.cpp *\n>>    vi test.cpp\n\n>>    git rm test.c\n>>    git add test.cpp\n\n>or just git mv test.c test.cpp\n\nYes I gathered that.\n\nfollowed by 'vi test.cpp' :)\n\nGIT's looking great, cannot wait to really start using it.\n\nAaron\n"}]}