combine-diff: Honour -z option correctly.
[git.git] / git-am.sh
index ee6886f..7cc4ae5 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -1,11 +1,13 @@
 #!/bin/sh
 #
-#
+# Copyright (c) 2005, 2006 Junio C Hamano
 
 USAGE='[--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>
   or, when resuming [--skip | --resolved]'
 . git-sh-setup
 
+git var GIT_COMMITTER_IDENT >/dev/null || exit
+
 stop_here () {
     echo "$1" >"$dotest/next"
     exit 1
@@ -88,7 +90,10 @@ fall_back_3way () {
     # saying that we reverted all those changes.
 
     git-merge-resolve $orig_tree -- HEAD $his_tree || {
-           git-rerere
+           if test -d "$GIT_DIR/rr-cache"
+           then
+               git-rerere
+           fi
            echo Failed to merge in the changes.
            exit 1
     }
@@ -295,7 +300,7 @@ do
            } >"$dotest/final-commit"
            ;;
        *)
-               case "$resolved,$interactive" in
+               case "$resolved$interactive" in
                tt)
                        # This is used only for interactive view option.
                        git-diff-index -p --cached HEAD >"$dotest/patch"
@@ -359,6 +364,12 @@ do
                # trust what the user has in the index file and the
                # working tree.
                resolved=
+               changed="$(git-diff-index --cached --name-only HEAD)"
+               if test '' = "$changed"
+               then
+                       echo "No changes - did you forget update-index?"
+                       stop_here $this
+               fi
                apply_status=0
                ;;
        esac
@@ -369,7 +380,7 @@ do
                then
                    # Applying the patch to an earlier tree and merging the
                    # result may have produced the same tree as ours.
-                   changed="$(git-diff-index --cached --name-only -z HEAD)"
+                   changed="$(git-diff-index --cached --name-only HEAD)"
                    if test '' = "$changed"
                    then
                            echo No changes -- Patch already applied.