{"thread":{"id":"7386","subject":"Re: [PATCH] Use diff* with --exit-code in git-am, git-rebase and git-merge-ours","startedAt":"2007-03-25T00:42:56Z","lastAt":"2007-03-25T00:49:53Z","messageCount":2,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"37906","messageId":"20070325004256.GB11507@steel.home","threadId":"7386","inReplyTo":null,"subject":"[PATCH] Use diff* with --exit-code in git-am, git-rebase and git-merge-ours","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-25T00:42:56Z","receivedAt":"2007-03-25T00:42:56Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"This simplifies the shell code and reduces memory footprint, speeds\nthings up. The performance improvements should be noticable by\ngit-rebase, when it is used to rebase big commits.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n git-am.sh         |   18 +++++++-----------\n git-merge-ours.sh |    2 +-\n git-rebase.sh     |   10 ++++------\n 3 files changed, 12 insertions(+), 18 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 88af8dd..e9d8d57 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -408,12 +408,10 @@ do\n \t\t# trust what the user has in the index file and the\n \t\t# working tree.\n \t\tresolved=\n-\t\tchanged=\"$(git-diff-index --cached --name-only HEAD)\"\n-\t\tif test '' = \"$changed\"\n-\t\tthen\n+\t\tgit-diff-index --quiet --exit-code --cached HEAD && {\n \t\t\techo \"No changes - did you forget to use 'git add'?\"\n \t\t\tstop_here_user_resolve $this\n-\t\tfi\n+\t\t}\n \t\tunmerged=$(git-ls-files -u)\n \t\tif test -n \"$unmerged\"\n \t\tthen\n@@ -435,13 +433,11 @@ do\n \t\tthen\n \t\t    # Applying the patch to an earlier tree and merging the\n \t\t    # result may have produced the same tree as ours.\n-\t\t    changed=\"$(git-diff-index --cached --name-only HEAD)\"\n-\t\t    if test '' = \"$changed\"\n-\t\t    then\n-\t\t\t    echo No changes -- Patch already applied.\n-\t\t\t    go_next\n-\t\t\t    continue\n-\t\t    fi\n+\t\t    git-diff-index --quiet --exit-code --cached HEAD && {\n+\t\t\techo No changes -- Patch already applied.\n+\t\t\tgo_next\n+\t\t\tcontinue\n+\t\t    }\n \t\t    # clear apply_status -- we have successfully merged.\n \t\t    apply_status=0\n \t\tfi\ndiff --git a/git-merge-ours.sh b/git-merge-ours.sh\nindex 4f3d053..40491f2 100755\n--- a/git-merge-ours.sh\n+++ b/git-merge-ours.sh\n@@ -9,6 +9,6 @@\n # because the current index is what we will be committing as the\n # merge result.\n \n-test \"$(git-diff-index --cached --name-status HEAD)\" = \"\" || exit 2\n+git-diff-index --quiet --exit-code --cached HEAD || exit 2\n \n exit 0\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex aadd580..860c0ce 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -59,7 +59,7 @@ continue_merge () {\n \t\tdie \"$RESOLVEMSG\"\n \tfi\n \n-\tif test -n \"`git-diff-index HEAD`\"\n+\tif ! git-diff-index --quiet --exit-code HEAD\n \tthen\n \t\tif ! git-commit -C \"`cat $dotest/current`\"\n \t\tthen\n@@ -124,13 +124,11 @@ while case \"$#\" in 0) break ;; esac\n do\n \tcase \"$1\" in\n \t--continue)\n-\t\tdiff=$(git-diff-files)\n-\t\tcase \"$diff\" in\n-\t\t?*)\techo \"You must edit all merge conflicts and then\"\n+\t\tgit-diff-files --quiet --exit-code || {\n+\t\t\techo \"You must edit all merge conflicts and then\"\n \t\t\techo \"mark them as resolved using git update-index\"\n \t\t\texit 1\n-\t\t\t;;\n-\t\tesac\n+\t\t}\n \t\tif test -d \"$dotest\"\n \t\tthen\n \t\t\tprev_head=\"`cat $dotest/prev_head`\"\n-- \n1.5.1.rc1.63.g59cc5\n"},{"id":"37903","messageId":"20070325004953.GC11507@steel.home","threadId":"7386","inReplyTo":"20070325004256.GB11507@steel.home","subject":"Re: [PATCH] Use diff* with --exit-code in git-am, git-rebase and git-merge-ours","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-25T00:49:53Z","receivedAt":"2007-03-25T00:49:53Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Alex Riesen, Sun, Mar 25, 2007 01:42:56 +0100:\n> This simplifies the shell code and reduces memory footprint, speeds\n> things up. The performance improvements should be noticable by\n> git-rebase, when it is used to rebase big commits.\n\nPlease ignore, I forgot about \"--quiet implies --exit-code\" again.\nJust documented the option. Will resend.\n"}]}