* [PATCH 0/2] teach am and rebase -q/--quiet
@ 2009-06-13 20:21 Stephen Boyd
2009-06-13 20:21 ` [PATCH 1/2] am: teach quiet option Stephen Boyd
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-13 20:21 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
am and rebase are talkative scripts. Teach them to be less verbose.
This is useful for script writers incorporating rebase or am into
their scripts.
I am not sure why "current branch $branch is up to date" and
"Fast-forwarded $branch to $onto" is echoed to stderr, but I've
wrapped those in a quiet check because it doesn't seem to be
an error. Maybe those should be changed to stdout?
Stephen Boyd (2):
am: teach quiet option
rebase: teach quiet option
Documentation/git-am.txt | 6 ++++-
Documentation/git-rebase.txt | 4 +++
git-am.sh | 27 ++++++++++++++++++----
git-rebase.sh | 49 ++++++++++++++++++++++++++++++++---------
t/t3400-rebase.sh | 7 ++++++
t/t4150-am.sh | 7 ++++++
6 files changed, 83 insertions(+), 17 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/2] am: teach quiet option
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
@ 2009-06-13 20:21 ` Stephen Boyd
2009-06-13 20:21 ` [PATCH 2/2] rebase: " Stephen Boyd
2009-06-13 23:05 ` [PATCH 0/2] teach am and rebase -q/--quiet Junio C Hamano
` (2 subsequent siblings)
3 siblings, 1 reply; 18+ messages in thread
From: Stephen Boyd @ 2009-06-13 20:21 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/2] rebase: teach quiet option
2009-06-13 20:21 ` [PATCH 1/2] am: teach quiet option Stephen Boyd
@ 2009-06-13 20:21 ` Stephen Boyd
0 siblings, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-13 20:21 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
This is useful for scripts using rebase. Instead of redirecting to
/dev/null, the script writers can just use -q
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Documentation/git-rebase.txt | 4 +++
git-rebase.sh | 49 ++++++++++++++++++++++++++++++++---------
t/t3400-rebase.sh | 7 ++++++
3 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 26f3b7b..db1b71d 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -236,6 +236,10 @@ OPTIONS
is used instead ('git-merge-recursive' when merging a single
head, 'git-merge-octopus' otherwise). This implies --merge.
+-q::
+--quiet::
+ Be quiet. Implies --no-stat.
+
-v::
--verbose::
Be verbose. Implies --stat.
diff --git a/git-rebase.sh b/git-rebase.sh
index b83fd3f..9a39f0f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -46,11 +46,20 @@ do_merge=
dotest="$GIT_DIR"/rebase-merge
prec=4
verbose=
+quiet=
diffstat=$(git config --bool rebase.stat)
git_am_opt=
rebase_root=
force_rebase=
+say ()
+{
+ if test -z "$quiet"
+ then
+ echo $@
+ fi
+}
+
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
test -d "$dotest" || die "$dotest directory does not exist"
@@ -72,9 +81,15 @@ continue_merge () {
echo "directly, but instead do one of the following: "
die "$RESOLVEMSG"
fi
- printf "Committed: %0${prec}d " $msgnum
+ if test -z "$quiet"
+ then
+ printf "Committed: %0${prec}d " $msgnum
+ fi
else
- printf "Already applied: %0${prec}d " $msgnum
+ if test -z "$quiet"
+ then
+ printf "Already applied: %0${prec}d " $msgnum
+ fi
fi
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
@@ -138,7 +153,7 @@ move_to_original_branch () {
finish_rb_merge () {
move_to_original_branch
rm -r "$dotest"
- echo "All done."
+ say "All done."
}
is_interactive () {
@@ -221,7 +236,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
+ git am --resolved $quiet --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
@@ -249,7 +264,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
+ git am -3 --skip $quiet --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
@@ -300,6 +315,12 @@ do
-v|--verbose)
verbose=t
diffstat=t
+ quiet=
+ ;;
+ -q|--quiet)
+ quiet="-q"
+ verbose=
+ diffstat=
;;
--whitespace=*)
git_am_opt="$git_am_opt $1"
@@ -445,15 +466,18 @@ then
then
# Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to"
- echo >&2 "Current branch $branch_name is up to date."
+ if test -z "$quiet"
+ then
+ echo >&2 "Current branch $branch_name is up to date."
+ fi
exit 0
else
- echo "Current branch $branch_name is up to date, rebase forced."
+ say "Current branch $branch_name is up to date, rebase forced."
fi
fi
# Detach HEAD and reset the tree
-echo "First, rewinding head to replay your work on top of it..."
+say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $branch
@@ -471,7 +495,10 @@ fi
# we just fast forwarded.
if test "$mb" = "$branch"
then
- echo >&2 "Fast-forwarded $branch_name to $onto_name."
+ if test -z "$quiet"
+ then
+ echo >&2 "Fast-forwarded $branch_name to $onto_name."
+ fi
move_to_original_branch
exit 0
fi
@@ -487,7 +514,7 @@ if test -z "$do_merge"
then
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
$root_flag "$revisions" |
- git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
+ git am $git_am_opt $quiet --rebasing --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
ret=$?
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 7f62bfb..9456b2f 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -126,4 +126,11 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
grep "Untracked working tree file .B. would be overwritten" output.err
'
+test_expect_success 'rebase -q is quiet' '
+ rm B &&
+ git checkout -b quiet topic &&
+ git rebase -q master > output.out &&
+ test ! -s output.out
+'
+
test_done
--
1.6.3.2.225.gb8364
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
2009-06-13 20:21 ` [PATCH 1/2] am: teach quiet option Stephen Boyd
@ 2009-06-13 23:05 ` 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 23:16 ` [PATCHv2 0/3] Teach shell scripts to be quiet Stephen Boyd
3 siblings, 2 replies; 18+ messages in thread
From: Junio C Hamano @ 2009-06-13 23:05 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git
Stephen Boyd <bebarino@gmail.com> writes:
> I am not sure why "current branch $branch is up to date" and
> "Fast-forwarded $branch to $onto" is echoed to stderr, but I've
> wrapped those in a quiet check because it doesn't seem to be
> an error. Maybe those should be changed to stdout?
There are many valid cases where it makes sense to use stderr for messages
that are not errors (e.g. diagnostics, prompts, progress reports, and
informational messages that otherwise would clutter machine parsable
output meant to go to stdout).
I do not understand why some people seem to think stderr is only for
errors. I think we even saw a broken interpretive language environment
where the system considers it an error if a program it launched said
anything to stderr, instead of correctly diagnosing the exit status from
it?
It is a disease.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
2009-06-13 20:21 ` [PATCH 1/2] am: teach quiet option Stephen Boyd
2009-06-13 23:05 ` [PATCH 0/2] teach am and rebase -q/--quiet Junio C Hamano
@ 2009-06-13 23:07 ` Junio C Hamano
2009-06-14 7:16 ` Stephen Boyd
2009-06-14 23:16 ` [PATCHv2 0/3] Teach shell scripts to be quiet Stephen Boyd
3 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2009-06-13 23:07 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git
Perhaps you would want to do the same for "stash apply/pop" that runs "git
status", listing untracked files and whatnot?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
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
1 sibling, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 7:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
> There are many valid cases where it makes sense to use stderr for messages
> that are not errors (e.g. diagnostics, prompts, progress reports, and
> informational messages that otherwise would clutter machine parsable
> output meant to go to stdout).
>
> I do not understand why some people seem to think stderr is only for
> errors. I think we even saw a broken interpretive language environment
> where the system considers it an error if a program it launched said
> anything to stderr, instead of correctly diagnosing the exit status from
> it?
>
> It is a disease.
>
If I understand you correctly, wrapping them in quiet checks is fine.
Also, thanks for the explanation. I'll consider my self inoculated.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
2009-06-13 23:07 ` Junio C Hamano
@ 2009-06-14 7:16 ` Stephen Boyd
2009-06-14 8:24 ` Junio C Hamano
0 siblings, 1 reply; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 7:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
> Perhaps you would want to do the same for "stash apply/pop" that runs "git
> status", listing untracked files and whatnot?
This sounds fine for a follow up, or even a v2. I'm curious though,
would adding say() to git-sh-setup be a good idea? Otherwise I'll be
adding a say function another time.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
2009-06-14 7:16 ` Stephen Boyd
@ 2009-06-14 8:24 ` Junio C Hamano
0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2009-06-14 8:24 UTC (permalink / raw)
To: Stephen Boyd; +Cc: Junio C Hamano, git
Stephen Boyd <bebarino@gmail.com> writes:
> Junio C Hamano wrote:
>> Perhaps you would want to do the same for "stash apply/pop" that runs "git
>> status", listing untracked files and whatnot?
>
> This sounds fine for a follow up, or even a v2.
Yeah, I should have been clearer that I was suggesting a follow-up, and
not even necessarily by you.
> I'm curious though,
> would adding say() to git-sh-setup be a good idea?
We have die(); I'd say why not say() ;-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] teach am and rebase -q/--quiet
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
1 sibling, 0 replies; 18+ messages in thread
From: Sverre Rabbelier @ 2009-06-14 8:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Stephen Boyd, git
Heya,
On Sun, Jun 14, 2009 at 01:05, Junio C Hamano<gitster@pobox.com> wrote:
> Stephen Boyd <bebarino@gmail.com> writes:
> I do not understand why some people seem to think stderr is only for
> errors.
The name might be setting people off? ;)
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCHv2 0/3] Teach shell scripts to be quiet
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
` (2 preceding siblings ...)
2009-06-13 23:07 ` Junio C Hamano
@ 2009-06-14 23:16 ` Stephen Boyd
2009-06-14 23:16 ` [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options Stephen Boyd
3 siblings, 1 reply; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 23:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
The main goal of this is to teach git-am and git-rebase to be
quiet. To do that, I've implemented a generic say function in
git-sh-setup so that script writers can implement a quiet
option by setting GIT_QUIET and using say instead of echo.
git-stash is still left out, but hopefully this makes that easier
for someone else later.
Changes since v1:
- introduction of say()
- migration of submodule and repack
Stephen Boyd (3):
git-sh-setup: introduce say() for quiet options
submodule, repack: migrate to git-sh-setup's say()
am, rebase: teach quiet option
Documentation/git-am.txt | 6 +++++-
Documentation/git-rebase.txt | 4 ++++
git-am.sh | 17 ++++++++++++-----
git-rebase.sh | 40 +++++++++++++++++++++++++++++-----------
git-repack.sh | 12 +++++-------
git-sh-setup.sh | 7 +++++++
git-submodule.sh | 24 ++++++------------------
t/t3400-rebase.sh | 7 +++++++
t/t4150-am.sh | 7 +++++++
9 files changed, 82 insertions(+), 42 deletions(-)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
2009-06-14 23:16 ` [PATCHv2 0/3] Teach shell scripts to be quiet Stephen Boyd
@ 2009-06-14 23:16 ` Stephen Boyd
2009-06-14 23:16 ` [PATCHv2 2/3] submodule, repack: migrate to git-sh-setup's say() Stephen Boyd
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 23:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Scripts should use say() when they want to echo to stdout. Setting
GIT_QUIET will mute say(), allowing scripts to easily implement a quiet
option.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
git-sh-setup.sh | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 80acb7d..f88184e 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -44,6 +44,13 @@ die() {
exit 1
}
+say () {
+ if test -z "$GIT_QUIET"
+ then
+ echo "$@"
+ fi
+}
+
if test -n "$OPTIONS_SPEC"; then
usage() {
"$0" -h
--
1.6.3.2.306.g4f4fa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCHv2 2/3] submodule, repack: migrate to git-sh-setup's say()
2009-06-14 23:16 ` [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options Stephen Boyd
@ 2009-06-14 23:16 ` 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 6:25 ` Johannes Sixt
2 siblings, 1 reply; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 23:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Now that there is say() in git-sh-setup, these scripts don't need to use
their own. Migrate them over by setting GIT_QUIET and removing their
custom say() functions.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
git-repack.sh | 12 +++++-------
git-submodule.sh | 24 ++++++------------------
2 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/git-repack.sh b/git-repack.sh
index 0868734..efb527c 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -24,7 +24,7 @@ SUBDIRECTORY_OK='Yes'
. git-sh-setup
no_update_info= all_into_one= remove_redundant= unpack_unreachable=
-local= quiet= no_reuse= extra=
+local= no_reuse= extra=
while test $# != 0
do
case "$1" in
@@ -33,7 +33,7 @@ do
-A) all_into_one=t
unpack_unreachable=--unpack-unreachable ;;
-d) remove_redundant=t ;;
- -q) quiet=-q ;;
+ -q) GIT_QUIET=-q ;;
-f) no_reuse=--no-reuse-object ;;
-l) local=--local ;;
--max-pack-size|--window|--window-memory|--depth)
@@ -80,13 +80,11 @@ case ",$all_into_one," in
;;
esac
-args="$args $local $quiet $no_reuse$extra"
+args="$args $local $GIT_QUIET $no_reuse$extra"
names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
exit 1
if [ -z "$names" ]; then
- if test -z "$quiet"; then
- echo Nothing new to pack.
- fi
+ say Nothing new to pack.
fi
# Ok we have prepared all new packfiles.
@@ -176,7 +174,7 @@ then
done
)
fi
- git prune-packed $quiet
+ git prune-packed $GIT_QUIET
fi
case "$no_update_info" in
diff --git a/git-submodule.sh b/git-submodule.sh
index 19a3a84..58d2fd2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -14,23 +14,11 @@ require_work_tree
command=
branch=
-quiet=
reference=
cached=
nofetch=
update=
-#
-# print stuff on stdout unless -q was specified
-#
-say()
-{
- if test -z "$quiet"
- then
- echo "$@"
- fi
-}
-
# Resolve relative url by appending to parent's url
resolve_relative_url ()
{
@@ -137,7 +125,7 @@ cmd_add()
shift
;;
-q|--quiet)
- quiet=1
+ GIT_QUIET=1
;;
--reference)
case "$2" in '') usage ;; esac
@@ -273,7 +261,7 @@ cmd_init()
do
case "$1" in
-q|--quiet)
- quiet=1
+ GIT_QUIET=1
;;
--)
shift
@@ -333,7 +321,7 @@ cmd_update()
case "$1" in
-q|--quiet)
shift
- quiet=1
+ GIT_QUIET=1
;;
-i|--init)
init=1
@@ -650,7 +638,7 @@ cmd_status()
do
case "$1" in
-q|--quiet)
- quiet=1
+ GIT_QUIET=1
;;
--cached)
cached=1
@@ -704,7 +692,7 @@ cmd_sync()
do
case "$1" in
-q|--quiet)
- quiet=1
+ GIT_QUIET=1
shift
;;
--)
@@ -759,7 +747,7 @@ do
command=$1
;;
-q|--quiet)
- quiet=1
+ GIT_QUIET=1
;;
-b|--branch)
case "$2" in
--
1.6.3.2.306.g4f4fa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCHv2 3/3] am, rebase: teach quiet option
2009-06-14 23:16 ` [PATCHv2 2/3] submodule, repack: migrate to git-sh-setup's say() Stephen Boyd
@ 2009-06-14 23:16 ` Stephen Boyd
0 siblings, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-14 23:16 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
git-rebase and git-am are talkative scripts. This option will quiet
them and allow them to speak only when they fail or experience errors.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Documentation/git-am.txt | 6 +++++-
Documentation/git-rebase.txt | 4 ++++
git-am.sh | 17 ++++++++++++-----
git-rebase.sh | 40 +++++++++++++++++++++++++++++-----------
t/t3400-rebase.sh | 7 +++++++
t/t4150-am.sh | 7 +++++++
6 files changed, 64 insertions(+), 17 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/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 26f3b7b..db1b71d 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -236,6 +236,10 @@ OPTIONS
is used instead ('git-merge-recursive' when merging a single
head, 'git-merge-octopus' otherwise). This implies --merge.
+-q::
+--quiet::
+ Be quiet. Implies --no-stat.
+
-v::
--verbose::
Be verbose. Implies --stat.
diff --git a/git-am.sh b/git-am.sh
index 578780b..899ab83 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
@@ -99,7 +100,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 +116,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 +126,10 @@ It does not apply to blobs recorded in its index."
eval GITHEAD_$his_tree='"$FIRSTLINE"'
export GITHEAD_$his_tree
+ if test -n "$GIT_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 +186,8 @@ do
committer_date_is_author_date=t ;;
--ignore-date)
ignore_date=t ;;
+ -q|--quiet)
+ GIT_QUIET=t ;;
--)
shift; break ;;
*)
@@ -352,7 +359,7 @@ fi
if test "$this" -gt "$last"
then
- echo Nothing to do.
+ say Nothing to do.
rm -fr "$dotest"
exit
fi
@@ -498,7 +505,7 @@ do
stop_here $this
fi
- printf 'Applying: %s\n' "$FIRSTLINE"
+ say "Applying: $FIRSTLINE"
case "$resolved" in
'')
@@ -534,7 +541,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/git-rebase.sh b/git-rebase.sh
index b83fd3f..e6d44ff 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -72,9 +72,15 @@ continue_merge () {
echo "directly, but instead do one of the following: "
die "$RESOLVEMSG"
fi
- printf "Committed: %0${prec}d " $msgnum
+ if test -z "$GIT_QUIET"
+ then
+ printf "Committed: %0${prec}d " $msgnum
+ fi
else
- printf "Already applied: %0${prec}d " $msgnum
+ if test -z "$GIT_QUIET"
+ then
+ printf "Already applied: %0${prec}d " $msgnum
+ fi
fi
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
@@ -138,7 +144,7 @@ move_to_original_branch () {
finish_rb_merge () {
move_to_original_branch
rm -r "$dotest"
- echo "All done."
+ say "All done."
}
is_interactive () {
@@ -221,7 +227,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
+ git am --resolved $GIT_QUIET --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
@@ -249,7 +255,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
- git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
+ git am -3 --skip $GIT_QUIET --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
@@ -300,6 +306,12 @@ do
-v|--verbose)
verbose=t
diffstat=t
+ GIT_QUIET=
+ ;;
+ -q|--quiet)
+ GIT_QUIET="-q"
+ verbose=
+ diffstat=
;;
--whitespace=*)
git_am_opt="$git_am_opt $1"
@@ -445,15 +457,18 @@ then
then
# Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to"
- echo >&2 "Current branch $branch_name is up to date."
+ if test -z "$GIT_QUIET"
+ then
+ echo >&2 "Current branch $branch_name is up to date."
+ fi
exit 0
else
- echo "Current branch $branch_name is up to date, rebase forced."
+ say "Current branch $branch_name is up to date, rebase forced."
fi
fi
# Detach HEAD and reset the tree
-echo "First, rewinding head to replay your work on top of it..."
+say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $branch
@@ -471,7 +486,10 @@ fi
# we just fast forwarded.
if test "$mb" = "$branch"
then
- echo >&2 "Fast-forwarded $branch_name to $onto_name."
+ if test -z "$GIT_QUIET"
+ then
+ echo >&2 "Fast-forwarded $branch_name to $onto_name."
+ fi
move_to_original_branch
exit 0
fi
@@ -487,7 +505,7 @@ if test -z "$do_merge"
then
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
$root_flag "$revisions" |
- git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
+ git am $git_am_opt $GIT_QUIET --rebasing --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
ret=$?
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 7f62bfb..fe6445b 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -126,4 +126,11 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '
grep "Untracked working tree file .B. would be overwritten" output.err
'
+test_expect_success 'rebase -q is quiet' '
+ rm B &&
+ git checkout -b quiet topic &&
+ git rebase -q master > output.out &&
+ test ! -s output.out
+'
+
test_done
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.306.g4f4fa
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
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:21 ` Thomas Adam
2009-06-15 4:23 ` Junio C Hamano
2009-06-15 6:25 ` Johannes Sixt
2 siblings, 1 reply; 18+ messages in thread
From: Thomas Adam @ 2009-06-14 23:21 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git, Junio C Hamano
2009/6/15 Stephen Boyd <bebarino@gmail.com>:
> Scripts should use say() when they want to echo to stdout. Setting
> GIT_QUIET will mute say(), allowing scripts to easily implement a quiet
> option.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
> git-sh-setup.sh | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> index 80acb7d..f88184e 100755
> --- a/git-sh-setup.sh
> +++ b/git-sh-setup.sh
> @@ -44,6 +44,13 @@ die() {
> exit 1
> }
>
> +say () {
> + if test -z "$GIT_QUIET"
> + then
> + echo "$@"
Except that where you've then replaced various calls with say() they
were originally using printf. Please use printf here also, and not
echo.
-- Thomas Adam
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
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
0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2009-06-15 4:23 UTC (permalink / raw)
To: Thomas Adam; +Cc: Stephen Boyd, git
Thomas Adam <thomas.adam22@gmail.com> writes:
> 2009/6/15 Stephen Boyd <bebarino@gmail.com>:
>> Scripts should use say() when they want to echo to stdout. Setting
>> GIT_QUIET will mute say(), allowing scripts to easily implement a quiet
>> option.
>>
>> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
>> ---
>> git-sh-setup.sh | 7 +++++++
>> 1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
>> index 80acb7d..f88184e 100755
>> --- a/git-sh-setup.sh
>> +++ b/git-sh-setup.sh
>> @@ -44,6 +44,13 @@ die() {
>> exit 1
>> }
>>
>> +say () {
>> + if test -z "$GIT_QUIET"
>> + then
>> + echo "$@"
>
> Except that where you've then replaced various calls with say() they
> were originally using printf.
The only difference I found in these three patch series is this hunk on
git-am.sh in [PATCHv2 3/3]:
@@ -498,7 +505,7 @@ do
stop_here $this
fi
- printf 'Applying: %s\n' "$FIRSTLINE"
+ say "Applying: $FIRSTLINE"
case "$resolved" in
'')
This was made from echo to printf with 4b7cc26 (git-am: use printf instead
of echo on user-supplied strings, 2007-05-25), with reason:
Under some implementations of echo (such as that provided by
dash), backslash escapes are recognized without any other
options. This means that echo-ing user-supplied strings may
cause any backslash sequences in them to be converted. Using
printf resolves the ambiguity.
This bug can be seen when using git-am to apply a patch
whose subject contains the character sequence "\n"; the
characters are converted to a literal newline. Noticed by
Szekeres Istvan.
To make the conversion of the above hunk correct, say() must use
printf "%s" "$*"
Needless to say, all the conversions from "echo" to "say" in the patch
series need to be verified.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
2009-06-15 4:23 ` Junio C Hamano
@ 2009-06-15 6:15 ` Stephen Boyd
0 siblings, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-15 6:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Adam, git
On Sun, Jun 14, 2009 at 9:23 PM, Junio C Hamano<gitster@pobox.com> wrote:
>
> To make the conversion of the above hunk correct, say() must use
>
> printf "%s" "$*"
Thanks for the background information. This hunk was in the original
series but I guess nobody noticed. I'll fixup these issues in the next
round and maybe add a test for this case.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
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:21 ` [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options Thomas Adam
@ 2009-06-15 6:25 ` Johannes Sixt
2009-06-15 6:33 ` Stephen Boyd
2 siblings, 1 reply; 18+ messages in thread
From: Johannes Sixt @ 2009-06-15 6:25 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git, Junio C Hamano
Stephen Boyd schrieb:
> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> index 80acb7d..f88184e 100755
> --- a/git-sh-setup.sh
> +++ b/git-sh-setup.sh
> @@ -44,6 +44,13 @@ die() {
> exit 1
> }
>
> +say () {
> + if test -z "$GIT_QUIET"
> + then
> + echo "$@"
> + fi
> +}
Is it intended that this obeys any GIT_QUIET that appears in the
environment? If not, then you should add
GIT_QUIET=
here to override the environment.
-- Hannes
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options
2009-06-15 6:25 ` Johannes Sixt
@ 2009-06-15 6:33 ` Stephen Boyd
0 siblings, 0 replies; 18+ messages in thread
From: Stephen Boyd @ 2009-06-15 6:33 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, Junio C Hamano
On Sun, Jun 14, 2009 at 11:25 PM, Johannes Sixt<j.sixt@viscovery.net> wrote:
>
> Is it intended that this obeys any GIT_QUIET that appears in the
> environment?
I wasn't sure, therefore I left it up to interpretation. It's probably
better to just override the environment though.
Thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2009-06-15 6:34 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-13 20:21 [PATCH 0/2] teach am and rebase -q/--quiet Stephen Boyd
2009-06-13 20:21 ` [PATCH 1/2] am: teach quiet option Stephen Boyd
2009-06-13 20:21 ` [PATCH 2/2] rebase: " 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.