{"thread":{"id":"2688","subject":"[PATCH] git-mv: shrink usage, no usage on error","startedAt":"2005-11-27T20:58:52Z","lastAt":"2005-11-27T20:58:52Z","messageCount":1,"participants":["Josef Weidendorfer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"12810","messageId":"200511272158.53234.Josef.Weidendorfer@gmx.de","threadId":"2688","inReplyTo":null,"subject":"[PATCH] git-mv: shrink usage, no usage on error","fromName":"Josef Weidendorfer","fromEmail":"josef.weidendorfer@gmx.de","sentAt":"2005-11-27T20:58:52Z","receivedAt":"2005-11-27T20:58:52Z","isPatch":true,"sender":{"key":"josef.weidendorfer@gmx.de","avatar":null},"body":"Small fixes to be consistent with other git scripts:\n- usage message is only about options and arguments\n- on error, exit(1) without the usage message\n\nAdditionally, \"beautifies\" output with -n a little bit\n\nSigned-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>\n\n---\nThis conflicts with Johannes's (and Junio's corrected)\n [PATCH] Make git-mv work in subdirectories, too\nso this should be changed accordingly.\nOtherwise, I can acknowlegde that your correction to this\npatch (make git-mv work in subdirs) works for me.\nWhat is the correct way to \"Ack\" a patch?\n\nJosef\n\n git-mv.perl |   46 +++++++++++++++++++---------------------------\n 1 files changed, 19 insertions(+), 27 deletions(-)\n\napplies-to: 1dc0816b6c98ef90985d2761f1ab80739e4fbc7d\n58d858a354c10c3be0b9eae68cabdce8a3d87f27\ndiff --git a/git-mv.perl b/git-mv.perl\nindex b2eace5..990bec5 100755\n--- a/git-mv.perl\n+++ b/git-mv.perl\n@@ -13,22 +13,8 @@ use Getopt::Std;\n \n sub usage() {\n \tprint <<EOT;\n-$0 [-f] [-n] <source> <dest>\n-$0 [-f] [-k] [-n] <source> ... <dest directory>\n-\n-In the first form, source must exist and be either a file,\n-symlink or directory, dest must not exist. It renames source to dest.\n-In the second form, the last argument has to be an existing\n-directory; the given sources will be moved into this directory.\n-\n-Updates the git cache to reflect the change.\n-Use \"git commit\" to make the change permanently.\n-\n-Options:\n-  -f   Force renaming/moving, even if target exists\n-  -k   Continue on error by skipping\n-       not-existing or not revision-controlled source\n-  -n   Do nothing; show what would happen\n+$0 [-f] [-n] <source> <destination>\n+$0 [-f] [-n] [-k] <source> ... <destination directory>\n EOT\n \texit(1);\n }\n@@ -38,8 +24,8 @@ my $GIT_DIR = $ENV{'GIT_DIR'} || \".git\";\n \n unless ( -d $GIT_DIR && -d $GIT_DIR . \"/objects\" && \n \t-d $GIT_DIR . \"/objects/\" && -d $GIT_DIR . \"/refs\") {\n-    print \"Git repository not found.\";\n-    usage();\n+    print \"Error: git repository not found.\";\n+    exit(1);\n }\n \n \n@@ -70,7 +56,7 @@ else {\n \tprint \"Error: moving to directory '\"\n \t    . $ARGV[$argCount-1]\n \t    . \"' not possible; not exisiting\\n\";\n-\tusage;\n+\texit(1);\n     }\n     @srcArgs = ($ARGV[0]);\n     @dstArgs = ($ARGV[1]);\n@@ -148,7 +134,7 @@ while(scalar @srcArgs > 0) {\n \t    next;\n \t}\n \tprint \"Error: $bad\\n\";\n-\tusage();\n+\texit(1);\n     }\n     push @srcs, $src;\n     push @dsts, $dst;\n@@ -187,33 +173,39 @@ while(scalar @srcs > 0) {\n }\n \n if ($opt_n) {\n+    if (@changedfiles) {\n \tprint \"Changed  : \". join(\", \", @changedfiles) .\"\\n\";\n+    }\n+    if (@addedfiles) {\n \tprint \"Adding   : \". join(\", \", @addedfiles) .\"\\n\";\n+    }\n+    if (@deletedfiles) {\n \tprint \"Deleting : \". join(\", \", @deletedfiles) .\"\\n\";\n-\texit(1);\n+    }\n }\n-\t\n-if (@changedfiles) {\n+else {\n+    if (@changedfiles) {\n \topen(H, \"| git-update-index -z --stdin\")\n \t\tor die \"git-update-index failed to update changed files with code $!\\n\";\n \tforeach my $fileName (@changedfiles) {\n \t\tprint H \"$fileName\\0\";\n \t}\n \tclose(H);\n-}\n-if (@addedfiles) {\n+    }\n+    if (@addedfiles) {\n \topen(H, \"| git-update-index --add -z --stdin\")\n \t\tor die \"git-update-index failed to add new names with code $!\\n\";\n \tforeach my $fileName (@addedfiles) {\n \t\tprint H \"$fileName\\0\";\n \t}\n \tclose(H);\n-}\n-if (@deletedfiles) {\n+    }\n+    if (@deletedfiles) {\n \topen(H, \"| git-update-index --remove -z --stdin\")\n \t\tor die \"git-update-index failed to remove old names with code $!\\n\";\n \tforeach my $fileName (@deletedfiles) {\n \t\tprint H \"$fileName\\0\";\n \t}\n \tclose(H);\n+    }\n }\n---\n0.99.9.GIT\n"}]}