add a quiet option to git-checkout
Those new messages are certainly nice, but there might be cases where they are simply unwelcome, like when git-commit is used within scripts. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Feb 1, 2007 at 12:31 UTC
6124aee5d903150a649a75bf51a68b4bdfd67140
2 files changed
+18
-10
Documentation/git-checkout.txt
+4
-1
@@ -8,7 +8,7 @@ git-checkout - Checkout and switch to a branch
8
SYNOPSIS
9
--------
10
[verse]
11
-'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>]
11
+'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>]
12
'git-checkout' [<tree-ish>] <paths>...
13
14
DESCRIPTION
@@ -33,6 +33,9 @@ working tree.
33
34
OPTIONS
35
-------
36
+-q::
37
+ Quiet, supress feedback messages.
38
+
39
-f::
40
Force a re-read of everything.
41
git-checkout.sh
+14
-9
@@ -1,6 +1,6 @@
1
#!/bin/sh
2
3
-USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
3
+USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
4
SUBDIRECTORY_OK=Sometimes
5
. git-sh-setup
6
require_work_tree
@@ -15,6 +15,7 @@ branch=
15
newbranch=
16
newbranch_log=
17
merge=
18
+quiet=
19
LF='
20
'
21
while [ "$#" != "0" ]; do
@@ -40,6 +41,9 @@ while [ "$#" != "0" ]; do
41
-m)
42
merge=1
43
;;
44
+ "-q")
45
+ quiet=1
46
+ ;;
47
--)
48
break
49
;;
@@ -153,7 +157,7 @@ detach_warn=
157
if test -z "$branch$newbranch" && test "$new" != "$old"
158
then
159
detached="$new"
156
- if test -n "$oldbranch"
160
+ if test -n "$oldbranch" && test -z "$quiet"
161
then
162
detach_warn="Note: moving to \"$new_name\" which isn't a local branch
163
If you want to create a new branch from this checkout, you may do so
@@ -180,8 +184,11 @@ fi
184
185
if [ "X$old" = X ]
186
then
183
- echo >&2 "warning: You appear to be on a branch yet to be born."
184
- echo >&2 "warning: Forcing checkout of $new_name."
187
+ if test -z "$quiet"
188
+ then
189
+ echo >&2 "warning: You appear to be on a branch yet to be born."
190
+ echo >&2 "warning: Forcing checkout of $new_name."
191
+ fi
192
force=1
193
fi
194
@@ -226,7 +233,7 @@ else
233
exit 0
234
)
235
saved_err=$?
229
- if test "$saved_err" = 0
236
+ if test "$saved_err" = 0 && test -z "$quiet"
237
then
238
git diff-index --name-status "$new"
239
fi
@@ -251,11 +258,9 @@ if [ "$?" -eq 0 ]; then
258
if test -n "$branch"
259
then
260
GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD "refs/heads/$branch"
254
- if test -n "$newbranch"
261
+ if test -z "$quiet"
262
then
256
- echo >&2 "Switched to a new branch \"$branch\""
257
- else
258
- echo >&2 "Switched to branch \"$branch\""
263
+ echo >&2 "Switched to${newbranch:+ a new} branch \"$branch\""
264
fi
265
elif test -n "$detached"
266
then