git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] am: teach quiet option
Date: Sat, 13 Jun 2009 13:21:39 -0700	[thread overview]
Message-ID: <1244924500-27391-2-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <1244924500-27391-1-git-send-email-bebarino@gmail.com>

git-rebase will use this when invoked with -q.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
 Documentation/git-am.txt |    6 +++++-
 git-am.sh                |   27 ++++++++++++++++++++++-----
 t/t4150-am.sh            |    7 +++++++
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 6d92cbe..32e689b 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -13,7 +13,7 @@ SYNOPSIS
 	 [--3way] [--interactive] [--committer-date-is-author-date]
 	 [--ignore-date]
 	 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
-	 [--reject]
+	 [--reject] [-q | --quiet]
 	 [<mbox> | <Maildir>...]
 'git am' (--skip | --resolved | --abort)
 
@@ -39,6 +39,10 @@ OPTIONS
 --keep::
 	Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
 
+-q::
+--quiet::
+	Be quiet. Only print error messages.
+
 -u::
 --utf8::
 	Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
diff --git a/git-am.sh b/git-am.sh
index 578780b..f04aca5 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)
 i,interactive   run interactively
 b,binary*       (historical option -- no-op)
 3,3way          allow fall back on 3way merging if needed
+q,quiet         be quiet
 s,signoff       add a Signed-off-by line to the commit message
 u,utf8          recode into utf8 (default)
 k,keep          pass -k flag to git-mailinfo
@@ -52,6 +53,16 @@ stop_here () {
     exit 1
 }
 
+quiet=
+
+say ()
+{
+    if test -z "$quiet"
+    then
+	echo $@
+    fi
+}
+
 stop_here_user_resolve () {
     if [ -n "$resolvemsg" ]; then
 	    printf '%s\n' "$resolvemsg"
@@ -99,7 +110,7 @@ fall_back_3way () {
     git write-tree >"$dotest/patch-merge-base+" ||
     cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
 
-    echo Using index info to reconstruct a base tree...
+    say Using index info to reconstruct a base tree...
     if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
 	git apply --cached <"$dotest/patch"
     then
@@ -115,7 +126,7 @@ It does not apply to blobs recorded in its index."
     orig_tree=$(cat "$dotest/patch-merge-base") &&
     rm -fr "$dotest"/patch-merge-* || exit 1
 
-    echo Falling back to patching base and 3-way merge...
+    say Falling back to patching base and 3-way merge...
 
     # This is not so wrong.  Depending on which base we picked,
     # orig_tree may be wildly different from ours, but his_tree
@@ -125,6 +136,10 @@ It does not apply to blobs recorded in its index."
 
     eval GITHEAD_$his_tree='"$FIRSTLINE"'
     export GITHEAD_$his_tree
+    if test -n "$quiet"
+    then
+	    export GIT_MERGE_VERBOSITY=0
+    fi
     git-merge-recursive $orig_tree -- HEAD $his_tree || {
 	    git rerere
 	    echo Failed to merge in the changes.
@@ -181,6 +196,8 @@ do
 		committer_date_is_author_date=t ;;
 	--ignore-date)
 		ignore_date=t ;;
+	-q|--quiet)
+		quiet=t ;;
 	--)
 		shift; break ;;
 	*)
@@ -352,7 +369,7 @@ fi
 
 if test "$this" -gt "$last"
 then
-	echo Nothing to do.
+	say Nothing to do.
 	rm -fr "$dotest"
 	exit
 fi
@@ -498,7 +515,7 @@ do
 		stop_here $this
 	fi
 
-	printf 'Applying: %s\n' "$FIRSTLINE"
+	say "Applying: $FIRSTLINE"
 
 	case "$resolved" in
 	'')
@@ -534,7 +551,7 @@ do
 		    # Applying the patch to an earlier tree and merging the
 		    # result may have produced the same tree as ours.
 		    git diff-index --quiet --cached HEAD -- && {
-			echo No changes -- Patch already applied.
+			say No changes -- Patch already applied.
 			go_next
 			continue
 		    }
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index d6ebbae..f8725a9 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -305,4 +305,11 @@ test_expect_success 'am into an unborn branch' '
 	test "z$result" = "z$(git rev-parse first^{tree})"
 '
 
+test_expect_success 'am -q is quiet' '
+	git checkout first &&
+	test_tick &&
+	git am -q <patch1 > output.out &&
+	test ! -s output.out
+'
+
 test_done
-- 
1.6.3.2.225.gb8364

  reply	other threads:[~2009-06-13 20:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
2009-06-13 20:21 ` Stephen Boyd [this message]
2009-06-13 20:21   ` [PATCH 2/2] rebase: teach quiet option Stephen Boyd
2009-06-13 23:05 ` [PATCH 0/2] teach am and rebase -q/--quiet Junio C Hamano
2009-06-14  7:07   ` Stephen Boyd
2009-06-14  8:27   ` Sverre Rabbelier
2009-06-13 23:07 ` Junio C Hamano
2009-06-14  7:16   ` Stephen Boyd
2009-06-14  8:24     ` Junio C Hamano
2009-06-14 23:16 ` [PATCHv2 0/3] Teach shell scripts to be quiet Stephen Boyd
2009-06-14 23:16   ` [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options Stephen Boyd
2009-06-14 23:16     ` [PATCHv2 2/3] submodule, repack: migrate to git-sh-setup's say() Stephen Boyd
2009-06-14 23:16       ` [PATCHv2 3/3] am, rebase: teach quiet option Stephen Boyd
2009-06-14 23:21     ` [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options Thomas Adam
2009-06-15  4:23       ` Junio C Hamano
2009-06-15  6:15         ` Stephen Boyd
2009-06-15  6:25     ` Johannes Sixt
2009-06-15  6:33       ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1244924500-27391-2-git-send-email-bebarino@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).