{"thread":{"id":"17403","subject":"[PATCH 2/2] git-am: minor cleanups","startedAt":"2009-01-28T02:38:57Z","lastAt":"2009-01-28T03:08:26Z","messageCount":5,"participants":["Jay Soffian","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"102227","messageId":"1233110338-16806-1-git-send-email-jaysoffian@gmail.com","threadId":"17403","inReplyTo":null,"subject":"[PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-01-28T02:38:57Z","receivedAt":"2009-01-28T02:38:57Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"When git am is called w/o arguments, w/o a patch on stdin and the user hits\nctrl-c, it leaves behind a partially populated $dotest directory. After this\ncommit, it emits usage when called w/o arguments and w/o a patch on stdin.\n\nAlso ensure that $dotest is cleaned up if user manages to interupt mailsplit\nwhile it is processing input.\n\nNoticed by Sverre Rabbelier\n---\n git-am.sh |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex b1c05c9..36227c6 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -254,10 +254,10 @@ else\n \t\tdone\n \t\tshift\n \tfi\n-\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" ||  {\n-\t\trm -fr \"$dotest\"\n-\t\texit 1\n-\t}\n+\ttest $# = 0 && test -t 0 && usage\n+\ttrap 'rm -fr \"$dotest\"' 0\n+\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" || exit 1\n+\ttrap - 0\n \n \t# -s, -u, -k, --whitespace, -3, -C and -p flags are kept\n \t# for the resuming session after a patch failure.\n-- \n1.6.1.224.gb56c\n"},{"id":"102226","messageId":"1233110338-16806-2-git-send-email-jaysoffian@gmail.com","threadId":"17403","inReplyTo":"1233110338-16806-1-git-send-email-jaysoffian@gmail.com","subject":"[PATCH 2/2] git-am: minor cleanups","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-01-28T02:38:58Z","receivedAt":"2009-01-28T02:38:58Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Update usage statement to remove a no-longer supported option, and to hide two\noptions (one a no-op, one internal) unless --help-all is used.\n\nUse \"test -t 0\" instead of deprecated \"tty -s\" to detect when stdin is a\nterminal. (test -t 0 is used elsewhere in git-am and in other git shell\nscripts, tty -s is not.)\n\nUse \"test ...\" instead of \"[ ... ]\" and \"die <msg>\" instead of \"echo <msg>\n>&2; exit 1\" to be consistent with rest of script.\n---\nWhile fixing Sverre's issue, I noticed a few other things about git-am that\nseemed worth cleaning up. These seem much to small to split into separate\npatches so I included them together. Let me know if they should be split.\n\n git-am.sh |   12 ++++--------\n 1 files changed, 4 insertions(+), 8 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 36227c6..2ad229b 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -8,9 +8,8 @@ OPTIONS_SPEC=\"\\\n git am [options] [<mbox>|<Maildir>...]\n git am [options] (--resolved | --skip | --abort)\n --\n-d,dotest=       (removed -- do not use)\n i,interactive   run interactively\n-b,binary        (historical option -- no-op)\n+b,binary*       (historical option -- no-op)\n 3,3way          allow fall back on 3way merging if needed\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n@@ -24,7 +23,7 @@ resolvemsg=     override error message when patch failure occurs\n r,resolved      to be used after a patch failure\n skip            skip the current patch\n abort           restore the original branch and abort the patching operation.\n-rebasing        (internal use for git-rebase)\"\n+rebasing*       (internal use for git-rebase)\"\n \n . git-sh-setup\n prefix=$(git rev-parse --show-prefix)\n@@ -204,7 +203,7 @@ then\n \t\t# unreliable -- stdin could be /dev/null for example\n \t\t# and the caller did not intend to feed us a patch but\n \t\t# wanted to continue unattended.\n-\t\ttty -s\n+\t\ttest -t 0\n \t\t;;\n \t*)\n \t\tfalse\n@@ -280,10 +279,7 @@ fi\n case \"$resolved\" in\n '')\n \tfiles=$(git diff-index --cached --name-only HEAD --) || exit\n-\tif [ \"$files\" ]; then\n-\t   echo \"Dirty index: cannot apply patches (dirty: $files)\" >&2\n-\t   exit 1\n-\tfi\n+\ttest \"$files\" && die \"Dirty index: cannot apply patches (dirty: $files)\"\n esac\n \n if test \"$(cat \"$dotest/utf8\")\" = t\n-- \n1.6.1.224.gb56c\n"},{"id":"102228","messageId":"76718490901271853p4c9eea6dhe7b2ea5edac256b5@mail.gmail.com","threadId":"17403","inReplyTo":"1233110338-16806-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-01-28T02:53:40Z","receivedAt":"2009-01-28T02:53:40Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Jan 27, 2009 at 9:38 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> When git am is called w/o arguments, w/o a patch on stdin and the user hits\n> ctrl-c, it leaves behind a partially populated $dotest directory. After this\n> commit, it emits usage when called w/o arguments and w/o a patch on stdin.\n>\n> Also ensure that $dotest is cleaned up if user manages to interupt mailsplit\n> while it is processing input.\n>\n> Noticed by Sverre Rabbelier\n\nUgh, I forgot to sign-off on this and the next patch. Should I resend\nor is it okay to say:\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n\nj.\n"},{"id":"102229","messageId":"7v7i4gyvzr.fsf@gitster.siamese.dyndns.org","threadId":"17403","inReplyTo":"1233110338-16806-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-28T03:01:28Z","receivedAt":"2009-01-28T03:01:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> Also ensure that $dotest is cleaned up if user manages to interupt mailsplit\n> while it is processing input.\n\nI do not think this \"Also ensure\" part is necessary nor desirable.  If\nsomething goes wrong, we'd like to have a way to resurrect some partial\nresults from the split out result.\n\nThe rest looked fine.  Perhaps a re-roll?\n"},{"id":"102230","messageId":"76718490901271908m4f64232ka9cfb9c554589cf2@mail.gmail.com","threadId":"17403","inReplyTo":"7v7i4gyvzr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/2] git-am: emit usage when called w/o arguments and w/o patch on stdin","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-01-28T03:08:26Z","receivedAt":"2009-01-28T03:08:26Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Jan 27, 2009 at 10:01 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jay Soffian <jaysoffian@gmail.com> writes:\n>\n>> Also ensure that $dotest is cleaned up if user manages to interupt mailsplit\n>> while it is processing input.\n>\n> I do not think this \"Also ensure\" part is necessary nor desirable.  If\n> something goes wrong, we'd like to have a way to resurrect some partial\n> results from the split out result.\n\nHmm, git-am was already nuking $dotest if mailsplit exited non-zero,\nso I kept that behavior, but also clean-up if user kills git-am while\nmailsplit is running.\n\nI still think it should nuke $dotest if user hits ctrl-c, but I agree\nif mailsplit exits non-zero it should not (which would be a change\nfrom what it does now).\n\n> The rest looked fine.  Perhaps a re-roll?\n\nSure.\n\nj.\n"}]}