summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorLucien Kong <Lucien.Kong@ensimag.imag.fr>2012-06-05 20:21:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-06-14 17:15:19 (GMT)
commit96b0ec1a4c3cafd17bc397c9ac836950c316dab6 (patch)
tree3aa766c75682669370119da624300399d34e0e4e /wt-status.c
parent708192637e7d48bfff49c08cdd7cd6e4b052ac32 (diff)
downloadgit-96b0ec1a4c3cafd17bc397c9ac836950c316dab6.zip
git-96b0ec1a4c3cafd17bc397c9ac836950c316dab6.tar.gz
git-96b0ec1a4c3cafd17bc397c9ac836950c316dab6.tar.bz2
status: don't suggest "git rm" or "git add" if not appropriate
The display of the advice '(use git add/rm [...])' (when there are unmerged files) after running 'git status' is now depending of the mark, whether it's 'both deleted', 'deleted by us/them' or others. For instance, when there is just one file that's marked as 'both deleted', 'git status' shows '(use git rm [...])' and if there are two files, one as 'both deleted' and the other as 'added by them', the advice is '(use git add/rm [...])'. The previous tests in t7512-status-help.sh are updated. Test about the case of only 'both deleted' is added in t7060-wtstatus.sh Signed-off-by: Lucien Kong <Lucien.Kong@ensimag.imag.fr> Signed-off-by: Valentin Duperray <Valentin.Duperray@ensimag.imag.fr> Signed-off-by: Franck Jonas <Franck.Jonas@ensimag.imag.fr> Signed-off-by: Thomas Nguy <Thomas.Nguy@ensimag.imag.fr> Signed-off-by: Huynh Khoi Nguyen Nguyen <Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr> Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/wt-status.c b/wt-status.c
index e404f2d..6d0b71f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -131,9 +131,34 @@ void wt_status_prepare(struct wt_status *s)
static void wt_status_print_unmerged_header(struct wt_status *s)
{
+ int i;
+ int del_mod_conflict = 0;
+ int both_deleted = 0;
+ int not_deleted = 0;
const char *c = color(WT_STATUS_HEADER, s);
status_printf_ln(s, c, _("Unmerged paths:"));
+
+ for (i = 0; i < s->change.nr; i++) {
+ struct string_list_item *it = &(s->change.items[i]);
+ struct wt_status_change_data *d = it->util;
+
+ switch (d->stagemask) {
+ case 0:
+ break;
+ case 1:
+ both_deleted = 1;
+ break;
+ case 3:
+ case 5:
+ del_mod_conflict = 1;
+ break;
+ default:
+ not_deleted = 1;
+ break;
+ }
+ }
+
if (!advice_status_hints)
return;
if (s->whence != FROM_COMMIT)
@@ -142,7 +167,17 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
status_printf_ln(s, c, _(" (use \"git reset %s <file>...\" to unstage)"), s->reference);
else
status_printf_ln(s, c, _(" (use \"git rm --cached <file>...\" to unstage)"));
- status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
+
+ if (!both_deleted) {
+ if (!del_mod_conflict)
+ status_printf_ln(s, c, _(" (use \"git add <file>...\" to mark resolution)"));
+ else
+ status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
+ } else if (!del_mod_conflict && !not_deleted) {
+ status_printf_ln(s, c, _(" (use \"git rm <file>...\" to mark resolution)"));
+ } else {
+ status_printf_ln(s, c, _(" (use \"git add/rm <file>...\" as appropriate to mark resolution)"));
+ }
status_printf_ln(s, c, "");
}