Skip to content

Commit 46077fa

Browse files
Michael J Grubergitster
authored andcommitted
Documentation+t5708: document and test status -s -b
Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05a59a0 commit 46077fa

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

Documentation/git-status.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ OPTIONS
2727
--short::
2828
Give the output in the short-format.
2929

30+
-b::
31+
--branch::
32+
Show the branch and tracking info even in short-format.
33+
3034
--porcelain::
3135
Give the output in a stable, easy-to-parse format for scripts.
3236
Currently this is identical to --short output, but is guaranteed
@@ -120,6 +124,10 @@ Ignored files are not listed.
120124
? ? untracked
121125
-------------------------------------------------
122126

127+
If -b is used the short-format status is preceded by a line
128+
129+
## branchname tracking info
130+
123131
There is an alternate -z format recommended for machine parsing. In
124132
that format, the status field is the same, but some other things
125133
change. First, the '->' is omitted from rename entries and the field
@@ -128,7 +136,7 @@ order is reversed (e.g 'from -> to' becomes 'to from'). Second, a NUL
128136
and the terminating newline (but a space still separates the status
129137
field from the first filename). Third, filenames containing special
130138
characters are not specially formatted; no quoting or
131-
backslash-escaping is performed.
139+
backslash-escaping is performed. Fourth, there is no branch line.
132140

133141
CONFIGURATION
134142
-------------

t/t7508-status.sh

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,32 @@ A dir2/added
107107
?? untracked
108108
EOF
109109

110-
test_expect_success 'status -s (2)' '
110+
test_expect_success 'status -s' '
111111
112112
git status -s >output &&
113113
test_cmp expect output
114114
115115
'
116116

117+
cat >expect <<\EOF
118+
## master
119+
M dir1/modified
120+
A dir2/added
121+
?? dir1/untracked
122+
?? dir2/modified
123+
?? dir2/untracked
124+
?? expect
125+
?? output
126+
?? untracked
127+
EOF
128+
129+
test_expect_success 'status -s -b' '
130+
131+
git status -s -b >output &&
132+
test_cmp expect output
133+
134+
'
135+
117136
cat >expect <<EOF
118137
# On branch master
119138
# Changes to be committed:
@@ -436,6 +455,25 @@ test_expect_success 'status -s with color.status' '
436455
437456
'
438457

458+
cat >expect <<\EOF
459+
## <GREEN>master<RESET>
460+
<RED>M<RESET> dir1/modified
461+
<GREEN>A<RESET> dir2/added
462+
<BLUE>??<RESET> dir1/untracked
463+
<BLUE>??<RESET> dir2/modified
464+
<BLUE>??<RESET> dir2/untracked
465+
<BLUE>??<RESET> expect
466+
<BLUE>??<RESET> output
467+
<BLUE>??<RESET> untracked
468+
EOF
469+
470+
test_expect_success 'status -s -b with color.status' '
471+
472+
git status -s -b | test_decode_color >output &&
473+
test_cmp expect output
474+
475+
'
476+
439477
cat >expect <<\EOF
440478
M dir1/modified
441479
A dir2/added
@@ -469,6 +507,13 @@ test_expect_success 'status --porcelain ignores color.status' '
469507
git config --unset color.status
470508
git config --unset color.ui
471509

510+
test_expect_success 'status --porcelain ignores -b' '
511+
512+
git status --porcelain -b >output &&
513+
test_cmp expect output
514+
515+
'
516+
472517
cat >expect <<\EOF
473518
# On branch master
474519
# Changes to be committed:

0 commit comments

Comments
 (0)