Merge branch 'mg/status-v-v'

"git status" now allows the "-v" to be given twice to show the
differences that are left in the working tree not to be committed.

* mg/status-v-v:
  commit/status: show the index-worktree diff with -v -v
  t7508: test git status -v
  t7508: .gitignore 'expect' and 'output' files
This commit is contained in:
Junio C Hamano 2015-03-17 16:01:33 -07:00
commit 9bb56e4753
3 changed files with 60 additions and 67 deletions

View file

@ -284,6 +284,10 @@ configuration variable documented in linkgit:git-config[1].
would be committed at the bottom of the commit message
template. Note that this diff output doesn't have its
lines prefixed with '#'.
+
If specified twice, show in addition the unified diff between
what would be committed and the worktree files, i.e. the unstaged
changes to tracked files.
-q::
--quiet::

View file

@ -66,6 +66,12 @@ strip_comments () {
rm "$1" && mv "$1".tmp "$1"
}
cat >.gitignore <<\EOF
.gitignore
expect*
output*
EOF
test_expect_success 'status --column' '
cat >expect <<\EOF &&
# On branch master
@ -83,8 +89,8 @@ test_expect_success 'status --column' '
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# dir1/untracked dir2/untracked output
# dir2/modified expect untracked
# dir1/untracked dir2/untracked
# dir2/modified untracked
#
EOF
COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
@ -116,8 +122,6 @@ cat >expect <<\EOF
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
#
EOF
@ -133,6 +137,23 @@ test_expect_success 'status with status.displayCommentPrefix=false' '
test_i18ncmp expect output
'
test_expect_success 'status -v' '
(cat expect && git diff --cached) >expect-with-v &&
git status -v >output &&
test_i18ncmp expect-with-v output
'
test_expect_success 'status -v -v' '
(cat expect &&
echo "Changes to be committed:" &&
git -c diff.mnemonicprefix=true diff --cached &&
echo "--------------------------------------------------" &&
echo "Changes not staged for commit:" &&
git -c diff.mnemonicprefix=true diff) >expect-with-v &&
git status -v -v >output &&
test_i18ncmp expect-with-v output
'
test_expect_success 'setup fake editor' '
cat >.git/editor <<-\EOF &&
#! /bin/sh
@ -167,8 +188,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -186,8 +205,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
@ -201,7 +218,7 @@ test_expect_success 'status -s' '
test_expect_success 'status with gitignore' '
{
echo ".gitignore" &&
echo "expect" &&
echo "expect*" &&
echo "output" &&
echo "untracked"
} >.gitignore &&
@ -222,6 +239,7 @@ test_expect_success 'status with gitignore' '
!! dir1/untracked
!! dir2/untracked
!! expect
!! expect-with-v
!! output
!! untracked
EOF
@ -253,6 +271,7 @@ Ignored files:
dir1/untracked
dir2/untracked
expect
expect-with-v
output
untracked
@ -264,7 +283,7 @@ EOF
test_expect_success 'status with gitignore (nothing untracked)' '
{
echo ".gitignore" &&
echo "expect" &&
echo "expect*" &&
echo "dir2/modified" &&
echo "output" &&
echo "untracked"
@ -285,6 +304,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
!! dir2/modified
!! dir2/untracked
!! expect
!! expect-with-v
!! output
!! untracked
EOF
@ -312,6 +332,7 @@ Ignored files:
dir2/modified
dir2/untracked
expect
expect-with-v
output
untracked
@ -320,7 +341,11 @@ EOF
test_i18ncmp expect output
'
rm -f .gitignore
cat >.gitignore <<\EOF
.gitignore
expect*
output*
EOF
cat >expect <<\EOF
## master
@ -329,8 +354,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
@ -434,8 +457,6 @@ Untracked files:
dir2/modified
dir2/untracked
dir3/
expect
output
untracked
EOF
@ -456,8 +477,6 @@ A dir2/added
?? dir2/modified
?? dir2/untracked
?? dir3/
?? expect
?? output
?? untracked
EOF
test_expect_success 'status -s -unormal' '
@ -493,8 +512,6 @@ Untracked files:
dir2/untracked
dir3/untracked1
dir3/untracked2
expect
output
untracked
EOF
@ -518,8 +535,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
test_expect_success 'status -s -uall' '
@ -554,8 +569,6 @@ Untracked files:
untracked
../dir2/modified
../dir2/untracked
../expect
../output
../untracked
EOF
@ -569,8 +582,6 @@ A ../dir2/added
?? untracked
?? ../dir2/modified
?? ../dir2/untracked
?? ../expect
?? ../output
?? ../untracked
EOF
test_expect_success 'status -s with relative paths' '
@ -586,8 +597,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
@ -625,8 +634,6 @@ Untracked files:
<BLUE>dir1/untracked<RESET>
<BLUE>dir2/modified<RESET>
<BLUE>dir2/untracked<RESET>
<BLUE>expect<RESET>
<BLUE>output<RESET>
<BLUE>untracked<RESET>
EOF
@ -647,8 +654,6 @@ cat >expect <<\EOF
<BLUE>??<RESET> dir1/untracked
<BLUE>??<RESET> dir2/modified
<BLUE>??<RESET> dir2/untracked
<BLUE>??<RESET> expect
<BLUE>??<RESET> output
<BLUE>??<RESET> untracked
EOF
@ -676,8 +681,6 @@ cat >expect <<\EOF
<BLUE>??<RESET> dir1/untracked
<BLUE>??<RESET> dir2/modified
<BLUE>??<RESET> dir2/untracked
<BLUE>??<RESET> expect
<BLUE>??<RESET> output
<BLUE>??<RESET> untracked
EOF
@ -694,8 +697,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
@ -755,8 +756,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -772,8 +771,6 @@ A dir2/added
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
@ -798,8 +795,6 @@ Untracked files:
dir1/untracked
dir2/
expect
output
untracked
EOF
@ -848,8 +843,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -870,8 +863,6 @@ A sm
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
test_expect_success 'status -s submodule summary is disabled by default' '
@ -913,8 +904,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -940,8 +929,6 @@ A sm
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
test_expect_success 'status -s submodule summary' '
@ -964,8 +951,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
no changes added to commit (use "git add" and/or "git commit -a")
@ -983,8 +968,6 @@ cat >expect <<EOF
?? dir1/untracked
?? dir2/modified
?? dir2/untracked
?? expect
?? output
?? untracked
EOF
test_expect_success 'status -s submodule summary (clean submodule)' '
@ -1025,8 +1008,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -1080,8 +1061,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -1192,8 +1171,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -1254,8 +1231,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF
@ -1336,8 +1311,6 @@ cat > expect << EOF
; dir1/untracked
; dir2/modified
; dir2/untracked
; expect
; output
; untracked
;
EOF
@ -1369,8 +1342,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
no changes added to commit (use "git add" and/or "git commit -a")
@ -1400,8 +1371,6 @@ Untracked files:
dir1/untracked
dir2/modified
dir2/untracked
expect
output
untracked
EOF

View file

@ -849,6 +849,8 @@ static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
struct setup_revision_opt opt;
int dirty_submodules;
const char *c = color(WT_STATUS_HEADER, s);
init_revisions(&rev, NULL);
DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
@ -873,7 +875,25 @@ static void wt_status_print_verbose(struct wt_status *s)
rev.diffopt.use_color = 0;
wt_status_add_cut_line(s->fp);
}
if (s->verbose > 1 && s->commitable) {
/* print_updated() printed a header, so do we */
if (s->fp != stdout)
wt_status_print_trailer(s);
status_printf_ln(s, c, _("Changes to be committed:"));
rev.diffopt.a_prefix = "c/";
rev.diffopt.b_prefix = "i/";
} /* else use prefix as per user config */
run_diff_index(&rev, 1);
if (s->verbose > 1 &&
wt_status_check_worktree_changes(s, &dirty_submodules)) {
status_printf_ln(s, c,
"--------------------------------------------------");
status_printf_ln(s, c, _("Changes not staged for commit:"));
setup_work_tree();
rev.diffopt.a_prefix = "i/";
rev.diffopt.b_prefix = "w/";
run_diff_files(&rev, 0);
}
}
static void wt_status_print_tracking(struct wt_status *s)