am: teach StGit patch parser how to read from stdin

git-mailsplit, which splits mbox patches, will read the patch from stdin when the filename is "-" or there are no files listed on the command-line. To be consistent with this behavior, teach the StGit patch parser to read from stdin if the filename is "-" or no files are listed on the command-line. Based-on-patch-by: Chris Packham <judge.packham@gmail.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Paul Tan committed Jun 15, 2015 at 19:08 UTC ab680dce2b565d285ac538fc931bd4b93beb68c8
2 files changed +12 -1
git-am.sh
+2 -1
@@ -297,6 +297,7 @@ split_patches () {
297 ;;
298 stgit)
299 this=0
300 + test 0 -eq "$#" && set -- -
301 for stgit in "$@"
302 do
303 this=$(expr "$this" + 1)
@@ -318,7 +319,7 @@ split_patches () {
319 print "Subject: ", $_ ;
320 $subject = 1;
321 }
321 - ' < "$stgit" > "$dotest/$msgnum" || clean_abort
322 + ' -- "$stgit" >"$dotest/$msgnum" || clean_abort
323 done
324 echo "$this" > "$dotest/last"
325 this=
t/t4150-am.sh
+10
@@ -209,6 +209,16 @@ test_expect_success 'am applies stgit patch' '
209 test_cmp_rev second^ HEAD^
210 '
211
212 +test_expect_success 'am --patch-format=stgit applies stgit patch' '
213 + rm -fr .git/rebase-apply &&
214 + git checkout -f first &&
215 + git am --patch-format=stgit <patch1-stgit.eml &&
216 + test_path_is_missing .git/rebase-apply &&
217 + git diff --exit-code second &&
218 + test_cmp_rev second HEAD &&
219 + test_cmp_rev second^ HEAD^
220 +'
221 +
222 test_expect_success 'setup: new author and committer' '
223 GIT_AUTHOR_NAME="Another Thor" &&
224 GIT_AUTHOR_EMAIL="a.thor@example.com" &&