{"thread":{"id":"3335","subject":"git-svnimport issue with rename+change in the same commit","startedAt":"2006-02-14T17:12:33Z","lastAt":"2006-02-14T17:29:23Z","messageCount":2,"participants":["Eduardo Pereira Habkost","Manu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"16117","messageId":"20060214171233.GC4381@duckman.conectiva","threadId":"3335","inReplyTo":null,"subject":"git-svnimport issue with rename+change in the same commit","fromName":"Eduardo Pereira Habkost","fromEmail":"ehabkost@mandriva.com","sentAt":"2006-02-14T17:12:33Z","receivedAt":"2006-02-14T17:12:33Z","isPatch":false,"sender":{"key":"ehabkost@mandriva.com","avatar":null},"body":"Hi,\n\nI've just hit a problem when using git-svnimport to import a big\nsubversion repository: it doesn't import correctly a commit when the\ncommit renames (or copies) and modify a file at the same time.\n\nAt the bottom of this message, there is a script that reproduces the bug.\n\nThe result of the final 'diff' command on the script is:\n\ndiff -u --exclude .git --exclude .svn checkout/universe.py\ngit/universe.py\n--- checkout/universe.py        2006-02-14 14:55:37.000000000 -0200\n+++ git/universe.py     2006-02-14 14:55:38.000000000 -0200\n@@ -1 +1 @@\n-print \"Hello, universe!\"\n+print \"Hello, world!\"\n\ngit-svnadmin is just taking the original version of the file when\nthe commit has a 'file copy', even if this copy was modified before\nthe commit.\n\nHowever I can't see a way to fix this problem without making the script\nignore completely the the \"copied from\" information from the svn commits\n(and always fetching the resulting files from the repository). It seems\nthat subversion doesn't tell us if the copied file was changed (or this\ninformation is hidden somewhere else).\n\n-- \nEduardo\n\n\n#!/bin/sh\nset -e\n\nmkdir repos\nsvnadmin create $PWD/repos\nrepos=file://$PWD/repos\nsvn mkdir $repos/trunk -m 'creating trunk'\nsvn co file://$PWD/repos/trunk checkout\ncd checkout\ncat >hello.py <<EOF\nprint \"Hello, world!\"\nEOF\nsvn add hello.py\nsvn commit -m 'adding hello.py'\nsvn mv hello.py world.py\nsvn commit -m 'renaming to world.py'\nsvn mv world.py universe.py\nsed -i -e 's/world/universe/' universe.py\nsvn commit -m 'universe, now'\ncd ..\nmkdir git\ncd git\ngit svnimport $repos\ncd ..\ndiff -u --exclude .git --exclude .svn checkout git # will report differences\n"},{"id":"16118","messageId":"43F21373.8040400@blairos.org","threadId":"3335","inReplyTo":"20060214171233.GC4381@duckman.conectiva","subject":"Re: git-svnimport issue with rename+change in the same commit","fromName":"Manu","fromEmail":"manu@blairos.org","sentAt":"2006-02-14T17:29:23Z","receivedAt":"2006-02-14T17:29:23Z","isPatch":false,"sender":{"key":"manu@blairos.org","avatar":null},"body":"Hi,\nEduardo Pereira Habkost wrote:\n > Hi,\n >\n > I've just hit a problem when using git-svnimport to import a big\n > subversion repository: it doesn't import correctly a commit when the\n > commit renames (or copies) and modify a file at the same time.\n\nI came accross the same problem myself. Here is a patch that seemed to \ndo the trick for me.\nI tried your script, and it also seems to work.\nRegards,\n\nEmmanuel\n\n---\n\n[PATCH] git-svnimport: Correction when a \"copy_path\" has different \ncontents for src and dest.\n\nIn my SVN repository, there is a weird log:\n\n   A /trunk/mydir2 (from /trunk/mydir1:4)\n   R /trunk/mydir2/test.txt (from /trunk/mydir1/test.txt:4)\n\nAs a result, mydir2/test.txt is different than mydir1/test.txt, but\ngit-svnimport assumes that the content of mydir2/test.txt is the same\nas mydir1/test.txt.\n\nThis patch adds a test in copy_path, that makes sure that src and dest\nhave the same content. If not, it uses the content of dest.\n\n---\n\n git-svnimport.perl |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ne107ff9a06497a0003036ffafa45fa9dc050ecc4\ndiff --git a/git-svnimport.perl b/git-svnimport.perl\nindex f17d5a2..a2faa9a 100755\n--- a/git-svnimport.perl\n+++ b/git-svnimport.perl\n@@ -409,6 +409,12 @@ sub copy_path($$$$$$$$) {\n             $p = $path . substr($p,length($srcpath)-1);\n         } else {\n             $p = $path;\n+            # Deal with copy and modification\n+            my $f=get_file($newrev,$newbranch,$path);\n+            my ($tmode,$tsha1,$tp)=@$f;\n+            if ($tsha1 ne $sha1) {\n+                $sha1=$tsha1;\n+            }\n         }\n         push(@$new,[$mode,$sha1,$p]);   \n     }\n-- \n1.1.GIT\n"}]}