'
-test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
+test_expect_success 'prepare for conflicts' '
git reset --hard &&
git checkout -b conflict &&
test_commit one main.txt one &&
git commit -m "main.txt renamed in sub_master.txt" &&
git checkout conflict_second &&
git mv main.txt sub_second.txt &&
- git commit -m "main.txt renamed in sub_second.txt" &&
+ git commit -m "main.txt renamed in sub_second.txt"
+'
+
+
+test_expect_success 'status when conflicts with add and rm advice (both deleted)' '
test_must_fail git merge conflict &&
cat >expected <<-\EOF &&
# On branch conflict_second
'
+test_expect_success 'status when conflicts with only rm advice (both deleted)' '
+ git reset --hard conflict_second &&
+ test_must_fail git merge conflict &&
+ git add sub_master.txt &&
+ git add sub_second.txt &&
+ cat >expected <<-\EOF &&
+ # On branch conflict_second
+ # You have unmerged paths.
+ # (fix conflicts and run "git commit")
+ #
+ # Changes to be committed:
+ #
+ # new file: sub_master.txt
+ #
+ # Unmerged paths:
+ # (use "git rm <file>..." to mark resolution)
+ #
+ # both deleted: main.txt
+ #
+ # Untracked files not listed (use -u option to show untracked files)
+ EOF
+ git status --untracked-files=no >actual &&
+ test_i18ncmp expected actual &&
+ git reset --hard &&
+ git checkout master
+'
+
+
test_done
# (fix conflicts and run "git commit")
#
# Unmerged paths:
- # (use "git add/rm <file>..." as appropriate to mark resolution)
+ # (use "git add <file>..." to mark resolution)
#
# both modified: main.txt
#
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
- # (use "git add/rm <file>..." as appropriate to mark resolution)
+ # (use "git add <file>..." to mark resolution)
#
# both modified: main.txt
#
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
- # (use "git add/rm <file>..." as appropriate to mark resolution)
+ # (use "git add <file>..." to mark resolution)
#
# both modified: main.txt
#
# (fix conflicts and run "git commit")
#
# Unmerged paths:
- # (use "git add/rm <file>..." as appropriate to mark resolution)
+ # (use "git add <file>..." to mark resolution)
#
# both modified: main.txt
#
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)
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, "");
}