{"thread":{"id":"19824","subject":"[PATCHv3 0/4] Teach shell scripts to be quiet","startedAt":"2009-06-16T02:05:01Z","lastAt":"2009-06-18T01:07:37Z","messageCount":18,"participants":["Stephen Boyd","Junio C Hamano","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"116376","messageId":"1245117905-19351-1-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":null,"subject":"[PATCHv3 0/4] Teach shell scripts to be quiet","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T02:05:01Z","receivedAt":"2009-06-16T02:05:01Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"The main goal of this series is to teach git-am and git-rebase to be\nquiet.\n\nI was tempted to do a more clever say() which could take arbitrary\nprintf arguments. I've decided it's not worth it, as just doing\nwhat Junio suggested and then adding an echo works well for most\nusers of say().\n\nstash is still left out, and I've noticed that rerere could probably\nbe made quiet too, but that's for a later day.\n\nI've included a test for the newline bug. If it's not wanted\nit can just be dropped.\n\nChanges since v2:\n    - say uses printf instead of echo\n    - suppressing errors from git-apply under am -3 -q\n    - added a test for am -3 -q\n    - added a test for am where subjects have a literal newline\n    - am,rebase tests check both stdout and stderr\n    - rebase.sh::continue_merge() suppress the output of git rev-list\n\nChanges since v1:\n    - introduction of say()\n    - migration of submodule and repack\n\nStephen Boyd (4):\n  t4150: test applying with a newline in subject\n  git-sh-setup: introduce say() for quiet options\n  submodule, repack: migrate to git-sh-setup's say()\n  am, rebase: teach quiet option\n\n Documentation/git-am.txt     |    6 +++++-\n Documentation/git-rebase.txt |    4 ++++\n git-am.sh                    |   26 ++++++++++++++++++++------\n git-rebase.sh                |   39 +++++++++++++++++++++++++++------------\n git-repack.sh                |   12 +++++-------\n git-sh-setup.sh              |   10 ++++++++++\n git-submodule.sh             |   24 ++++++------------------\n t/t3400-rebase.sh            |    7 +++++++\n t/t4150-am.sh                |   26 ++++++++++++++++++++++++++\n 9 files changed, 110 insertions(+), 44 deletions(-)\n"},{"id":"116379","messageId":"1245117905-19351-2-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245117905-19351-1-git-send-email-bebarino@gmail.com","subject":"[PATCHv3 1/4] t4150: test applying with a newline in subject","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T02:05:02Z","receivedAt":"2009-06-16T02:05:02Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Commit 4b7cc26 (git-am: use printf instead of echo on user-supplied\nstrings, 2007-05-25) fixed a bug where subjects with newlines would\ncause git-am to echo multiple lines when it says \"Applying: <subject>\".\n\nThis test ensures that fix stays valid.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n t/t4150-am.sh |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex d6ebbae..51c369a 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -305,4 +305,12 @@ test_expect_success 'am into an unborn branch' '\n \ttest \"z$result\" = \"z$(git rev-parse first^{tree})\"\n '\n \n+test_expect_success 'am newline in subject' '\n+\tgit checkout first &&\n+\ttest_tick &&\n+\tsed -e \"s/second/second \\\\\\n foo/\" patch1 > patchnl &&\n+\tgit am < patchnl > output.out 2>&1 &&\n+\tgrep \"^Applying: second \\\\\\n foo$\" output.out\n+'\n+\n test_done\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116377","messageId":"1245117905-19351-3-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245117905-19351-2-git-send-email-bebarino@gmail.com","subject":"[PATCHv3 2/4] git-sh-setup: introduce say() for quiet options","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T02:05:03Z","receivedAt":"2009-06-16T02:05:03Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Scripts should use say() when they want to output non-error messages.\nThis function helps future script writers easily implement a quiet\noption by setting GIT_QUIET to enable suppression of non-error messages.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n git-sh-setup.sh |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 80acb7d..33513d2 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -44,6 +44,16 @@ die() {\n \texit 1\n }\n \n+GIT_QUIET=\n+\n+say () {\n+\tif test -z \"$GIT_QUIET\"\n+\tthen\n+\t\tprintf \"%s\" \"$*\"\n+\t\techo\n+\tfi\n+}\n+\n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n \t\t\"$0\" -h\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116378","messageId":"1245117905-19351-4-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245117905-19351-3-git-send-email-bebarino@gmail.com","subject":"[PATCHv3 3/4] submodule, repack: migrate to git-sh-setup's say()","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T02:05:04Z","receivedAt":"2009-06-16T02:05:04Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Now that there is say() in git-sh-setup, these scripts don't need to use\ntheir own. Migrate them over by setting GIT_QUIET and removing their\ncustom say() functions.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n git-repack.sh    |   12 +++++-------\n git-submodule.sh |   24 ++++++------------------\n 2 files changed, 11 insertions(+), 25 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 0868734..efb527c 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -24,7 +24,7 @@ SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n no_update_info= all_into_one= remove_redundant= unpack_unreachable=\n-local= quiet= no_reuse= extra=\n+local= no_reuse= extra=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -33,7 +33,7 @@ do\n \t-A)\tall_into_one=t\n \t\tunpack_unreachable=--unpack-unreachable ;;\n \t-d)\tremove_redundant=t ;;\n-\t-q)\tquiet=-q ;;\n+\t-q)\tGIT_QUIET=-q ;;\n \t-f)\tno_reuse=--no-reuse-object ;;\n \t-l)\tlocal=--local ;;\n \t--max-pack-size|--window|--window-memory|--depth)\n@@ -80,13 +80,11 @@ case \",$all_into_one,\" in\n \t;;\n esac\n \n-args=\"$args $local $quiet $no_reuse$extra\"\n+args=\"$args $local $GIT_QUIET $no_reuse$extra\"\n names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n \texit 1\n if [ -z \"$names\" ]; then\n-\tif test -z \"$quiet\"; then\n-\t\techo Nothing new to pack.\n-\tfi\n+\tsay Nothing new to pack.\n fi\n \n # Ok we have prepared all new packfiles.\n@@ -176,7 +174,7 @@ then\n \t\t  done\n \t\t)\n \tfi\n-\tgit prune-packed $quiet\n+\tgit prune-packed $GIT_QUIET\n fi\n \n case \"$no_update_info\" in\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 19a3a84..58d2fd2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -14,23 +14,11 @@ require_work_tree\n \n command=\n branch=\n-quiet=\n reference=\n cached=\n nofetch=\n update=\n \n-#\n-# print stuff on stdout unless -q was specified\n-#\n-say()\n-{\n-\tif test -z \"$quiet\"\n-\tthen\n-\t\techo \"$@\"\n-\tfi\n-}\n-\n # Resolve relative url by appending to parent's url\n resolve_relative_url ()\n {\n@@ -137,7 +125,7 @@ cmd_add()\n \t\t\tshift\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -273,7 +261,7 @@ cmd_init()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -333,7 +321,7 @@ cmd_update()\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n \t\t\tshift\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t-i|--init)\n \t\t\tinit=1\n@@ -650,7 +638,7 @@ cmd_status()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--cached)\n \t\t\tcached=1\n@@ -704,7 +692,7 @@ cmd_sync()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\tshift\n \t\t\t;;\n \t\t--)\n@@ -759,7 +747,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tquiet=1\n+\t\tGIT_QUIET=1\n \t\t;;\n \t-b|--branch)\n \t\tcase \"$2\" in\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116380","messageId":"1245117905-19351-5-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245117905-19351-4-git-send-email-bebarino@gmail.com","subject":"[PATCHv3 4/4] am, rebase: teach quiet option","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T02:05:05Z","receivedAt":"2009-06-16T02:05:05Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"git-rebase and git-am are talkative scripts. This option will quiet\nthem and allow them to speak only when they fail or experience errors.\n\nNote that git-am with 3way will output errors when applying, even though\nthe 3way will usually be successfull. We suppress these errors from\ngit-apply because they are not \"true\" errors until the 3way has been\nattempted.\n\nAdd a few tests for this new feature too.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n Documentation/git-am.txt     |    6 +++++-\n Documentation/git-rebase.txt |    4 ++++\n git-am.sh                    |   26 ++++++++++++++++++++------\n git-rebase.sh                |   39 +++++++++++++++++++++++++++------------\n t/t3400-rebase.sh            |    7 +++++++\n t/t4150-am.sh                |   18 ++++++++++++++++++\n 6 files changed, 81 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex 6d92cbe..32e689b 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n \t [--3way] [--interactive] [--committer-date-is-author-date]\n \t [--ignore-date]\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n-\t [--reject]\n+\t [--reject] [-q | --quiet]\n \t [<mbox> | <Maildir>...]\n 'git am' (--skip | --resolved | --abort)\n \n@@ -39,6 +39,10 @@ OPTIONS\n --keep::\n \tPass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).\n \n+-q::\n+--quiet::\n+\tBe quiet. Only print error messages.\n+\n -u::\n --utf8::\n \tPass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 26f3b7b..db1b71d 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -236,6 +236,10 @@ OPTIONS\n \tis used instead ('git-merge-recursive' when merging a single\n \thead, 'git-merge-octopus' otherwise).  This implies --merge.\n \n+-q::\n+--quiet::\n+\tBe quiet. Implies --no-stat.\n+\n -v::\n --verbose::\n \tBe verbose. Implies --stat.\ndiff --git a/git-am.sh b/git-am.sh\nindex 578780b..42b1bae 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)\n i,interactive   run interactively\n b,binary*       (historical option -- no-op)\n 3,3way          allow fall back on 3way merging if needed\n+q,quiet         be quiet\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n@@ -99,7 +100,7 @@ fall_back_3way () {\n     git write-tree >\"$dotest/patch-merge-base+\" ||\n     cannot_fallback \"Repository lacks necessary blobs to fall back on 3-way merge.\"\n \n-    echo Using index info to reconstruct a base tree...\n+    say Using index info to reconstruct a base tree...\n     if GIT_INDEX_FILE=\"$dotest/patch-merge-tmp-index\" \\\n \tgit apply --cached <\"$dotest/patch\"\n     then\n@@ -115,7 +116,7 @@ It does not apply to blobs recorded in its index.\"\n     orig_tree=$(cat \"$dotest/patch-merge-base\") &&\n     rm -fr \"$dotest\"/patch-merge-* || exit 1\n \n-    echo Falling back to patching base and 3-way merge...\n+    say Falling back to patching base and 3-way merge...\n \n     # This is not so wrong.  Depending on which base we picked,\n     # orig_tree may be wildly different from ours, but his_tree\n@@ -125,6 +126,10 @@ It does not apply to blobs recorded in its index.\"\n \n     eval GITHEAD_$his_tree='\"$FIRSTLINE\"'\n     export GITHEAD_$his_tree\n+    if test -n \"$GIT_QUIET\"\n+    then\n+\t    export GIT_MERGE_VERBOSITY=0\n+    fi\n     git-merge-recursive $orig_tree -- HEAD $his_tree || {\n \t    git rerere\n \t    echo Failed to merge in the changes.\n@@ -181,6 +186,8 @@ do\n \t\tcommitter_date_is_author_date=t ;;\n \t--ignore-date)\n \t\tignore_date=t ;;\n+\t-q|--quiet)\n+\t\tGIT_QUIET=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -352,7 +359,7 @@ fi\n \n if test \"$this\" -gt \"$last\"\n then\n-\techo Nothing to do.\n+\tsay Nothing to do.\n \trm -fr \"$dotest\"\n \texit\n fi\n@@ -498,11 +505,18 @@ do\n \t\tstop_here $this\n \tfi\n \n-\tprintf 'Applying: %s\\n' \"$FIRSTLINE\"\n+\tsay \"Applying: $FIRSTLINE\"\n \n \tcase \"$resolved\" in\n \t'')\n-\t\teval 'git apply '\"$git_apply_opt\"' --index \"$dotest/patch\"'\n+\t\tif test \"$threeway\" = t && test -n \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\teval 'git apply '\"$git_apply_opt\" \\\n+\t\t\t' --index \"$dotest/patch\" > /dev/null 2>&1'\n+\t\telse\n+\t\t\teval 'git apply '\"$git_apply_opt\" \\\n+\t\t\t' --index \"$dotest/patch\"'\n+\t\tfi\n \t\tapply_status=$?\n \t\t;;\n \tt)\n@@ -534,7 +548,7 @@ do\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    git diff-index --quiet --cached HEAD -- && {\n-\t\t\techo No changes -- Patch already applied.\n+\t\t\tsay No changes -- Patch already applied.\n \t\t\tgo_next\n \t\t\tcontinue\n \t\t    }\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex b83fd3f..a518505 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano.\n #\n \n-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'\n+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n LONG_USAGE='git-rebase replaces <branch> with a new branch of the\n same name.  When the --onto option is provided the new branch starts\n out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>\n@@ -72,11 +72,20 @@ continue_merge () {\n \t\t\techo \"directly, but instead do one of the following: \"\n \t\t\tdie \"$RESOLVEMSG\"\n \t\tfi\n-\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tfi\n \telse\n-\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tfi\n+\tfi\n+\tif test -z \"$GIT_QUIET\"\n+\tthen\n+\t\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n \tfi\n-\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n \n \tprev_head=`git rev-parse HEAD^0`\n \t# save the resulting commit so we can read-tree on it later\n@@ -138,7 +147,7 @@ move_to_original_branch () {\n finish_rb_merge () {\n \tmove_to_original_branch\n \trm -r \"$dotest\"\n-\techo \"All done.\"\n+\tsay All done.\n }\n \n is_interactive () {\n@@ -221,7 +230,7 @@ do\n \t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n \t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n \t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\t\tgit am --resolved $GIT_QUIET --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n@@ -249,7 +258,7 @@ do\n \t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n \t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n \t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n+\t\tgit am -3 --skip $GIT_QUIET --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n@@ -300,6 +309,12 @@ do\n \t-v|--verbose)\n \t\tverbose=t\n \t\tdiffstat=t\n+\t\tGIT_QUIET=\n+\t\t;;\n+\t-q|--quiet)\n+\t\tGIT_QUIET=\"-q\"\n+\t\tverbose=\n+\t\tdiffstat=\n \t\t;;\n \t--whitespace=*)\n \t\tgit_am_opt=\"$git_am_opt $1\"\n@@ -445,15 +460,15 @@ then\n \tthen\n \t\t# Lazily switch to the target branch if needed...\n \t\ttest -z \"$switch_to\" || git checkout \"$switch_to\"\n-\t\techo >&2 \"Current branch $branch_name is up to date.\"\n+\t\tsay >&2 \"Current branch $branch_name is up to date.\"\n \t\texit 0\n \telse\n-\t\techo \"Current branch $branch_name is up to date, rebase forced.\"\n+\t\tsay \"Current branch $branch_name is up to date, rebase forced.\"\n \tfi\n fi\n \n # Detach HEAD and reset the tree\n-echo \"First, rewinding head to replay your work on top of it...\"\n+say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n git update-ref ORIG_HEAD $branch\n \n@@ -471,7 +486,7 @@ fi\n # we just fast forwarded.\n if test \"$mb\" = \"$branch\"\n then\n-\techo >&2 \"Fast-forwarded $branch_name to $onto_name.\"\n+\tsay >&2 \"Fast-forwarded $branch_name to $onto_name.\"\n \tmove_to_original_branch\n \texit 0\n fi\n@@ -487,7 +502,7 @@ if test -z \"$do_merge\"\n then\n \tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n \t\t$root_flag \"$revisions\" |\n-\tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am $git_am_opt $GIT_QUIET --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \tret=$?\n \ttest 0 != $ret -a -d \"$GIT_DIR\"/rebase-apply &&\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex 7f62bfb..248944b 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -126,4 +126,11 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '\n      grep \"Untracked working tree file .B. would be overwritten\" output.err\n '\n \n+test_expect_success 'rebase -q is quiet' '\n+     rm B &&\n+     git checkout -b quiet topic &&\n+     git rebase -q master > output.out 2>&1 &&\n+     test ! -s output.out\n+'\n+\n test_done\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 51c369a..a12bf84 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -180,6 +180,17 @@ test_expect_success 'am -3 falls back to 3-way merge' '\n \ttest -z \"$(git diff lorem)\"\n '\n \n+test_expect_success 'am -3 -q is quiet' '\n+\tgit reset master2 --hard &&\n+\tsed -n -e \"3,\\$p\" msg >file &&\n+\thead -n 9 msg >>file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m \"copied stuff\" &&\n+\tgit am -3 -q lorem-move.patch > output.out 2>&1 &&\n+\t! test -s output.out\n+'\n+\n test_expect_success 'am pauses on conflict' '\n \tgit checkout lorem2^^ &&\n \ttest_must_fail git am lorem-move.patch &&\n@@ -313,4 +324,11 @@ test_expect_success 'am newline in subject' '\n \tgrep \"^Applying: second \\\\\\n foo$\" output.out\n '\n \n+test_expect_success 'am -q is quiet' '\n+\tgit checkout first &&\n+\ttest_tick &&\n+\tgit am -q < patch1 > output.out 2>&1 &&\n+\t! test -s output.out\n+'\n+\n test_done\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116385","messageId":"7viqiwg1rl.fsf@alter.siamese.dyndns.org","threadId":"19824","inReplyTo":"1245117905-19351-4-git-send-email-bebarino@gmail.com","subject":"Re: [PATCHv3 3/4] submodule, repack: migrate to git-sh-setup's say()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-16T05:56:30Z","receivedAt":"2009-06-16T05:56:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Now that there is say() in git-sh-setup, these scripts don't need to use\n> their own. Migrate them over by setting GIT_QUIET and removing their\n> custom say() functions.\n\nThis is not exactly a very nice style.\n\nThe contract between the callers of say() and its implementation is that\nit does not matter what value is set to GIT_QUIET.  The only thing that\nmatters is if it is set to empty string or not.  And ...\n\n> @@ -33,7 +33,7 @@ do\n>  \t-A)\tall_into_one=t\n>  \t\tunpack_unreachable=--unpack-unreachable ;;\n>  \t-d)\tremove_redundant=t ;;\n> -\t-q)\tquiet=-q ;;\n> +\t-q)\tGIT_QUIET=-q ;;\n\n... this one takes advantage of it to set GIT_QUIET to -q, so that it can\nbe directly passed to another command that happens to use -q as \"quiet\"\noption, like this ...\n\n> -\tgit prune-packed $quiet\n> +\tgit prune-packed $GIT_QUIET\n>  fi\n\n... while the other one does not have a callout to command that takes -q\nat all, and does this ...\n\n>  \t\t-q|--quiet)\n> -\t\t\tquiet=1\n> +\t\t\tGIT_QUIET=1\n\nIf the convention is \"GIT_QUIET, when set to non-empty string, squelches\nthe output\", then I think the callers should be more consistent and the\ncall to prune-packed should say something like this, which is admittedly a\nroundabout way:\n\n\tgit prune-packed ${GIT_QUIET:+-q}\n\nfor consistency (and then what you set to GIT_QUIET in the first hunk I\nquoted does not matter anymore---it can even be t or 1 or whatever).\n\nI think this does not matter too much, because I suspect that in the\nlonger term scripted Porcelains are going away, but still...\n"},{"id":"116386","messageId":"7vbpoog1py.fsf@alter.siamese.dyndns.org","threadId":"19824","inReplyTo":"1245117905-19351-5-git-send-email-bebarino@gmail.com","subject":"Re: [PATCHv3 4/4] am, rebase: teach quiet option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-16T05:57:29Z","receivedAt":"2009-06-16T05:57:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> git-rebase and git-am are talkative scripts. This option will quiet\n> them and allow them to speak only when they fail or experience errors.\n>\n> Note that git-am with 3way will output errors when applying, even though\n> the 3way will usually be successfull. We suppress these errors from\n> git-apply because they are not \"true\" errors until the 3way has been\n> attempted.\n\nThanks.\n\n> @@ -498,11 +505,18 @@ do\n> ...\n>  \tcase \"$resolved\" in\n>  \t'')\n> -\t\teval 'git apply '\"$git_apply_opt\"' --index \"$dotest/patch\"'\n> +\t\tif test \"$threeway\" = t && test -n \"$GIT_QUIET\"\n> +\t\tthen\n> +\t\t\teval 'git apply '\"$git_apply_opt\" \\\n> +\t\t\t' --index \"$dotest/patch\" > /dev/null 2>&1'\n> +\t\telse\n> +\t\t\teval 'git apply '\"$git_apply_opt\" \\\n> +\t\t\t' --index \"$dotest/patch\"'\n> +\t\tfi\n>  \t\tapply_status=$?\n\nHmm, this long conditional body looks ugly, and I suspect it is harder to\nmaintain than necessary.  Can we do something about it?\n\n\t# When we are allowed to fall back to 3-way later, don't give\n        # false errors during the initial attempt.\n\tsquelch=\n\tif test \"$threeway\" = t && test -n \"$GIT_QUIET\"\n\tthen\n\t\tsquelch='>/dev/null 2>&1 '\n\tfi\n        eval \"git apply $squelch$git_apply_opt\"' --index \"$dotest/patch\"'\n\n> @@ -72,11 +72,20 @@ continue_merge () {\n>  \t\t\techo \"directly, but instead do one of the following: \"\n>  \t\t\tdie \"$RESOLVEMSG\"\n>  \t\tfi\n> -\t\tprintf \"Committed: %0${prec}d \" $msgnum\n> +\t\tif test -z \"$GIT_QUIET\"\n> +\t\tthen\n> +\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n> +\t\tfi\n>  \telse\n> -\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n> +\t\tif test -z \"$GIT_QUIET\"\n> +\t\tthen\n> +\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n> +\t\tfi\n> +\tfi\n> +\tif test -z \"$GIT_QUIET\"\n> +\tthen\n> +\t\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n>  \tfi\n> -\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n\nThis is very good, because a straightforward translation is what we want\nin this particular patch.\n\nWe however would want to update this using\n\n\tgit show -s --oneline\n\nor something, perhaps even with a custom --format='...', in a follow-up\npatch.  This \"rev-list --pretty=oneline\" piped to sed looks very much\nantiquated.\n\n> @@ -445,15 +460,15 @@ then\n>  \tthen\n>  \t\t# Lazily switch to the target branch if needed...\n>  \t\ttest -z \"$switch_to\" || git checkout \"$switch_to\"\n> -\t\techo >&2 \"Current branch $branch_name is up to date.\"\n> +\t\tsay >&2 \"Current branch $branch_name is up to date.\"\n>  \t\texit 0\n\nAh, I was blind.\n\nWhile sending non-error messages to stderr is justifiable, I do not think\nthis one is, because all the other progress-y message in this program we\nreviewed so far go to stdout.  I think we should drop >&2 here.\n\n> @@ -471,7 +486,7 @@ fi\n>  # we just fast forwarded.\n>  if test \"$mb\" = \"$branch\"\n>  then\n> -\techo >&2 \"Fast-forwarded $branch_name to $onto_name.\"\n> +\tsay >&2 \"Fast-forwarded $branch_name to $onto_name.\"\n\nDitto.\n\nThere is one more thing to think about in git-am, which I do not think you\naddressed.  Consider this scenario.\n\n    (1) Tell am to run quietly, feeding a four-patch series.\n\n\t$ git am -q -3 mbox\n\n    (2) The first patch applies cleanly; the second one does not apply,\n        even with -3, and leaves conflict (you did the right thing not to\n        squelch the message when this happens).\n\n    (3) You fix it up, and save the result from your editor, and tell it\n        to continue.\n\n\t$ git am --resolved\n\nNow, should the second invocation be also quiet, or talkative as default?\n\nNote that the third and fourth patch are applied with -3 option in effect,\neven though you did not say -3 when you restarted \"am\" with --resolved\n(cf. ll.280-340 in git-am.sh).\n"},{"id":"116388","messageId":"7v3aa0g0qq.fsf@alter.siamese.dyndns.org","threadId":"19824","inReplyTo":"7viqiwg1rl.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] submodule, repack: migrate to git-sh-setup's say()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-16T06:18:37Z","receivedAt":"2009-06-16T06:18:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> ...\n> If the convention is \"GIT_QUIET, when set to non-empty string, squelches\n> the output\", then I think the callers should be more consistent and the\n> call to prune-packed should say something like this, which is admittedly a\n> roundabout way:\n>\n> \tgit prune-packed ${GIT_QUIET:+-q}\n>\n> for consistency (and then what you set to GIT_QUIET in the first hunk I\n> quoted does not matter anymore---it can even be t or 1 or whatever).\n>\n> I think this does not matter too much, because I suspect that in the\n> longer term scripted Porcelains are going away, but still...\n\nWhat I meant was that my _style_ comment does not matter too much.  The\naddition of \"quiet\" _is_ a worthwhile thing to do, I think.\n"},{"id":"116391","messageId":"4A374BE0.4060604@gmail.com","threadId":"19824","inReplyTo":"7viqiwg1rl.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/4] submodule, repack: migrate to git-sh-setup's say()","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T07:38:08Z","receivedAt":"2009-06-16T07:38:08Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Junio C Hamano wrote:\n> This is not exactly a very nice style.\n\nI had a feeling ;-)\n\n> If the convention is \"GIT_QUIET, when set to non-empty string, squelches\n> the output\", then I think the callers should be more consistent and the\n> call to prune-packed should say something like this, which is admittedly a\n> roundabout way:\n>\n> \tgit prune-packed ${GIT_QUIET:+-q}\n>\n> for consistency (and then what you set to GIT_QUIET in the first hunk I\n> quoted does not matter anymore---it can even be t or 1 or whatever).\n>\n> I think this does not matter too much, because I suspect that in the\n> longer term scripted Porcelains are going away, but still...\n\nI think this is fine. At least it's more explicit and localized. I'll do\nthe same for git-am\n"},{"id":"116393","messageId":"4A374EAD.9030309@gmail.com","threadId":"19824","inReplyTo":"7vbpoog1py.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 4/4] am, rebase: teach quiet option","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T07:50:05Z","receivedAt":"2009-06-16T07:50:05Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Junio C Hamano wrote:\n> Hmm, this long conditional body looks ugly, and I suspect it is harder to\n> maintain than necessary.  Can we do something about it?\n>\n> \t# When we are allowed to fall back to 3-way later, don't give\n>         # false errors during the initial attempt.\n> \tsquelch=\n> \tif test \"$threeway\" = t && test -n \"$GIT_QUIET\"\n> \tthen\n> \t\tsquelch='>/dev/null 2>&1 '\n> \tfi\n>         eval \"git apply $squelch$git_apply_opt\"' --index \"$dotest/patch\"'\n>\n\nThanks. I thought there would be a nicer way but I didn't know it.\n\n> Ah, I was blind.\n>\n> While sending non-error messages to stderr is justifiable, I do not think\n> this one is, because all the other progress-y message in this program we\n> reviewed so far go to stdout.  I think we should drop >&2 here.\n\nWill do, gotta fixup some tests for that though...\n\n> There is one more thing to think about in git-am, which I do not think you\n> addressed.  Consider this scenario.\n>\n>     (1) Tell am to run quietly, feeding a four-patch series.\n>\n> \t$ git am -q -3 mbox\n>\n>     (2) The first patch applies cleanly; the second one does not apply,\n>         even with -3, and leaves conflict (you did the right thing not to\n>         squelch the message when this happens).\n>\n>     (3) You fix it up, and save the result from your editor, and tell it\n>         to continue.\n>\n> \t$ git am --resolved\n>\n> Now, should the second invocation be also quiet, or talkative as default?\n>\n> Note that the third and fourth patch are applied with -3 option in effect,\n> even though you did not say -3 when you restarted \"am\" with --resolved\n> (cf. ll.280-340 in git-am.sh).\n\nThanks for bringing this up. I gave this some thought before I sent the\nseries out but I was secretly hoping nobody would care :-) I think it's\nmore correct and maybe even more consistent to keep the quiet option\nenabled.\n\nSeeing as this series is going for round 4 I'll make sure to include\nthis as well.\n"},{"id":"116396","messageId":"4A375418.8050401@viscovery.net","threadId":"19824","inReplyTo":"1245117905-19351-3-git-send-email-bebarino@gmail.com","subject":"Re: [PATCHv3 2/4] git-sh-setup: introduce say() for quiet options","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-06-16T08:13:12Z","receivedAt":"2009-06-16T08:13:12Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Stephen Boyd schrieb:\n> +say () {\n> +\tif test -z \"$GIT_QUIET\"\n> +\tthen\n> +\t\tprintf \"%s\" \"$*\"\n> +\t\techo\n\nYou can squash these two lines into\n\n\t\tprintf '%s\\n' \"$*\"\n\n-- Hannes\n"},{"id":"116448","messageId":"1245191581-11127-1-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245117905-19351-1-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 0/5] Teach shell scripts to be quiet","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:32:56Z","receivedAt":"2009-06-16T22:32:56Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"The main goal of this series is to teach git-am and git-rebase to be\nquiet.\n\nThis series feels very improved. I'm pretty confident in the first\nthree patches. I've split off the suppressing errors from git-apply\nin git-am into its own patch this time around. It felt more like\nan independent change.\n\nI've tried to make sure I maintained GIT_QUIET after failing to apply,\nbut I'd appreciate if others could look over that to make sure.\n\nChanges since v3:\n    - simplify say()\n    - say \"applying to an empty history\" in am.sh\n    - quiet merge in rebase.sh::call_merge()\n    - drop >&2 in a couple places in rebase.sh\n    - maintain GIT_QUIET when git-am or git-rebase fails\n    - fixup style issues with repack.sh\n    - add to git_am_opt instead of hijacking GIT_QUIET in rebase.sh\n\nChanges since v2:\n    - say uses printf instead of echo\n    - suppressing errors from git-apply under am -3 -q\n    - added a test for am -3 -q\n    - added a test for am where subjects have a literal newline\n    - am,rebase tests check both stdout and stderr\n    - rebase.sh::continue_merge() suppress the output of git rev-list\n\nChanges since v1:\n    - introduction of say()\n    - migration of submodule and repack\n\nStephen Boyd (5):\n  t4150: test applying with a newline in subject\n  am: suppress apply errors when using 3-way\n  git-sh-setup: introduce say() for quiet options\n  submodule, repack: migrate to git-sh-setup's say()\n  am, rebase: teach quiet option\n\n Documentation/git-am.txt     |    6 ++++-\n Documentation/git-rebase.txt |    4 +++\n git-am.sh                    |   35 +++++++++++++++++++++++-------\n git-rebase.sh                |   48 +++++++++++++++++++++++++++++++++--------\n git-repack.sh                |   12 ++++------\n git-sh-setup.sh              |    9 +++++++\n git-submodule.sh             |   24 +++++---------------\n t/t3400-rebase.sh            |   19 +++++++++++-----\n t/t4150-am.sh                |   26 ++++++++++++++++++++++\n 9 files changed, 133 insertions(+), 50 deletions(-)\n"},{"id":"116451","messageId":"1245191581-11127-2-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-1-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 1/5] t4150: test applying with a newline in subject","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:32:57Z","receivedAt":"2009-06-16T22:32:57Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Commit 4b7cc26 (git-am: use printf instead of echo on user-supplied\nstrings, 2007-05-25) fixed a bug where subjects with newlines would\ncause git-am to echo multiple lines when it says \"Applying: <subject>\".\n\nThis test ensures that fix stays valid.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nNothing new here.\n\n t/t4150-am.sh |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex d6ebbae..51c369a 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -305,4 +305,12 @@ test_expect_success 'am into an unborn branch' '\n \ttest \"z$result\" = \"z$(git rev-parse first^{tree})\"\n '\n \n+test_expect_success 'am newline in subject' '\n+\tgit checkout first &&\n+\ttest_tick &&\n+\tsed -e \"s/second/second \\\\\\n foo/\" patch1 > patchnl &&\n+\tgit am < patchnl > output.out 2>&1 &&\n+\tgrep \"^Applying: second \\\\\\n foo$\" output.out\n+'\n+\n test_done\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116447","messageId":"1245191581-11127-3-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-2-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 2/5] am: suppress apply errors when using 3-way","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:32:58Z","receivedAt":"2009-06-16T22:32:58Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"git-am with 3-way outputs errors when applying, even though the\n3-way will usually be successful. We suppress these errors from\ngit-apply because they are not \"true\" errors until the 3-way has been\nattempted.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nSeems to me like we should always suppress these errors if we're\nfalling back to 3-way. So I've removed the test for GIT_QUIET\nand pushed this earlier in the series.\n\n git-am.sh |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 578780b..e26c54a 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -502,7 +502,14 @@ do\n \n \tcase \"$resolved\" in\n \t'')\n-\t\teval 'git apply '\"$git_apply_opt\"' --index \"$dotest/patch\"'\n+\t\t# When we are allowed to fall back to 3-way later, don't give\n+\t\t# false errors during the initial attempt.\n+\t\tsquelch=\n+\t\tif test \"$threeway\" = t\n+\t\tthen\n+\t\t\tsquelch='>/dev/null 2>&1 '\n+\t\tfi\n+\t\teval \"git apply $squelch$git_apply_opt\"' --index \"$dotest/patch\"'\n \t\tapply_status=$?\n \t\t;;\n \tt)\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116453","messageId":"1245191581-11127-4-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-3-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 3/5] git-sh-setup: introduce say() for quiet options","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:32:59Z","receivedAt":"2009-06-16T22:32:59Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Scripts should use say() when they want to output non-error messages.\nThis function helps future script writers easily implement a quiet\noption by setting GIT_QUIET to enable suppression of non-error messages.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n git-sh-setup.sh |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 80acb7d..c41c2f7 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -44,6 +44,15 @@ die() {\n \texit 1\n }\n \n+GIT_QUIET=\n+\n+say () {\n+\tif test -z \"$GIT_QUIET\"\n+\tthen\n+\t\tprintf '%s\\n' \"$*\"\n+\tfi\n+}\n+\n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n \t\t\"$0\" -h\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116449","messageId":"1245191581-11127-5-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-4-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 4/5] submodule, repack: migrate to git-sh-setup's say()","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:33:00Z","receivedAt":"2009-06-16T22:33:00Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Now that there is say() in git-sh-setup, these scripts don't need to use\ntheir own. Migrate them over by setting GIT_QUIET and removing their\ncustom say() functions.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nThis has the style fixups.\n\n git-repack.sh    |   12 +++++-------\n git-submodule.sh |   24 ++++++------------------\n 2 files changed, 11 insertions(+), 25 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 0868734..1bf2394 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -24,7 +24,7 @@ SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n no_update_info= all_into_one= remove_redundant= unpack_unreachable=\n-local= quiet= no_reuse= extra=\n+local= no_reuse= extra=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -33,7 +33,7 @@ do\n \t-A)\tall_into_one=t\n \t\tunpack_unreachable=--unpack-unreachable ;;\n \t-d)\tremove_redundant=t ;;\n-\t-q)\tquiet=-q ;;\n+\t-q)\tGIT_QUIET=t ;;\n \t-f)\tno_reuse=--no-reuse-object ;;\n \t-l)\tlocal=--local ;;\n \t--max-pack-size|--window|--window-memory|--depth)\n@@ -80,13 +80,11 @@ case \",$all_into_one,\" in\n \t;;\n esac\n \n-args=\"$args $local $quiet $no_reuse$extra\"\n+args=\"$args $local ${GIT_QUIET:+-q} $no_reuse$extra\"\n names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n \texit 1\n if [ -z \"$names\" ]; then\n-\tif test -z \"$quiet\"; then\n-\t\techo Nothing new to pack.\n-\tfi\n+\tsay Nothing new to pack.\n fi\n \n # Ok we have prepared all new packfiles.\n@@ -176,7 +174,7 @@ then\n \t\t  done\n \t\t)\n \tfi\n-\tgit prune-packed $quiet\n+\tgit prune-packed ${GIT_QUIET:+-q}\n fi\n \n case \"$no_update_info\" in\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 19a3a84..58d2fd2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -14,23 +14,11 @@ require_work_tree\n \n command=\n branch=\n-quiet=\n reference=\n cached=\n nofetch=\n update=\n \n-#\n-# print stuff on stdout unless -q was specified\n-#\n-say()\n-{\n-\tif test -z \"$quiet\"\n-\tthen\n-\t\techo \"$@\"\n-\tfi\n-}\n-\n # Resolve relative url by appending to parent's url\n resolve_relative_url ()\n {\n@@ -137,7 +125,7 @@ cmd_add()\n \t\t\tshift\n \t\t\t;;\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--reference)\n \t\t\tcase \"$2\" in '') usage ;; esac\n@@ -273,7 +261,7 @@ cmd_init()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--)\n \t\t\tshift\n@@ -333,7 +321,7 @@ cmd_update()\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n \t\t\tshift\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t-i|--init)\n \t\t\tinit=1\n@@ -650,7 +638,7 @@ cmd_status()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\t;;\n \t\t--cached)\n \t\t\tcached=1\n@@ -704,7 +692,7 @@ cmd_sync()\n \tdo\n \t\tcase \"$1\" in\n \t\t-q|--quiet)\n-\t\t\tquiet=1\n+\t\t\tGIT_QUIET=1\n \t\t\tshift\n \t\t\t;;\n \t\t--)\n@@ -759,7 +747,7 @@ do\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n-\t\tquiet=1\n+\t\tGIT_QUIET=1\n \t\t;;\n \t-b|--branch)\n \t\tcase \"$2\" in\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116450","messageId":"1245191581-11127-6-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-5-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 5/5] am, rebase: teach quiet option","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-16T22:33:01Z","receivedAt":"2009-06-16T22:33:01Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"git-am and git-rebase are talkative scripts. Teach them to be quiet when\ntold, allowing them to speak only when they fail or experience errors.\n\nThe quiet option is maintained when git-am or git-rebase fails to apply\na patch. This means subsequent --resolved, --continue, --skip, --abort\ninvocations will be quiet if the original invocation was quiet.\n\nDrop a couple >&2 statements because Junio has deemed them unnecessary.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nCopied from cover letter for convenience:\n    - say \"applying to an empty history\" in am.sh\n    - quiet merge in rebase.sh::call_merge()\n    - drop >&2 in a couple places in rebase.sh\n    - maintain GIT_QUIET when git-am or git-rebase fails\n    - add to git_am_opt instead of hijacking GIT_QUIET in rebase.sh\n\nI chose GIT_MERGE_VERBOSITY=1 in rebase because the resolvemsg\nsays \"correct the above error\", and GIT_MERGE_VERBOSITY=0 prints\nnothing. I think this might be a bug, either in the documentation or\nin merge-recursive. At least setting it to 1 prints\n\"CONFLICT (content): ...\" \n\nThis behavior was observed by passing -q to rebase in t3407.\n\n Documentation/git-am.txt     |    6 ++++-\n Documentation/git-rebase.txt |    4 +++\n git-am.sh                    |   26 ++++++++++++++++------\n git-rebase.sh                |   48 +++++++++++++++++++++++++++++++++--------\n t/t3400-rebase.sh            |   19 +++++++++++-----\n t/t4150-am.sh                |   18 +++++++++++++++\n 6 files changed, 97 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex 6d92cbe..32e689b 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n \t [--3way] [--interactive] [--committer-date-is-author-date]\n \t [--ignore-date]\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n-\t [--reject]\n+\t [--reject] [-q | --quiet]\n \t [<mbox> | <Maildir>...]\n 'git am' (--skip | --resolved | --abort)\n \n@@ -39,6 +39,10 @@ OPTIONS\n --keep::\n \tPass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).\n \n+-q::\n+--quiet::\n+\tBe quiet. Only print error messages.\n+\n -u::\n --utf8::\n \tPass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 26f3b7b..db1b71d 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -236,6 +236,10 @@ OPTIONS\n \tis used instead ('git-merge-recursive' when merging a single\n \thead, 'git-merge-octopus' otherwise).  This implies --merge.\n \n+-q::\n+--quiet::\n+\tBe quiet. Implies --no-stat.\n+\n -v::\n --verbose::\n \tBe verbose. Implies --stat.\ndiff --git a/git-am.sh b/git-am.sh\nindex e26c54a..58d4eb6 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)\n i,interactive   run interactively\n b,binary*       (historical option -- no-op)\n 3,3way          allow fall back on 3way merging if needed\n+q,quiet         be quiet\n s,signoff       add a Signed-off-by line to the commit message\n u,utf8          recode into utf8 (default)\n k,keep          pass -k flag to git-mailinfo\n@@ -99,7 +100,7 @@ fall_back_3way () {\n     git write-tree >\"$dotest/patch-merge-base+\" ||\n     cannot_fallback \"Repository lacks necessary blobs to fall back on 3-way merge.\"\n \n-    echo Using index info to reconstruct a base tree...\n+    say Using index info to reconstruct a base tree...\n     if GIT_INDEX_FILE=\"$dotest/patch-merge-tmp-index\" \\\n \tgit apply --cached <\"$dotest/patch\"\n     then\n@@ -115,7 +116,7 @@ It does not apply to blobs recorded in its index.\"\n     orig_tree=$(cat \"$dotest/patch-merge-base\") &&\n     rm -fr \"$dotest\"/patch-merge-* || exit 1\n \n-    echo Falling back to patching base and 3-way merge...\n+    say Falling back to patching base and 3-way merge...\n \n     # This is not so wrong.  Depending on which base we picked,\n     # orig_tree may be wildly different from ours, but his_tree\n@@ -125,6 +126,10 @@ It does not apply to blobs recorded in its index.\"\n \n     eval GITHEAD_$his_tree='\"$FIRSTLINE\"'\n     export GITHEAD_$his_tree\n+    if test -n \"$GIT_QUIET\"\n+    then\n+\t    export GIT_MERGE_VERBOSITY=0\n+    fi\n     git-merge-recursive $orig_tree -- HEAD $his_tree || {\n \t    git rerere\n \t    echo Failed to merge in the changes.\n@@ -181,6 +186,8 @@ do\n \t\tcommitter_date_is_author_date=t ;;\n \t--ignore-date)\n \t\tignore_date=t ;;\n+\t-q|--quiet)\n+\t\tGIT_QUIET=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -279,7 +286,7 @@ else\n \t\texit 1\n \t}\n \n-\t# -s, -u, -k, --whitespace, -3, -C and -p flags are kept\n+\t# -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept\n \t# for the resuming session after a patch failure.\n \t# -i can and must be given when resuming.\n \techo \" $git_apply_opt\" >\"$dotest/apply-opt\"\n@@ -287,6 +294,7 @@ else\n \techo \"$sign\" >\"$dotest/sign\"\n \techo \"$utf8\" >\"$dotest/utf8\"\n \techo \"$keep\" >\"$dotest/keep\"\n+\techo \"$GIT_QUIET\" >\"$dotest/quiet\"\n \techo 1 >\"$dotest/next\"\n \tif test -n \"$rebasing\"\n \tthen\n@@ -327,6 +335,10 @@ if test \"$(cat \"$dotest/keep\")\" = t\n then\n \tkeep=-k\n fi\n+if test \"$(cat \"$dotest/quiet\")\" = t\n+then\n+\tGIT_QUIET=t\n+fi\n if test \"$(cat \"$dotest/threeway\")\" = t\n then\n \tthreeway=t\n@@ -352,7 +364,7 @@ fi\n \n if test \"$this\" -gt \"$last\"\n then\n-\techo Nothing to do.\n+\tsay Nothing to do.\n \trm -fr \"$dotest\"\n \texit\n fi\n@@ -498,7 +510,7 @@ do\n \t\tstop_here $this\n \tfi\n \n-\tprintf 'Applying: %s\\n' \"$FIRSTLINE\"\n+\tsay \"Applying: $FIRSTLINE\"\n \n \tcase \"$resolved\" in\n \t'')\n@@ -541,7 +553,7 @@ do\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    git diff-index --quiet --cached HEAD -- && {\n-\t\t\techo No changes -- Patch already applied.\n+\t\t\tsay No changes -- Patch already applied.\n \t\t\tgo_next\n \t\t\tcontinue\n \t\t    }\n@@ -567,7 +579,7 @@ do\n \t\t\tGIT_AUTHOR_DATE=\n \t\tfi\n \t\tparent=$(git rev-parse --verify -q HEAD) ||\n-\t\techo >&2 \"applying to an empty history\"\n+\t\tsay >&2 \"applying to an empty history\"\n \n \t\tif test -n \"$committer_date_is_author_date\"\n \t\tthen\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex b83fd3f..84b5173 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano.\n #\n \n-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'\n+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n LONG_USAGE='git-rebase replaces <branch> with a new branch of the\n same name.  When the --onto option is provided the new branch starts\n out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>\n@@ -72,11 +72,20 @@ continue_merge () {\n \t\t\techo \"directly, but instead do one of the following: \"\n \t\t\tdie \"$RESOLVEMSG\"\n \t\tfi\n-\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tfi\n \telse\n-\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tfi\n+\tfi\n+\tif test -z \"$GIT_QUIET\"\n+\tthen\n+\t\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n \tfi\n-\tgit rev-list --pretty=oneline -1 \"$cmt\" | sed -e 's/^[^ ]* //'\n \n \tprev_head=`git rev-parse HEAD^0`\n \t# save the resulting commit so we can read-tree on it later\n@@ -97,6 +106,10 @@ call_merge () {\n \teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n \teval GITHEAD_$hd='$(cat \"$dotest/onto_name\")'\n \texport GITHEAD_$cmt GITHEAD_$hd\n+\tif test -n \"$GIT_QUIET\"\n+\tthen\n+\t\texport GIT_MERGE_VERBOSITY=1\n+\tfi\n \tgit-merge-$strategy \"$cmt^\" -- \"$hd\" \"$cmt\"\n \trv=$?\n \tcase \"$rv\" in\n@@ -138,7 +151,7 @@ move_to_original_branch () {\n finish_rb_merge () {\n \tmove_to_original_branch\n \trm -r \"$dotest\"\n-\techo \"All done.\"\n+\tsay All done.\n }\n \n is_interactive () {\n@@ -209,6 +222,7 @@ do\n \t\t\tend=$(cat \"$dotest/end\")\n \t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n \t\t\tonto=$(cat \"$dotest/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n \t\t\tcontinue_merge\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n@@ -221,6 +235,7 @@ do\n \t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n \t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n \t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -238,6 +253,7 @@ do\n \t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n \t\t\tmsgnum=$(($msgnum + 1))\n \t\t\tonto=$(cat \"$dotest/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n \t\t\t\tcall_merge \"$msgnum\"\n@@ -249,6 +265,7 @@ do\n \t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n \t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n \t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n \t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -260,9 +277,11 @@ do\n \t\tgit rerere clear\n \t\tif test -d \"$dotest\"\n \t\tthen\n+\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n \t\t\tmove_to_original_branch\n \t\telse\n \t\t\tdotest=\"$GIT_DIR\"/rebase-apply\n+\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n \t\t\tmove_to_original_branch\n \t\tfi\n \t\tgit reset --hard $(cat \"$dotest/orig-head\")\n@@ -300,6 +319,13 @@ do\n \t-v|--verbose)\n \t\tverbose=t\n \t\tdiffstat=t\n+\t\tGIT_QUIET=\n+\t\t;;\n+\t-q|--quiet)\n+\t\tGIT_QUIET=t\n+\t\tgit_am_opt=\"$git_am_opt -q\"\n+\t\tverbose=\n+\t\tdiffstat=\n \t\t;;\n \t--whitespace=*)\n \t\tgit_am_opt=\"$git_am_opt $1\"\n@@ -445,15 +471,15 @@ then\n \tthen\n \t\t# Lazily switch to the target branch if needed...\n \t\ttest -z \"$switch_to\" || git checkout \"$switch_to\"\n-\t\techo >&2 \"Current branch $branch_name is up to date.\"\n+\t\tsay \"Current branch $branch_name is up to date.\"\n \t\texit 0\n \telse\n-\t\techo \"Current branch $branch_name is up to date, rebase forced.\"\n+\t\tsay \"Current branch $branch_name is up to date, rebase forced.\"\n \tfi\n fi\n \n # Detach HEAD and reset the tree\n-echo \"First, rewinding head to replay your work on top of it...\"\n+say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n git update-ref ORIG_HEAD $branch\n \n@@ -471,7 +497,7 @@ fi\n # we just fast forwarded.\n if test \"$mb\" = \"$branch\"\n then\n-\techo >&2 \"Fast-forwarded $branch_name to $onto_name.\"\n+\tsay \"Fast-forwarded $branch_name to $onto_name.\"\n \tmove_to_original_branch\n \texit 0\n fi\n@@ -493,7 +519,8 @@ then\n \ttest 0 != $ret -a -d \"$GIT_DIR\"/rebase-apply &&\n \t\techo $head_name > \"$GIT_DIR\"/rebase-apply/head-name &&\n \t\techo $onto > \"$GIT_DIR\"/rebase-apply/onto &&\n-\t\techo $orig_head > \"$GIT_DIR\"/rebase-apply/orig-head\n+\t\techo $orig_head > \"$GIT_DIR\"/rebase-apply/orig-head &&\n+\t\techo \"$GIT_QUIET\" > \"$GIT_DIR\"/rebase-apply/quiet\n \texit $ret\n fi\n \n@@ -507,6 +534,7 @@ prev_head=$orig_head\n echo \"$prev_head\" > \"$dotest/prev_head\"\n echo \"$orig_head\" > \"$dotest/orig-head\"\n echo \"$head_name\" > \"$dotest/head-name\"\n+echo \"$GIT_QUIET\" > \"$dotest/quiet\"\n \n msgnum=0\n for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex 7f62bfb..c5c29cc 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -54,8 +54,8 @@ test_expect_success 'rebase against master' '\n      git rebase master'\n \n test_expect_success 'rebase against master twice' '\n-     git rebase master 2>err &&\n-     grep \"Current branch my-topic-branch is up to date\" err\n+     git rebase master >out &&\n+     grep \"Current branch my-topic-branch is up to date\" out\n '\n \n test_expect_success 'rebase against master twice with --force' '\n@@ -65,14 +65,14 @@ test_expect_success 'rebase against master twice with --force' '\n \n test_expect_success 'rebase against master twice from another branch' '\n      git checkout my-topic-branch^ &&\n-     git rebase master my-topic-branch 2>err &&\n-     grep \"Current branch my-topic-branch is up to date\" err\n+     git rebase master my-topic-branch >out &&\n+     grep \"Current branch my-topic-branch is up to date\" out\n '\n \n test_expect_success 'rebase fast-forward to master' '\n      git checkout my-topic-branch^ &&\n-     git rebase my-topic-branch 2>err &&\n-     grep \"Fast-forwarded HEAD to my-topic-branch\" err\n+     git rebase my-topic-branch >out &&\n+     grep \"Fast-forwarded HEAD to my-topic-branch\" out\n '\n \n test_expect_success \\\n@@ -126,4 +126,11 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '\n      grep \"Untracked working tree file .B. would be overwritten\" output.err\n '\n \n+test_expect_success 'rebase -q is quiet' '\n+     rm B &&\n+     git checkout -b quiet topic &&\n+     git rebase -q master > output.out 2>&1 &&\n+     test ! -s output.out\n+'\n+\n test_done\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 51c369a..a12bf84 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -180,6 +180,17 @@ test_expect_success 'am -3 falls back to 3-way merge' '\n \ttest -z \"$(git diff lorem)\"\n '\n \n+test_expect_success 'am -3 -q is quiet' '\n+\tgit reset master2 --hard &&\n+\tsed -n -e \"3,\\$p\" msg >file &&\n+\thead -n 9 msg >>file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m \"copied stuff\" &&\n+\tgit am -3 -q lorem-move.patch > output.out 2>&1 &&\n+\t! test -s output.out\n+'\n+\n test_expect_success 'am pauses on conflict' '\n \tgit checkout lorem2^^ &&\n \ttest_must_fail git am lorem-move.patch &&\n@@ -313,4 +324,11 @@ test_expect_success 'am newline in subject' '\n \tgrep \"^Applying: second \\\\\\n foo$\" output.out\n '\n \n+test_expect_success 'am -q is quiet' '\n+\tgit checkout first &&\n+\ttest_tick &&\n+\tgit am -q < patch1 > output.out 2>&1 &&\n+\t! test -s output.out\n+'\n+\n test_done\n-- \n1.6.3.2.306.g4f4fa\n"},{"id":"116517","messageId":"1245287257-18186-1-git-send-email-bebarino@gmail.com","threadId":"19824","inReplyTo":"1245191581-11127-6-git-send-email-bebarino@gmail.com","subject":"[PATCHv4 6/5] stash: teach quiet option","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-06-18T01:07:37Z","receivedAt":"2009-06-18T01:07:37Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Teach stash pop, apply, save, and drop to be quiet when told. By using\nthe quiet option (-q), these actions will be silent unless errors are\nencountered.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n Documentation/git-stash.txt |   15 ++++----\n git-stash.sh                |   78 +++++++++++++++++++++++++++++++++---------\n t/t3903-stash.sh            |   23 +++++++++++++\n 3 files changed, 92 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex a42d4c8..1c64a02 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -9,10 +9,11 @@ SYNOPSIS\n --------\n [verse]\n 'git stash' list [<options>]\n-'git stash' ( show | drop ) [<stash>]\n-'git stash' ( pop | apply ) [--index] [<stash>]\n+'git stash' show [<stash>]\n+'git stash' drop [-q|--quiet] [<stash>]\n+'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]\n 'git stash' branch <branchname> [<stash>]\n-'git stash' [save [--keep-index] [<message>]]\n+'git stash' [save [--keep-index] [-q|--quiet] [<message>]]\n 'git stash' clear\n 'git stash' create\n \n@@ -41,7 +42,7 @@ is also possible).\n OPTIONS\n -------\n \n-save [--keep-index] [<message>]::\n+save [--keep-index] [-q|--quiet] [<message>]::\n \n \tSave your local modifications to a new 'stash', and run `git reset\n \t--hard` to revert them.  This is the default action when no\n@@ -75,7 +76,7 @@ show [<stash>]::\n \tit will accept any format known to 'git-diff' (e.g., `git stash show\n \t-p stash@\\{1}` to view the second most recent stash in patch form).\n \n-pop [<stash>]::\n+pop [--index] [-q|--quiet] [<stash>]::\n \n \tRemove a single stashed state from the stash list and apply it\n \ton top of the current working tree state, i.e., do the inverse\n@@ -93,7 +94,7 @@ longer apply the changes as they were originally).\n +\n When no `<stash>` is given, `stash@\\{0}` is assumed.\n \n-apply [--index] [<stash>]::\n+apply [--index] [-q|--quiet] [<stash>]::\n \n \tLike `pop`, but do not remove the state from the stash list.\n \n@@ -115,7 +116,7 @@ clear::\n \tRemove all the stashed states. Note that those states will then\n \tbe subject to pruning, and may be difficult or impossible to recover.\n \n-drop [<stash>]::\n+drop [-q|--quiet] [<stash>]::\n \n \tRemove a single stashed state from the stash list. When no `<stash>`\n \tis given, it removes the latest one. i.e. `stash@\\{0}`\ndiff --git a/git-stash.sh b/git-stash.sh\nindex e6a5867..531c7c3 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -3,10 +3,11 @@\n \n dashless=$(basename \"$0\" | sed -e 's/-/ /')\n USAGE=\"list [<options>]\n-   or: $dashless ( show | drop ) [<stash>]\n-   or: $dashless ( pop | apply ) [--index] [<stash>]\n+   or: $dashless show [<stash>]\n+   or: $dashless drop [-q|--quiet] [<stash>]\n+   or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]\n    or: $dashless branch <branchname> [<stash>]\n-   or: $dashless [save [--keep-index] [<message>]]\n+   or: $dashless [save [--keep-index] [-q|--quiet] [<message>]]\n    or: $dashless clear\"\n \n SUBDIRECTORY_OK=Yes\n@@ -94,18 +95,28 @@ create_stash () {\n \n save_stash () {\n \tkeep_index=\n-\tcase \"$1\" in\n-\t--keep-index)\n-\t\tkeep_index=t\n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--keep-index)\n+\t\t\tkeep_index=t\n+\t\t\t;;\n+\t\t-q|--quiet)\n+\t\t\tGIT_QUIET=t\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n \t\tshift\n-\tesac\n+\tdone\n \n \tstash_msg=\"$*\"\n \n \tgit update-index -q --refresh\n \tif no_changes\n \tthen\n-\t\techo 'No local changes to save'\n+\t\tsay 'No local changes to save'\n \t\texit 0\n \tfi\n \ttest -f \"$GIT_DIR/logs/$ref_stash\" ||\n@@ -118,9 +129,9 @@ save_stash () {\n \n \tgit update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n \t\tdie \"Cannot save the current status\"\n-\tprintf 'Saved working directory and index state \"%s\"\\n' \"$stash_msg\"\n+\tsay Saved working directory and index state \"$stash_msg\"\n \n-\tgit reset --hard\n+\tgit reset --hard ${GIT_QUIET:+-q}\n \n \tif test -n \"$keep_index\" && test -n $i_tree\n \tthen\n@@ -156,11 +167,22 @@ apply_stash () {\n \t\tdie 'Cannot apply to a dirty working tree, please stage your changes'\n \n \tunstash_index=\n-\tcase \"$1\" in\n-\t--index)\n-\t\tunstash_index=t\n+\n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--index)\n+\t\t\tunstash_index=t\n+\t\t\t;;\n+\t\t-q|--quiet)\n+\t\t\tGIT_QUIET=t\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n \t\tshift\n-\tesac\n+\tdone\n \n \t# current index state\n \tc_tree=$(git write-tree) ||\n@@ -193,6 +215,10 @@ apply_stash () {\n \t\texport GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree\n \t\"\n \n+\tif test -n \"$GIT_QUIET\"\n+\tthen\n+\t\texport GIT_MERGE_VERBOSITY=0\n+\tfi\n \tif git-merge-recursive $b_tree -- $c_tree $w_tree\n \tthen\n \t\t# No conflict\n@@ -207,7 +233,12 @@ apply_stash () {\n \t\t\t\tdie \"Cannot unstage modified files\"\n \t\t\trm -f \"$a\"\n \t\tfi\n-\t\tgit status || :\n+\t\tsquelch=\n+\t\tif test -n \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tsquelch='>/dev/null 2>&1'\n+\t\tfi\n+\t\teval \"git status $squelch\" || :\n \telse\n \t\t# Merge conflict; keep the exit status from merge-recursive\n \t\tstatus=$?\n@@ -222,6 +253,19 @@ apply_stash () {\n drop_stash () {\n \thave_stash || die 'No stash entries to drop'\n \n+\twhile test $# != 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t-q|--quiet)\n+\t\t\tGIT_QUIET=t\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+\n \tif test $# = 0\n \tthen\n \t\tset x \"$ref_stash@{0}\"\n@@ -235,7 +279,7 @@ drop_stash () {\n \t\tdie \"$*: not a valid stashed state\"\n \n \tgit reflog delete --updateref --rewrite \"$@\" &&\n-\t\techo \"Dropped $* ($s)\" || die \"$*: Could not drop stash entry\"\n+\t\tsay \"Dropped $* ($s)\" || die \"$*: Could not drop stash entry\"\n \n \t# clear_stash if we just dropped the last stash entry\n \tgit rev-parse --verify \"$ref_stash@{0}\" > /dev/null 2>&1 || clear_stash\n@@ -312,7 +356,7 @@ branch)\n \tif test $# -eq 0\n \tthen\n \t\tsave_stash &&\n-\t\techo '(To restore them type \"git stash apply\")'\n+\t\tsay '(To restore them type \"git stash apply\")'\n \telse\n \t\tusage\n \tfi\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 7484cbe..7a3fb67 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -177,4 +177,27 @@ test_expect_success 'stash branch' '\n \ttest 0 = $(git stash list | wc -l)\n '\n \n+test_expect_success 'apply -q is quiet' '\n+\techo foo > file &&\n+\tgit stash &&\n+\tgit stash apply -q > output.out 2>&1 &&\n+\ttest ! -s output.out\n+'\n+\n+test_expect_success 'save -q is quiet' '\n+\tgit stash save --quiet > output.out 2>&1 &&\n+\ttest ! -s output.out\n+'\n+\n+test_expect_success 'pop -q is quiet' '\n+\tgit stash pop -q > output.out 2>&1 &&\n+\ttest ! -s output.out\n+'\n+\n+test_expect_success 'drop -q is quiet' '\n+\tgit stash &&\n+\tgit stash drop -q > output.out 2>&1 &&\n+\ttest ! -s output.out\n+'\n+\n test_done\n-- \n1.6.3.2.306.g4f4fa\n"}]}