Re: [PATCHv5 1/3] wt-status.*: better advices for git status added

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Junio C Hamano <gitster@xxxxxxxxx> a écrit :

konglu@xxxxxxxxxxxxxxx writes:

+	} else {
+		status_printf_ln(s, color, _("You are currently editing a commit
during a rebase."));
+		if (advice_status_hints) {
+			status_printf_ln(s, color, _("  You can amend the commit with"));
+			status_printf_ln(s, color, _("	git commit --amend"));
+			status_printf_ln(s, color, _("  Once you are satisfied with
your changes, run"));
+			status_printf_ln(s, color, _("	git rebase --continue"));

For an advice in "git status" output, the above may be appropriate,
but would the user see this in "git commit" template, and if so,
isn't it because the user typed "git commit --amend"?  Does it make
sense to suggest to run "git commit --amend" in that context?

True, the user will see the messages in the "git commit" template. We
didn't take this case into account because we thought that not many people
read the status in the "git commit" template. Anyway, just adding a condition

if (advice_status_hints && !s->amend)

does the job.

Hrm, what would happen if the user ran "git commit" without --amend?

The new advices will still be displayed (of course only if advice.statushints
is enabled).

It could be done by mistake, which will be greatly helped by the
information you already gathered during the inspection phase.

Thus, if done by mistake, the user will know that he needs to do
"git commit --amend" to edit the commit.

This also can be done deliberately to split a commit in "rebase -i",
so "You are in 'rebase -i', do not commit without --amend!" is a
wrong message, but it may be sensible to give "are you sure you
meant to commit without --amend?"

An interesting case. In fact, more than warning the user about running
git commit without --amend, wouldn't it be better if there were specific
help messages about splitting a commit ? Like

# Not currently on any branch.
# You are currently splitting a commit.
#   (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   t/t7060-wtstatus.sh
#       modified:   t/t7512-status-help.sh
#       modified:   wt-status.c
#
no changes added to commit (use "git add" and/or "git commit -a")

that will be the output of git status after a "git reset HEAD^" during
a rebase -i. There's already the advice "(use git add <file>...)" so
putting it twice is not really relevant.

What do you think about it ?


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]