{"thread":{"id":"3382","subject":"[PATCH] git-svn: remove files from the index before adding/updating","startedAt":"2006-02-18T05:04:47Z","lastAt":"2006-02-18T12:36:52Z","messageCount":3,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"16357","messageId":"11402390872301-git-send-email-normalperson@yhbt.net","threadId":"3382","inReplyTo":null,"subject":"[PATCH] git-svn: remove files from the index before adding/updating","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-02-18T05:04:47Z","receivedAt":"2006-02-18T05:04:47Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This fixes a bug when importing where a directory gets removed/renamed\nbut is immediately replaced by a file of the same name in the same\nrevision.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn |   11 +++++------\n 1 files changed, 5 insertions(+), 6 deletions(-)\n\nc142c70866ab8ce1765e4b88506aa79b5c5c1427\ndiff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn\nindex 2caf057..71a8b3b 100755\n--- a/contrib/git-svn/git-svn\n+++ b/contrib/git-svn/git-svn\n@@ -580,13 +580,12 @@ sub svn_info {\n sub sys { system(@_) == 0 or croak $? }\n \n sub git_addremove {\n-\tsystem(\t\"git-ls-files -z --others \".\n+\tsystem( \"git-diff-files --name-only -z \".\n+\t\t\t\t\" | git-update-index --remove -z --stdin; \".\n+\t\t\"git-ls-files -z --others \".\n \t\t\t\"'--exclude-from=$GIT_DIR/$GIT_SVN/info/exclude'\".\n-\t\t\t\t\"| git-update-index --add -z --stdin; \".\n-\t\t\"git-ls-files -z --deleted \".\n-\t\t\t\t\"| git-update-index --remove -z --stdin; \".\n-\t\t\"git-ls-files -z --modified\".\n-\t\t\t\t\"| git-update-index -z --stdin\") == 0 or croak $?\n+\t\t\t\t\" | git-update-index --add -z --stdin; \"\n+\t\t) == 0 or croak $?\n }\n \n sub s_to_file {\n-- \n1.2.0.g4d1a-dirty\n"},{"id":"16380","messageId":"20060218114628.GA24678@BL4ST","threadId":"3382","inReplyTo":"11402390872301-git-send-email-normalperson@yhbt.net","subject":"[PATCH] archimport: remove files from the index before adding/updating","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-02-18T11:49:38Z","receivedAt":"2006-02-18T11:49:38Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This fixes a bug when importing where a directory gets removed/renamed\nbut is immediately replaced by a file of the same name in the same\nchangeset.\n\nThis fix only applies to the accurate (default) strategy the moment.\n\nThis patch should also fix the fast strategy if/when it is updated\nto handle the cases that would've triggered this bug.\n\nThis bug was originally found in git-svn, but I remembered I did the\nsame thing with archimport as well.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-archimport.perl |   28 +++++++++++++---------------\n 1 files changed, 13 insertions(+), 15 deletions(-)\n\n011fe464212c52d46ad5b797eb1d8f86c1d77916\ndiff --git a/git-archimport.perl b/git-archimport.perl\nindex 841738d..6792624 100755\n--- a/git-archimport.perl\n+++ b/git-archimport.perl\n@@ -346,12 +346,10 @@ sub process_patchset_accurate {\n     } \n     \n     # update the index with all the changes we got\n+    system('git-diff-files --name-only -z | '.\n+            'git-update-index --remove -z --stdin') == 0 or die \"$! $?\\n\";\n     system('git-ls-files --others -z | '.\n             'git-update-index --add -z --stdin') == 0 or die \"$! $?\\n\";\n-    system('git-ls-files --deleted -z | '.\n-            'git-update-index --remove -z --stdin') == 0 or die \"$! $?\\n\";\n-    system('git-ls-files -z | '.\n-             'git-update-index -z --stdin') == 0 or die \"$! $?\\n\";\n     return 1;\n }\n \n@@ -416,22 +414,14 @@ sub process_patchset_fast {\n     # imports don't give us good info\n     # on added files. Shame on them\n     if ($ps->{type} eq 'i' || $ps->{type} eq 't') {\n-        system('git-ls-files --others -z | '.\n-                'git-update-index --add -z --stdin') == 0 or die \"$! $?\\n\";\n         system('git-ls-files --deleted -z | '.\n                 'git-update-index --remove -z --stdin') == 0 or die \"$! $?\\n\";\n+        system('git-ls-files --others -z | '.\n+                'git-update-index --add -z --stdin') == 0 or die \"$! $?\\n\";\n     }\n \n     # TODO: handle removed_directories and renamed_directories:\n-   \n-    if (my $add = $ps->{new_files}) {\n-        while (@$add) {\n-            my @slice = splice(@$add, 0, 100);\n-            system('git-update-index','--add','--',@slice) == 0 or\n-                            die \"Error in git-update-index --add: $! $?\\n\";\n-        }\n-    }\n-   \n+\n     if (my $del = $ps->{removed_files}) {\n         unlink @$del;\n         while (@$del) {\n@@ -462,6 +452,14 @@ sub process_patchset_fast {\n         }\n     }\n \n+    if (my $add = $ps->{new_files}) {\n+        while (@$add) {\n+            my @slice = splice(@$add, 0, 100);\n+            system('git-update-index','--add','--',@slice) == 0 or\n+                            die \"Error in git-update-index --add: $! $?\\n\";\n+        }\n+    }\n+\n     if (my $mod = $ps->{modified_files}) {\n         while (@$mod) {\n             my @slice = splice(@$mod, 0, 100);\n-- \n1.2.1.gffaf\n"},{"id":"16382","messageId":"20060218123652.GB12296@hand.yhbt.net","threadId":"3382","inReplyTo":"20060218114628.GA24678@BL4ST","subject":"Re: [PATCH] archimport: remove files from the index before adding/updating","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-02-18T12:36:52Z","receivedAt":"2006-02-18T12:36:52Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Oops, forgot to Cc Martin on this :>\n\n-- \nEric Wong\n"}]}