status: suggest "git rm --cached" to unstage for initial commit
It makes no sense to suggest "git reset HEAD" since we have
no HEAD commit. This actually used to work but regressed in
f26a0012
.
wt_status_print_cached_header was updated to take the whole
wt_status struct rather than just the reference field.
Previously the various code paths were sometimes sending in
s->reference and sometimes sending in NULL, making the
decision on whether this was an initial commit before we
even got to this function. Now we must check the initial
flag here.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
077b725f0b
commit
ff58b9aaf8
@ -17,6 +17,9 @@ test_expect_success 'setup' '
|
|||||||
: > dir1/tracked &&
|
: > dir1/tracked &&
|
||||||
: > dir1/modified &&
|
: > dir1/modified &&
|
||||||
git add . &&
|
git add . &&
|
||||||
|
|
||||||
|
git status >output &&
|
||||||
|
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m initial &&
|
git commit -m initial &&
|
||||||
: > untracked &&
|
: > untracked &&
|
||||||
@ -28,6 +31,12 @@ test_expect_success 'setup' '
|
|||||||
git add dir2/added
|
git add dir2/added
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status (1)' '
|
||||||
|
|
||||||
|
grep -e "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
cat > expect << \EOF
|
cat > expect << \EOF
|
||||||
# On branch master
|
# On branch master
|
||||||
# Changes to be committed:
|
# Changes to be committed:
|
||||||
@ -51,7 +60,7 @@ cat > expect << \EOF
|
|||||||
# untracked
|
# untracked
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'status' '
|
test_expect_success 'status (2)' '
|
||||||
|
|
||||||
git status > output &&
|
git status > output &&
|
||||||
git diff expect output
|
git diff expect output
|
||||||
|
@ -60,7 +60,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
|
|||||||
{
|
{
|
||||||
const char *c = color(WT_STATUS_HEADER);
|
const char *c = color(WT_STATUS_HEADER);
|
||||||
color_fprintf_ln(s->fp, c, "# Changes to be committed:");
|
color_fprintf_ln(s->fp, c, "# Changes to be committed:");
|
||||||
if (s->reference) {
|
if (!s->is_initial) {
|
||||||
color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
|
color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
|
||||||
} else {
|
} else {
|
||||||
color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
|
color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
|
||||||
|
Reference in New Issue
Block a user