{"thread":{"id":"12049","subject":"[Bug] git-status shows bad instructions prior to first commit","startedAt":"2008-02-12T00:59:39Z","lastAt":"2008-02-13T22:02:20Z","messageCount":4,"participants":["Rhodes, Kate","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"68470","messageId":"F1B5775C-1C11-4C30-B72E-9EB4076613A5@gmail.com","threadId":"12049","inReplyTo":null,"subject":"[Bug] git-status shows bad instructions prior to first commit","fromName":"Rhodes, Kate","fromEmail":"masukomi@gmail.com","sentAt":"2008-02-12T00:59:39Z","receivedAt":"2008-02-12T00:59:39Z","isPatch":false,"sender":{"key":"masukomi@gmail.com","avatar":null},"body":"git-status incorrectly reports that you should\n\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n\n\nwhen working on the Initial commit.\n\nTo reproduce\nmkdir foo\ncd foo\ntouch a.txt\ngit init\ngit add a.txt\ngit status\n\n\nThe problem is, obviously, that calling\ngit reset HEAD a.txt\nwill result in\nfatal: Failed to resolve 'HEAD' as a valid ref.\n\nWhy this is important:\nNew users are Going to accidentally add files they didn't mean to in  \ntheir first trials with Git. Providing instructions guaranteed to  \nerror when people are just getting started with it will give git a bad  \nimage and hurt adoption. Also,  just about every time I've added a  \nsizable project to a new version control system I've accidentally  \nadded a file before the first commit, usually something that should be  \nadded to the ignore file, but still, I think this isn't some random  \nisolated problem that people never encounter.\n\nWhile we're at it, can someone please explain to me how to remove a  \nfile from the index prior to the first commit? I'm stumped.\n\n-masukomi\n"},{"id":"68481","messageId":"7vzlu66f5g.fsf@gitster.siamese.dyndns.org","threadId":"12049","inReplyTo":"F1B5775C-1C11-4C30-B72E-9EB4076613A5@gmail.com","subject":"Re: [Bug] git-status shows bad instructions prior to first commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-12T03:13:15Z","receivedAt":"2008-02-12T03:13:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Rhodes, Kate\" <masukomi@gmail.com> writes:\n\n> While we're at it, can someone please explain to me how to remove a\n> file from the index prior to the first commit? I'm stumped.\n\nrm --cached\n"},{"id":"68484","messageId":"20080212054518.GA24817@sigill.intra.peff.net","threadId":"12049","inReplyTo":"7vzlu66f5g.fsf@gitster.siamese.dyndns.org","subject":"Re: [Bug] git-status shows bad instructions prior to first commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-02-12T05:45:18Z","receivedAt":"2008-02-12T05:45:18Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 11, 2008 at 07:13:15PM -0800, Junio C Hamano wrote:\n\n> \"Rhodes, Kate\" <masukomi@gmail.com> writes:\n> \n> > While we're at it, can someone please explain to me how to remove a\n> > file from the index prior to the first commit? I'm stumped.\n> \n> rm --cached\n\nAnd indeed, some clever person already made this distinction in the\ngit-status output, but it has been broken for a while. I'm not sure this\nis worth a test now that it is fixed (but such a test _would_ have\ncaught this); I can make one if you like.\n\n-- >8 --\nstatus: suggest \"git rm --cached\" to unstage for initial commit\n\nIt makes no sense to suggest \"git reset HEAD\" since we have\nno HEAD commit. This actually used to work but regressed in\nf26a0012.\n\nwt_status_print_cached_header was updated to take the whole\nwt_status struct rather than just the reference field.\nPreviously the various code paths were sometimes sending in\ns->reference and sometimes sending in NULL, making the\ndecision on whether this was an initial commit before we\neven got to this function. Now we must check the initial\nflag here.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n wt-status.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 27b946d..b5ae98d 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -60,7 +60,7 @@ static void wt_status_print_cached_header(struct wt_status *s)\n {\n \tconst char *c = color(WT_STATUS_HEADER);\n \tcolor_fprintf_ln(s->fp, c, \"# Changes to be committed:\");\n-\tif (s->reference) {\n+\tif (!s->is_initial) {\n \t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git reset %s <file>...\\\" to unstage)\", s->reference);\n \t} else {\n \t\tcolor_fprintf_ln(s->fp, c, \"#   (use \\\"git rm --cached <file>...\\\" to unstage)\");\n-- \n1.5.4.1215.gf7da-dirty\n"},{"id":"68677","messageId":"7vodako6qb.fsf@gitster.siamese.dyndns.org","threadId":"12049","inReplyTo":"20080212054518.GA24817@sigill.intra.peff.net","subject":"Re: [Bug] git-status shows bad instructions prior to first commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-13T22:02:20Z","receivedAt":"2008-02-13T22:02:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> status: suggest \"git rm --cached\" to unstage for initial commit\n>\n> It makes no sense to suggest \"git reset HEAD\" since we have\n> no HEAD commit. This actually used to work but regressed in\n> f26a0012.\n\nIn order to avoid regressing again, we must have something like\nthis included in your change, which I squashed in.\n\nThis goes to 'maint'.  Thanks for the fix.\n\n t/t7502-status.sh |   11 ++++++++++-\n 1 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7502-status.sh b/t/t7502-status.sh\nindex 9ce50ca..b64ce30 100755\n--- a/t/t7502-status.sh\n+++ b/t/t7502-status.sh\n@@ -17,6 +17,9 @@ test_expect_success 'setup' '\n \t: > dir1/tracked &&\n \t: > dir1/modified &&\n \tgit add . &&\n+\n+\tgit status >output &&\n+\n \ttest_tick &&\n \tgit commit -m initial &&\n \t: > untracked &&\n@@ -28,6 +31,12 @@ test_expect_success 'setup' '\n \tgit add dir2/added\n '\n \n+test_expect_success 'status (1)' '\n+\n+\tgrep -e \"use \\\"git rm --cached <file>\\.\\.\\.\\\" to unstage\" output\n+\n+'\n+\n cat > expect << \\EOF\n # On branch master\n # Changes to be committed:\n@@ -51,7 +60,7 @@ cat > expect << \\EOF\n #\tuntracked\n EOF\n \n-test_expect_success 'status' '\n+test_expect_success 'status (2)' '\n \n \tgit status > output &&\n \tgit diff expect output\n"}]}