Merge branch 'sb/quiet-porcelains'

* sb/quiet-porcelains:
  stash: teach quiet option
  am, rebase: teach quiet option
  submodule, repack: migrate to git-sh-setup's say()
  git-sh-setup: introduce say() for quiet options
  am: suppress apply errors when using 3-way
  t4150: test applying with a newline in subject
This commit is contained in:
Junio C Hamano 2009-07-01 19:40:50 -07:00
commit e6c7c2cc97
12 changed files with 225 additions and 74 deletions

View File

@ -13,7 +13,7 @@ SYNOPSIS
[--3way] [--interactive] [--committer-date-is-author-date] [--3way] [--interactive] [--committer-date-is-author-date]
[--ignore-date] [--ignore-date]
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>] [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
[--reject] [--reject] [-q | --quiet]
[<mbox> | <Maildir>...] [<mbox> | <Maildir>...]
'git am' (--skip | --resolved | --abort) 'git am' (--skip | --resolved | --abort)
@ -39,6 +39,10 @@ OPTIONS
--keep:: --keep::
Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]). Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
-q::
--quiet::
Be quiet. Only print error messages.
-u:: -u::
--utf8:: --utf8::
Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]). Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).

View File

@ -236,6 +236,10 @@ OPTIONS
is used instead ('git-merge-recursive' when merging a single is used instead ('git-merge-recursive' when merging a single
head, 'git-merge-octopus' otherwise). This implies --merge. head, 'git-merge-octopus' otherwise). This implies --merge.
-q::
--quiet::
Be quiet. Implies --no-stat.
-v:: -v::
--verbose:: --verbose::
Be verbose. Implies --stat. Be verbose. Implies --stat.

View File

@ -9,10 +9,11 @@ SYNOPSIS
-------- --------
[verse] [verse]
'git stash' list [<options>] 'git stash' list [<options>]
'git stash' ( show | drop ) [<stash>] 'git stash' show [<stash>]
'git stash' ( pop | apply ) [--index] [<stash>] 'git stash' drop [-q|--quiet] [<stash>]
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
'git stash' branch <branchname> [<stash>] 'git stash' branch <branchname> [<stash>]
'git stash' [save [--keep-index] [<message>]] 'git stash' [save [--keep-index] [-q|--quiet] [<message>]]
'git stash' clear 'git stash' clear
'git stash' create 'git stash' create
@ -41,7 +42,7 @@ is also possible).
OPTIONS OPTIONS
------- -------
save [--keep-index] [<message>]:: save [--keep-index] [-q|--quiet] [<message>]::
Save your local modifications to a new 'stash', and run `git reset Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no --hard` to revert them. This is the default action when no
@ -75,7 +76,7 @@ show [<stash>]::
it will accept any format known to 'git-diff' (e.g., `git stash show it will accept any format known to 'git-diff' (e.g., `git stash show
-p stash@\{1}` to view the second most recent stash in patch form). -p stash@\{1}` to view the second most recent stash in patch form).
pop [<stash>]:: pop [--index] [-q|--quiet] [<stash>]::
Remove a single stashed state from the stash list and apply it Remove a single stashed state from the stash list and apply it
on top of the current working tree state, i.e., do the inverse on top of the current working tree state, i.e., do the inverse
@ -93,7 +94,7 @@ longer apply the changes as they were originally).
+ +
When no `<stash>` is given, `stash@\{0}` is assumed. When no `<stash>` is given, `stash@\{0}` is assumed.
apply [--index] [<stash>]:: apply [--index] [-q|--quiet] [<stash>]::
Like `pop`, but do not remove the state from the stash list. Like `pop`, but do not remove the state from the stash list.
@ -115,7 +116,7 @@ clear::
Remove all the stashed states. Note that those states will then Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover. be subject to pruning, and may be difficult or impossible to recover.
drop [<stash>]:: drop [-q|--quiet] [<stash>]::
Remove a single stashed state from the stash list. When no `<stash>` Remove a single stashed state from the stash list. When no `<stash>`
is given, it removes the latest one. i.e. `stash@\{0}` is given, it removes the latest one. i.e. `stash@\{0}`

View File

@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)
i,interactive run interactively i,interactive run interactively
b,binary* (historical option -- no-op) b,binary* (historical option -- no-op)
3,3way allow fall back on 3way merging if needed 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 s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default) u,utf8 recode into utf8 (default)
k,keep pass -k flag to git-mailinfo k,keep pass -k flag to git-mailinfo
@ -99,7 +100,7 @@ fall_back_3way () {
git write-tree >"$dotest/patch-merge-base+" || git write-tree >"$dotest/patch-merge-base+" ||
cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge." 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" \ if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
git apply --cached <"$dotest/patch" git apply --cached <"$dotest/patch"
then then
@ -115,7 +116,7 @@ It does not apply to blobs recorded in its index."
orig_tree=$(cat "$dotest/patch-merge-base") && orig_tree=$(cat "$dotest/patch-merge-base") &&
rm -fr "$dotest"/patch-merge-* || exit 1 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, # This is not so wrong. Depending on which base we picked,
# orig_tree may be wildly different from ours, but his_tree # 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"' eval GITHEAD_$his_tree='"$FIRSTLINE"'
export GITHEAD_$his_tree 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-merge-recursive $orig_tree -- HEAD $his_tree || {
git rerere git rerere
echo Failed to merge in the changes. echo Failed to merge in the changes.
@ -181,6 +186,8 @@ do
committer_date_is_author_date=t ;; committer_date_is_author_date=t ;;
--ignore-date) --ignore-date)
ignore_date=t ;; ignore_date=t ;;
-q|--quiet)
GIT_QUIET=t ;;
--) --)
shift; break ;; shift; break ;;
*) *)
@ -279,7 +286,7 @@ else
exit 1 exit 1
} }
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept # -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept
# for the resuming session after a patch failure. # for the resuming session after a patch failure.
# -i can and must be given when resuming. # -i can and must be given when resuming.
echo " $git_apply_opt" >"$dotest/apply-opt" echo " $git_apply_opt" >"$dotest/apply-opt"
@ -287,6 +294,7 @@ else
echo "$sign" >"$dotest/sign" echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8" echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep" echo "$keep" >"$dotest/keep"
echo "$GIT_QUIET" >"$dotest/quiet"
echo 1 >"$dotest/next" echo 1 >"$dotest/next"
if test -n "$rebasing" if test -n "$rebasing"
then then
@ -327,6 +335,10 @@ if test "$(cat "$dotest/keep")" = t
then then
keep=-k keep=-k
fi fi
if test "$(cat "$dotest/quiet")" = t
then
GIT_QUIET=t
fi
if test "$(cat "$dotest/threeway")" = t if test "$(cat "$dotest/threeway")" = t
then then
threeway=t threeway=t
@ -352,7 +364,7 @@ fi
if test "$this" -gt "$last" if test "$this" -gt "$last"
then then
echo Nothing to do. say Nothing to do.
rm -fr "$dotest" rm -fr "$dotest"
exit exit
fi fi
@ -498,11 +510,18 @@ do
stop_here $this stop_here $this
fi fi
printf 'Applying: %s\n' "$FIRSTLINE" say "Applying: $FIRSTLINE"
case "$resolved" in case "$resolved" in
'') '')
eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"' # When we are allowed to fall back to 3-way later, don't give
# false errors during the initial attempt.
squelch=
if test "$threeway" = t
then
squelch='>/dev/null 2>&1 '
fi
eval "git apply $squelch$git_apply_opt"' --index "$dotest/patch"'
apply_status=$? apply_status=$?
;; ;;
t) t)
@ -534,7 +553,7 @@ do
# Applying the patch to an earlier tree and merging the # Applying the patch to an earlier tree and merging the
# result may have produced the same tree as ours. # result may have produced the same tree as ours.
git diff-index --quiet --cached HEAD -- && { git diff-index --quiet --cached HEAD -- && {
echo No changes -- Patch already applied. say No changes -- Patch already applied.
go_next go_next
continue continue
} }
@ -560,7 +579,7 @@ do
GIT_AUTHOR_DATE= GIT_AUTHOR_DATE=
fi fi
parent=$(git rev-parse --verify -q HEAD) || parent=$(git rev-parse --verify -q HEAD) ||
echo >&2 "applying to an empty history" say >&2 "applying to an empty history"
if test -n "$committer_date_is_author_date" if test -n "$committer_date_is_author_date"
then then

View File

@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano. # 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 LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts 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> out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@ -72,11 +72,20 @@ continue_merge () {
echo "directly, but instead do one of the following: " echo "directly, but instead do one of the following: "
die "$RESOLVEMSG" die "$RESOLVEMSG"
fi fi
printf "Committed: %0${prec}d " $msgnum if test -z "$GIT_QUIET"
then
printf "Committed: %0${prec}d " $msgnum
fi
else else
printf "Already applied: %0${prec}d " $msgnum if test -z "$GIT_QUIET"
then
printf "Already applied: %0${prec}d " $msgnum
fi
fi
if test -z "$GIT_QUIET"
then
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
fi fi
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
prev_head=`git rev-parse HEAD^0` prev_head=`git rev-parse HEAD^0`
# save the resulting commit so we can read-tree on it later # save the resulting commit so we can read-tree on it later
@ -97,6 +106,10 @@ call_merge () {
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
eval GITHEAD_$hd='$(cat "$dotest/onto_name")' eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
export GITHEAD_$cmt GITHEAD_$hd export GITHEAD_$cmt GITHEAD_$hd
if test -n "$GIT_QUIET"
then
export GIT_MERGE_VERBOSITY=1
fi
git-merge-$strategy "$cmt^" -- "$hd" "$cmt" git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
rv=$? rv=$?
case "$rv" in case "$rv" in
@ -138,7 +151,7 @@ move_to_original_branch () {
finish_rb_merge () { finish_rb_merge () {
move_to_original_branch move_to_original_branch
rm -r "$dotest" rm -r "$dotest"
echo "All done." say All done.
} }
is_interactive () { is_interactive () {
@ -207,6 +220,7 @@ do
end=$(cat "$dotest/end") end=$(cat "$dotest/end")
msgnum=$(cat "$dotest/msgnum") msgnum=$(cat "$dotest/msgnum")
onto=$(cat "$dotest/onto") onto=$(cat "$dotest/onto")
GIT_QUIET=$(cat "$dotest/quiet")
continue_merge continue_merge
while test "$msgnum" -le "$end" while test "$msgnum" -le "$end"
do do
@ -219,6 +233,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) && onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" && git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch move_to_original_branch
exit exit
@ -236,6 +251,7 @@ do
msgnum=$(cat "$dotest/msgnum") msgnum=$(cat "$dotest/msgnum")
msgnum=$(($msgnum + 1)) msgnum=$(($msgnum + 1))
onto=$(cat "$dotest/onto") onto=$(cat "$dotest/onto")
GIT_QUIET=$(cat "$dotest/quiet")
while test "$msgnum" -le "$end" while test "$msgnum" -le "$end"
do do
call_merge "$msgnum" call_merge "$msgnum"
@ -247,6 +263,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) && head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) && onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) && orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" && git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch move_to_original_branch
exit exit
@ -258,9 +275,11 @@ do
git rerere clear git rerere clear
if test -d "$dotest" if test -d "$dotest"
then then
GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch move_to_original_branch
else else
dotest="$GIT_DIR"/rebase-apply dotest="$GIT_DIR"/rebase-apply
GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch move_to_original_branch
fi fi
git reset --hard $(cat "$dotest/orig-head") git reset --hard $(cat "$dotest/orig-head")
@ -298,6 +317,13 @@ do
-v|--verbose) -v|--verbose)
verbose=t verbose=t
diffstat=t diffstat=t
GIT_QUIET=
;;
-q|--quiet)
GIT_QUIET=t
git_am_opt="$git_am_opt -q"
verbose=
diffstat=
;; ;;
--whitespace=*) --whitespace=*)
git_am_opt="$git_am_opt $1" git_am_opt="$git_am_opt $1"
@ -442,15 +468,15 @@ then
then then
# Lazily switch to the target branch if needed... # Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to" test -z "$switch_to" || git checkout "$switch_to"
echo >&2 "Current branch $branch_name is up to date." say "Current branch $branch_name is up to date."
exit 0 exit 0
else 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
fi fi
# Detach HEAD and reset the tree # 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 checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $branch git update-ref ORIG_HEAD $branch
@ -468,7 +494,7 @@ fi
# we just fast forwarded. # we just fast forwarded.
if test "$mb" = "$branch" if test "$mb" = "$branch"
then then
echo >&2 "Fast-forwarded $branch_name to $onto_name." say "Fast-forwarded $branch_name to $onto_name."
move_to_original_branch move_to_original_branch
exit 0 exit 0
fi fi
@ -490,7 +516,8 @@ then
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply && test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
echo $head_name > "$GIT_DIR"/rebase-apply/head-name && echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
echo $onto > "$GIT_DIR"/rebase-apply/onto && echo $onto > "$GIT_DIR"/rebase-apply/onto &&
echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head &&
echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet
exit $ret exit $ret
fi fi
@ -504,6 +531,7 @@ prev_head=$orig_head
echo "$prev_head" > "$dotest/prev_head" echo "$prev_head" > "$dotest/prev_head"
echo "$orig_head" > "$dotest/orig-head" echo "$orig_head" > "$dotest/orig-head"
echo "$head_name" > "$dotest/head-name" echo "$head_name" > "$dotest/head-name"
echo "$GIT_QUIET" > "$dotest/quiet"
msgnum=0 msgnum=0
for cmt in `git rev-list --reverse --no-merges "$revisions"` for cmt in `git rev-list --reverse --no-merges "$revisions"`

View File

@ -24,7 +24,7 @@ SUBDIRECTORY_OK='Yes'
. git-sh-setup . git-sh-setup
no_update_info= all_into_one= remove_redundant= unpack_unreachable= no_update_info= all_into_one= remove_redundant= unpack_unreachable=
local= quiet= no_reuse= extra= local= no_reuse= extra=
while test $# != 0 while test $# != 0
do do
case "$1" in case "$1" in
@ -33,7 +33,7 @@ do
-A) all_into_one=t -A) all_into_one=t
unpack_unreachable=--unpack-unreachable ;; unpack_unreachable=--unpack-unreachable ;;
-d) remove_redundant=t ;; -d) remove_redundant=t ;;
-q) quiet=-q ;; -q) GIT_QUIET=t ;;
-f) no_reuse=--no-reuse-object ;; -f) no_reuse=--no-reuse-object ;;
-l) local=--local ;; -l) local=--local ;;
--max-pack-size|--window|--window-memory|--depth) --max-pack-size|--window|--window-memory|--depth)
@ -80,13 +80,11 @@ case ",$all_into_one," in
;; ;;
esac esac
args="$args $local $quiet $no_reuse$extra" args="$args $local ${GIT_QUIET:+-q} $no_reuse$extra"
names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") || names=$(git pack-objects --honor-pack-keep --non-empty --all --reflog $args </dev/null "$PACKTMP") ||
exit 1 exit 1
if [ -z "$names" ]; then if [ -z "$names" ]; then
if test -z "$quiet"; then say Nothing new to pack.
echo Nothing new to pack.
fi
fi fi
# Ok we have prepared all new packfiles. # Ok we have prepared all new packfiles.
@ -176,7 +174,7 @@ then
done done
) )
fi fi
git prune-packed $quiet git prune-packed ${GIT_QUIET:+-q}
fi fi
case "$no_update_info" in case "$no_update_info" in

View File

@ -44,6 +44,15 @@ die() {
exit 1 exit 1
} }
GIT_QUIET=
say () {
if test -z "$GIT_QUIET"
then
printf '%s\n' "$*"
fi
}
if test -n "$OPTIONS_SPEC"; then if test -n "$OPTIONS_SPEC"; then
usage() { usage() {
"$0" -h "$0" -h

View File

@ -3,10 +3,11 @@
dashless=$(basename "$0" | sed -e 's/-/ /') dashless=$(basename "$0" | sed -e 's/-/ /')
USAGE="list [<options>] USAGE="list [<options>]
or: $dashless ( show | drop ) [<stash>] or: $dashless show [<stash>]
or: $dashless ( pop | apply ) [--index] [<stash>] or: $dashless drop [-q|--quiet] [<stash>]
or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
or: $dashless branch <branchname> [<stash>] or: $dashless branch <branchname> [<stash>]
or: $dashless [save [--keep-index] [<message>]] or: $dashless [save [--keep-index] [-q|--quiet] [<message>]]
or: $dashless clear" or: $dashless clear"
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
@ -94,18 +95,28 @@ create_stash () {
save_stash () { save_stash () {
keep_index= keep_index=
case "$1" in while test $# != 0
--keep-index) do
keep_index=t case "$1" in
--keep-index)
keep_index=t
;;
-q|--quiet)
GIT_QUIET=t
;;
*)
break
;;
esac
shift shift
esac done
stash_msg="$*" stash_msg="$*"
git update-index -q --refresh git update-index -q --refresh
if no_changes if no_changes
then then
echo 'No local changes to save' say 'No local changes to save'
exit 0 exit 0
fi fi
test -f "$GIT_DIR/logs/$ref_stash" || test -f "$GIT_DIR/logs/$ref_stash" ||
@ -118,9 +129,9 @@ save_stash () {
git update-ref -m "$stash_msg" $ref_stash $w_commit || git update-ref -m "$stash_msg" $ref_stash $w_commit ||
die "Cannot save the current status" die "Cannot save the current status"
printf 'Saved working directory and index state "%s"\n' "$stash_msg" say Saved working directory and index state "$stash_msg"
git reset --hard git reset --hard ${GIT_QUIET:+-q}
if test -n "$keep_index" && test -n $i_tree if test -n "$keep_index" && test -n $i_tree
then then
@ -156,11 +167,22 @@ apply_stash () {
die 'Cannot apply to a dirty working tree, please stage your changes' die 'Cannot apply to a dirty working tree, please stage your changes'
unstash_index= unstash_index=
case "$1" in
--index) while test $# != 0
unstash_index=t do
case "$1" in
--index)
unstash_index=t
;;
-q|--quiet)
GIT_QUIET=t
;;
*)
break
;;
esac
shift shift
esac done
# current index state # current index state
c_tree=$(git write-tree) || c_tree=$(git write-tree) ||
@ -193,6 +215,10 @@ apply_stash () {
export GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree export GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree
" "
if test -n "$GIT_QUIET"
then
export GIT_MERGE_VERBOSITY=0
fi
if git-merge-recursive $b_tree -- $c_tree $w_tree if git-merge-recursive $b_tree -- $c_tree $w_tree
then then
# No conflict # No conflict
@ -207,7 +233,12 @@ apply_stash () {
die "Cannot unstage modified files" die "Cannot unstage modified files"
rm -f "$a" rm -f "$a"
fi fi
git status || : squelch=
if test -n "$GIT_QUIET"
then
squelch='>/dev/null 2>&1'
fi
eval "git status $squelch" || :
else else
# Merge conflict; keep the exit status from merge-recursive # Merge conflict; keep the exit status from merge-recursive
status=$? status=$?
@ -222,6 +253,19 @@ apply_stash () {
drop_stash () { drop_stash () {
have_stash || die 'No stash entries to drop' have_stash || die 'No stash entries to drop'
while test $# != 0
do
case "$1" in
-q|--quiet)
GIT_QUIET=t
;;
*)
break
;;
esac
shift
done
if test $# = 0 if test $# = 0
then then
set x "$ref_stash@{0}" set x "$ref_stash@{0}"
@ -235,7 +279,7 @@ drop_stash () {
die "$*: not a valid stashed state" die "$*: not a valid stashed state"
git reflog delete --updateref --rewrite "$@" && git reflog delete --updateref --rewrite "$@" &&
echo "Dropped $* ($s)" || die "$*: Could not drop stash entry" say "Dropped $* ($s)" || die "$*: Could not drop stash entry"
# clear_stash if we just dropped the last stash entry # clear_stash if we just dropped the last stash entry
git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
@ -312,7 +356,7 @@ branch)
if test $# -eq 0 if test $# -eq 0
then then
save_stash && save_stash &&
echo '(To restore them type "git stash apply")' say '(To restore them type "git stash apply")'
else else
usage usage
fi fi

View File

@ -14,23 +14,11 @@ require_work_tree
command= command=
branch= branch=
quiet=
reference= reference=
cached= cached=
nofetch= nofetch=
update= 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 by appending to parent's url
resolve_relative_url () resolve_relative_url ()
{ {
@ -137,7 +125,7 @@ cmd_add()
shift shift
;; ;;
-q|--quiet) -q|--quiet)
quiet=1 GIT_QUIET=1
;; ;;
--reference) --reference)
case "$2" in '') usage ;; esac case "$2" in '') usage ;; esac
@ -273,7 +261,7 @@ cmd_init()
do do
case "$1" in case "$1" in
-q|--quiet) -q|--quiet)
quiet=1 GIT_QUIET=1
;; ;;
--) --)
shift shift
@ -333,7 +321,7 @@ cmd_update()
case "$1" in case "$1" in
-q|--quiet) -q|--quiet)
shift shift
quiet=1 GIT_QUIET=1
;; ;;
-i|--init) -i|--init)
init=1 init=1
@ -659,7 +647,7 @@ cmd_status()
do do
case "$1" in case "$1" in
-q|--quiet) -q|--quiet)
quiet=1 GIT_QUIET=1
;; ;;
--cached) --cached)
cached=1 cached=1
@ -713,7 +701,7 @@ cmd_sync()
do do
case "$1" in case "$1" in
-q|--quiet) -q|--quiet)
quiet=1 GIT_QUIET=1
shift shift
;; ;;
--) --)
@ -768,7 +756,7 @@ do
command=$1 command=$1
;; ;;
-q|--quiet) -q|--quiet)
quiet=1 GIT_QUIET=1
;; ;;
-b|--branch) -b|--branch)
case "$2" in case "$2" in

View File

@ -54,8 +54,8 @@ test_expect_success 'rebase against master' '
git rebase master' git rebase master'
test_expect_success 'rebase against master twice' ' test_expect_success 'rebase against master twice' '
git rebase master 2>err && git rebase master >out &&
grep "Current branch my-topic-branch is up to date" err grep "Current branch my-topic-branch is up to date" out
' '
test_expect_success 'rebase against master twice with --force' ' test_expect_success 'rebase against master twice with --force' '
@ -65,14 +65,14 @@ test_expect_success 'rebase against master twice with --force' '
test_expect_success 'rebase against master twice from another branch' ' test_expect_success 'rebase against master twice from another branch' '
git checkout my-topic-branch^ && git checkout my-topic-branch^ &&
git rebase master my-topic-branch 2>err && git rebase master my-topic-branch >out &&
grep "Current branch my-topic-branch is up to date" err grep "Current branch my-topic-branch is up to date" out
' '
test_expect_success 'rebase fast-forward to master' ' test_expect_success 'rebase fast-forward to master' '
git checkout my-topic-branch^ && git checkout my-topic-branch^ &&
git rebase my-topic-branch 2>err && git rebase my-topic-branch >out &&
grep "Fast-forwarded HEAD to my-topic-branch" err grep "Fast-forwarded HEAD to my-topic-branch" out
' '
test_expect_success \ test_expect_success \
@ -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 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 2>&1 &&
test ! -s output.out
'
test_done test_done

View File

@ -177,4 +177,27 @@ test_expect_success 'stash branch' '
test 0 = $(git stash list | wc -l) test 0 = $(git stash list | wc -l)
' '
test_expect_success 'apply -q is quiet' '
echo foo > file &&
git stash &&
git stash apply -q > output.out 2>&1 &&
test ! -s output.out
'
test_expect_success 'save -q is quiet' '
git stash save --quiet > output.out 2>&1 &&
test ! -s output.out
'
test_expect_success 'pop -q is quiet' '
git stash pop -q > output.out 2>&1 &&
test ! -s output.out
'
test_expect_success 'drop -q is quiet' '
git stash &&
git stash drop -q > output.out 2>&1 &&
test ! -s output.out
'
test_done test_done

View File

@ -180,6 +180,17 @@ test_expect_success 'am -3 falls back to 3-way merge' '
test -z "$(git diff lorem)" test -z "$(git diff lorem)"
' '
test_expect_success 'am -3 -q is quiet' '
git reset master2 --hard &&
sed -n -e "3,\$p" msg >file &&
head -n 9 msg >>file &&
git add file &&
test_tick &&
git commit -m "copied stuff" &&
git am -3 -q lorem-move.patch > output.out 2>&1 &&
! test -s output.out
'
test_expect_success 'am pauses on conflict' ' test_expect_success 'am pauses on conflict' '
git checkout lorem2^^ && git checkout lorem2^^ &&
test_must_fail git am lorem-move.patch && test_must_fail git am lorem-move.patch &&
@ -305,4 +316,19 @@ test_expect_success 'am into an unborn branch' '
test "z$result" = "z$(git rev-parse first^{tree})" test "z$result" = "z$(git rev-parse first^{tree})"
' '
test_expect_success 'am newline in subject' '
git checkout first &&
test_tick &&
sed -e "s/second/second \\\n foo/" patch1 > patchnl &&
git am < patchnl > output.out 2>&1 &&
grep "^Applying: second \\\n foo$" output.out
'
test_expect_success 'am -q is quiet' '
git checkout first &&
test_tick &&
git am -q < patch1 > output.out 2>&1 &&
! test -s output.out
'
test_done test_done