Merge branch 'rr/am-help'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Jun 2010 18:16:56 +0000 (11:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jun 2010 18:16:56 +0000 (11:16 -0700)
* rr/am-help:
git am: Remove stray error message from sed
git am: Display some help text when patch is empty
git am: Set cmdline globally

1  2 
git-am.sh
diff --combined git-am.sh
index 43ea52c15c3031bd12e86df4016fb35efaf05e5d,d3f6a893527bcf4c14195763c1fc3e35d023e645..ef2d51a2b80d77dc5fe28d76b5047a97dc4c0fae
+++ b/git-am.sh
@@@ -52,6 -52,16 +52,16 @@@ els
        HAS_HEAD=
  fi
  
+ cmdline="git am"
+ if test '' != "$interactive"
+ then
+       cmdline="$cmdline -i"
+ fi
+ if test '' != "$threeway"
+ then
+       cmdline="$cmdline -3"
+ fi
  sq () {
        git rev-parse --sq-quote "$@"
  }
@@@ -66,15 -76,6 +76,6 @@@ stop_here_user_resolve () 
            printf '%s\n' "$resolvemsg"
            stop_here $1
      fi
-     cmdline="git am"
-     if test '' != "$interactive"
-     then
-         cmdline="$cmdline -i"
-     fi
-     if test '' != "$threeway"
-     then
-         cmdline="$cmdline -3"
-     fi
      echo "When you have resolved this problem run \"$cmdline --resolved\"."
      echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
      echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
@@@ -591,6 -592,8 +592,8 @@@ d
  
                test -s "$dotest/patch" || {
                        echo "Patch is empty.  Was it split wrong?"
+                       echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
+                       echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
                        stop_here $this
                }
                rm -f "$dotest/original-commit"
        else
            action=yes
        fi
-       FIRSTLINE=$(sed 1q "$dotest/final-commit")
+       if test -f "$dotest/final-commit"
+       then
+               FIRSTLINE=$(sed 1q "$dotest/final-commit")
+       else
+               FIRSTLINE=""
+       fi
  
        if test $action = skip
        then
                resolved=
                git diff-index --quiet --cached HEAD -- && {
                        echo "No changes - did you forget to use 'git add'?"
 +                      echo "If there is nothing left to stage, chances are that something else"
 +                      echo "already introduced the same changes; you might want to skip this patch."
                        stop_here_user_resolve $this
                }
                unmerged=$(git ls-files -u)