Compare

2e8a9d94b009c69628e29bc7c50d9a3fc12e14ba..2ba77ea82891678dee18fe869b0aecaa1019298e

checkout: separate autostash conflict advice from branch-switch message

"git checkout -m" stashes the user's local changes when it cannot
perform the checkout, and then applies the stash.  When applying the
stash results in conflicts, the advice on how to deal with them is
printed directly on top of the branch-switch message ("Switched to
branch ..."), making the two hard to tell apart.  Print a blank line
in between so that the advice and the branch-switch message are
visually distinct.

apply_autostash_ref() reports whether applying the stash resulted in
conflicts via its enum stash_apply_result return value, so only print
the blank line in the conflicted case.

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Harald Nordgren <haraldnordgren@gmail.com> · 2026-09-03 14:39 UTC · committed by Junio C Hamano

Browse files
10 files changed, +200 −101
modified Documentation/git-stash.adoc
@@ -426,6 +426,15 @@ include::includes/cmd-config-section-all.adoc[]
426 426 :git-stash: 1
427 427 include::config/stash.adoc[]
428 428
429 + EXIT STATUS
430 + -----------
431 +
432 + The `git stash` subcommands exit with status 0 on success. The
433 + subcommands that apply a stash entry, i.e. `apply`, `pop` and `branch`,
434 + exit with status 1 when applying the stash entry resulted in conflicts,
435 + in which case the stash entry is left in place, and with a non-zero
436 + status other than 1 when they fail for other reasons.
437 +
429 438
430 439 SEE ALSO
431 440 --------
modified builtin/checkout.c
@@ -1163,6 +1163,7 @@ static int switch_branches(const struct checkout_opts *opts,
1163 1163 int flag, writeout_error = 0;
1164 1164 int do_merge = 1;
1165 1165 int created_autostash = 0;
1166 + enum stash_apply_result autostash_res = STASH_APPLY_CLEAN;
1166 1167 struct strbuf old_commit_shortname = STRBUF_INIT;
1167 1168 struct strbuf autostash_msg = STRBUF_INIT;
1168 1169 const char *stash_label_base = NULL;
@@ -1234,12 +1235,12 @@ static int switch_branches(const struct checkout_opts *opts,
1234 1235 git_config_push_parameter(cfg.buf);
1235 1236 strbuf_release(&cfg);
1236 1237 }
1237 - apply_autostash_ref(the_repository,
1238 - "CHECKOUT_AUTOSTASH_HEAD",
1239 - new_branch_info->name,
1240 - "local",
1241 - stash_label_base,
1242 - autostash_msg.buf);
1238 + autostash_res = apply_autostash_ref(the_repository,
1239 + "CHECKOUT_AUTOSTASH_HEAD",
1240 + new_branch_info->name,
1241 + "local",
1242 + stash_label_base,
1243 + autostash_msg.buf);
1243 1244 }
1244 1245 if (ret) {
1245 1246 branch_info_release(&old_branch_info);
@@ -1252,6 +1253,8 @@ static int switch_branches(const struct checkout_opts *opts,
1252 1253 if (!opts->quiet && !old_branch_info.path && old_branch_info.commit && new_branch_info->commit != old_branch_info.commit)
1253 1254 orphaned_commit_warning(old_branch_info.commit, new_branch_info->commit);
1254 1255
1256 + if (autostash_res == STASH_APPLY_CONFLICT && !opts->quiet)
1257 + fputc('\n', stderr);
1255 1258 update_refs_for_switch(opts, &old_branch_info, new_branch_info);
1256 1259
1257 1260 if (created_autostash) {
modified builtin/stash.c
@@ -10,6 +10,7 @@
10 10 #include "object-name.h"
11 11 #include "parse-options.h"
12 12 #include "refs.h"
13 + #include "stash.h"
13 14 #include "lockfile.h"
14 15 #include "cache-tree.h"
15 16 #include "unpack-trees.h"
@@ -640,10 +641,12 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
640 641 die(_("could not write index"));
641 642 }
642 643
643 - static int do_apply_stash(const char *prefix, struct stash_info *info,
644 - int index, int quiet,
645 - const char *label_ours, const char *label_theirs,
646 - const char *label_base)
644 + static enum stash_apply_result do_apply_stash(const char *prefix,
645 + struct stash_info *info,
646 + int index, int quiet,
647 + const char *label_ours,
648 + const char *label_theirs,
649 + const char *label_base)
647 650 {
648 651 int clean, ret;
649 652 int has_index = index;
@@ -717,8 +720,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
717 720
718 721 /*
719 722 * If 'clean' >= 0, reverse the value for 'ret' so 'ret' is 0 when the
720 - * merge was clean, and nonzero if the merge was unclean or encountered
721 - * an error.
723 + * merge was clean, and 1 if the merge was unclean or a negative value
724 + * if it encountered an error.
722 725 */
723 726 ret = clean >= 0 ? !clean : clean;
724 727
@@ -2492,10 +2495,22 @@ int cmd_stash(int argc,
2492 2495 strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file,
2493 2496 (uintmax_t)pid);
2494 2497
2495 - if (fn)
2496 - return !!fn(argc, argv, prefix, repo);
2497 - else if (!argc)
2498 + if (fn) {
2499 + ret = fn(argc, argv, prefix, repo);
2500 +
2501 + /*
2502 + * The subcommand implementations return 0 on success, a
2503 + * negative value on failure, and STASH_APPLY_CONFLICT
2504 + * when applying a stash entry resulted in conflicts.
2505 + * Map failures to 128, the status die() uses, so that
2506 + * exit status 1 unambiguously indicates conflicts.
2507 + */
2508 + if (ret < 0)
2509 + return 128;
2510 + return ret;
2511 + } else if (!argc) {
2498 2512 return !!push_stash_unassumed(0, NULL, prefix, repo);
2513 + }
2499 2514
2500 2515 /* Assume 'stash push' */
2501 2516 strvec_push(&args, "push");
modified builtin/worktree.c
@@ -294,7 +294,7 @@ static void remove_junk_on_signal(int signo)
294 294 raise(signo);
295 295 }
296 296
297 - static char *worktree_basename_dup(const char *path)
297 + static const char *worktree_basename(const char *path, int *olen)
298 298 {
299 299 const char *name;
300 300 int len;
@@ -303,11 +303,14 @@ static char *worktree_basename_dup(const char *path)
303 303 while (len && is_dir_sep(path[len - 1]))
304 304 len--;
305 305
306 - name = path + len;
307 - while (name > path && !is_dir_sep(name[-1]))
308 - name--;
306 + for (name = path + len - 1; name > path; name--)
307 + if (is_dir_sep(*name)) {
308 + name++;
309 + break;
310 + }
309 311
310 - return xmemdupz(name, path + len - name);
312 + *olen = len;
313 + return name;
311 314 }
312 315
313 316 /* check that path is viable location for worktree */
@@ -461,7 +464,6 @@ static int add_worktree(const char *path, const char *refname,
461 464 struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT;
462 465 struct strbuf sb = STRBUF_INIT;
463 466 const char *name;
464 - char *name_to_free = NULL;
465 467 struct strvec child_env = STRVEC_INIT;
466 468 unsigned int counter = 0;
467 469 int len, ret;
@@ -489,12 +491,12 @@ static int add_worktree(const char *path, const char *refname,
489 491 if (!commit && !opts->orphan)
490 492 die(_("invalid reference: %s"), refname);
491 493
492 - name = name_to_free = worktree_basename_dup(path);
493 - if (!*name)
494 - die(_("invalid path '%s'"), path);
495 - sanitize_refname_component(name, &sb_name);
494 + name = worktree_basename(path, &len);
495 + strbuf_add(&sb, name, path + len - name);
496 + sanitize_refname_component(sb.buf, &sb_name);
496 497 if (!sb_name.len)
497 - BUG("How come '%s' becomes empty after sanitization?", name);
498 + BUG("How come '%s' becomes empty after sanitization?", sb.buf);
499 + strbuf_reset(&sb);
498 500 name = sb_name.buf;
499 501 repo_git_path_replace(the_repository, &sb_repo, "worktrees/%s", name);
500 502 len = sb_repo.len;
@@ -627,7 +629,6 @@ done:
627 629 strbuf_release(&sb_git);
628 630 strbuf_release(&sb_name);
629 631 free_worktree(wt);
630 - free(name_to_free);
631 632 return ret;
632 633 }
633 634
@@ -764,8 +765,10 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
764 765
765 766 static char *dwim_branch(const char *path, char **new_branch)
766 767 {
768 + int n;
767 769 int branch_exists;
768 - char *branchname = worktree_basename_dup(path);
770 + const char *s = worktree_basename(path, &n);
771 + char *branchname = xstrndup(s, n);
769 772 struct strbuf ref = STRBUF_INIT;
770 773
771 774 branch_exists = !check_branch_ref(&ref, branchname) &&
@@ -872,7 +875,9 @@ static int add(int ac, const char **av, const char *prefix,
872 875 }
873 876
874 877 if (opts.orphan && !new_branch) {
875 - new_branch = new_branch_to_free = worktree_basename_dup(path);
878 + int n;
879 + const char *s = worktree_basename(path, &n);
880 + new_branch = new_branch_to_free = xstrndup(s, n);
876 881 } else if (opts.orphan) {
877 882 ; /* no-op */
878 883 } else if (opts.detach) {
modified sequencer.c
@@ -19,6 +19,7 @@
19 19 #include "commit.h"
20 20 #include "sequencer.h"
21 21 #include "run-command.h"
22 + #include "stash.h"
22 23 #include "hook.h"
23 24 #include "utf8.h"
24 25 #include "cache-tree.h"
@@ -4727,31 +4728,50 @@ void create_autostash_ref(struct repository *r, const char *refname,
4727 4728 create_autostash_internal(r, NULL, refname, message, silent);
4728 4729 }
4729 4730
4730 - static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
4731 - const char *label_ours, const char *label_theirs,
4732 - const char *label_base,
4733 - const char *stash_msg)
4731 + static enum stash_apply_result do_stash_apply(const char *stash_oid,
4732 + const char *label_ours,
4733 + const char *label_theirs,
4734 + const char *label_base)
4734 4735 {
4735 4736 struct child_process child = CHILD_PROCESS_INIT;
4736 - int ret = 0;
4737 4737
4738 - if (attempt_apply) {
4739 - child.git_cmd = 1;
4740 - child.no_stdout = 1;
4741 - child.no_stderr = 1;
4742 - strvec_push(&child.args, "stash");
4743 - strvec_push(&child.args, "apply");
4744 - if (label_ours)
4745 - strvec_pushf(&child.args, "--label-ours=%s", label_ours);
4746 - if (label_theirs)
4747 - strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
4748 - if (label_base)
4749 - strvec_pushf(&child.args, "--label-base=%s", label_base);
4750 - strvec_push(&child.args, stash_oid);
4751 - ret = run_command(&child);
4752 - }
4753 -
4754 - if (attempt_apply && !ret)
4738 + child.git_cmd = 1;
4739 + child.no_stdout = 1;
4740 + child.no_stderr = 1;
4741 + strvec_push(&child.args, "stash");
4742 + strvec_push(&child.args, "apply");
4743 + if (label_ours)
4744 + strvec_pushf(&child.args, "--label-ours=%s", label_ours);
4745 + if (label_theirs)
4746 + strvec_pushf(&child.args, "--label-theirs=%s", label_theirs);
4747 + if (label_base)
4748 + strvec_pushf(&child.args, "--label-base=%s", label_base);
4749 + strvec_push(&child.args, stash_oid);
4750 +
4751 + switch (run_command(&child)) {
4752 + case 0:
4753 + return STASH_APPLY_CLEAN;
4754 + case STASH_APPLY_CONFLICT:
4755 + return STASH_APPLY_CONFLICT;
4756 + default:
4757 + return STASH_APPLY_ERROR;
4758 + }
4759 + }
4760 +
4761 + static enum stash_apply_result apply_save_autostash_oid(const char *stash_oid,
4762 + int attempt_apply,
4763 + const char *label_ours,
4764 + const char *label_theirs,
4765 + const char *label_base,
4766 + const char *stash_msg)
4767 + {
4768 + enum stash_apply_result ret = STASH_APPLY_CLEAN;
4769 +
4770 + if (attempt_apply)
4771 + ret = do_stash_apply(stash_oid, label_ours, label_theirs,
4772 + label_base);
4773 +
4774 + if (attempt_apply && ret == STASH_APPLY_CLEAN)
4755 4775 fprintf(stderr, _("Applied autostash.\n"));
4756 4776 else {
4757 4777 struct child_process store = CHILD_PROCESS_INIT;
@@ -4765,13 +4785,16 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
4765 4785 strvec_push(&store.args, stash_oid);
4766 4786 if (run_command(&store))
4767 4787 ret = error(_("cannot store %s"), stash_oid);
4768 - else if (attempt_apply)
4788 + else if (attempt_apply && ret == STASH_APPLY_CONFLICT)
4769 4789 fprintf(stderr,
4770 4790 _("Your local changes are stashed, however applying them\n"
4771 4791 "resulted in conflicts. You can either resolve the conflicts\n"
4772 4792 "and then discard the stash with \"git stash drop\", or, if you\n"
4773 4793 "do not want to resolve them now, run \"git reset --hard\" and\n"
4774 4794 "apply the local changes later by running \"git stash pop\".\n"));
4795 + else if (attempt_apply)
4796 + ret = error(_("could not apply autostash; "
4797 + "your changes are safe in the stash"));
4775 4798 else
4776 4799 fprintf(stderr,
4777 4800 _("Autostash exists; creating a new stash entry.\n"
@@ -4783,15 +4806,16 @@ static int apply_save_autostash_oid(const char *stash_oid, int attempt_apply,
4783 4806 return ret;
4784 4807 }
4785 4808
4786 - static int apply_save_autostash(const char *path, int attempt_apply)
4809 + static enum stash_apply_result apply_save_autostash(const char *path,
4810 + int attempt_apply)
4787 4811 {
4788 4812 struct strbuf stash_oid = STRBUF_INIT;
4789 - int ret = 0;
4813 + enum stash_apply_result ret = STASH_APPLY_CLEAN;
4790 4814
4791 4815 if (!read_oneliner(&stash_oid, path,
4792 4816 READ_ONELINER_SKIP_IF_EMPTY)) {
4793 4817 strbuf_release(&stash_oid);
4794 - return 0;
4818 + return STASH_APPLY_CLEAN;
4795 4819 }
4796 4820 strbuf_trim(&stash_oid);
4797 4821
@@ -4803,37 +4827,40 @@ static int apply_save_autostash(const char *path, int attempt_apply)
4803 4827 return ret;
4804 4828 }
4805 4829
4806 - int save_autostash(const char *path)
4830 + enum stash_apply_result save_autostash(const char *path)
4807 4831 {
4808 4832 return apply_save_autostash(path, 0);
4809 4833 }
4810 4834
4811 - int apply_autostash(const char *path)
4835 + enum stash_apply_result apply_autostash(const char *path)
4812 4836 {
4813 4837 return apply_save_autostash(path, 1);
4814 4838 }
4815 4839
4816 - int apply_autostash_oid(const char *stash_oid)
4840 + enum stash_apply_result apply_autostash_oid(const char *stash_oid)
4817 4841 {
4818 4842 return apply_save_autostash_oid(stash_oid, 1, NULL, NULL, NULL, NULL);
4819 4843 }
4820 4844
4821 - static int apply_save_autostash_ref(struct repository *r, const char *refname,
4822 - int attempt_apply,
4823 - const char *label_ours, const char *label_theirs,
4824 - const char *label_base,
4825 - const char *stash_msg)
4845 + static enum stash_apply_result apply_save_autostash_ref(struct repository *r,
4846 + const char *refname,
4847 + int attempt_apply,
4848 + const char *label_ours,
4849 + const char *label_theirs,
4850 + const char *label_base,
4851 + const char *stash_msg)
4826 4852 {
4827 4853 struct object_id stash_oid;
4828 4854 char stash_oid_hex[GIT_MAX_HEXSZ + 1];
4829 - int flag, ret;
4855 + int flag;
4856 + enum stash_apply_result ret;
4830 4857
4831 4858 if (!refs_ref_exists(get_main_ref_store(r), refname))
4832 - return 0;
4859 + return STASH_APPLY_CLEAN;
4833 4860
4834 4861 if (!refs_resolve_ref_unsafe(get_main_ref_store(r), refname,
4835 4862 RESOLVE_REF_READING, &stash_oid, &flag))
4836 - return -1;
4863 + return STASH_APPLY_ERROR;
4837 4864 if (flag & REF_ISSYMREF)
4838 4865 return error(_("autostash reference is a symref"));
4839 4866
@@ -4848,15 +4875,19 @@ static int apply_save_autostash_ref(struct repository *r, const char *refname,
4848 4875 return ret;
4849 4876 }
4850 4877
4851 - int save_autostash_ref(struct repository *r, const char *refname)
4878 + enum stash_apply_result save_autostash_ref(struct repository *r,
4879 + const char *refname)
4852 4880 {
4853 4881 return apply_save_autostash_ref(r, refname, 0,
4854 4882 NULL, NULL, NULL, NULL);
4855 4883 }
4856 4884
4857 - int apply_autostash_ref(struct repository *r, const char *refname,
4858 - const char *label_ours, const char *label_theirs,
4859 - const char *label_base, const char *stash_msg)
4885 + enum stash_apply_result apply_autostash_ref(struct repository *r,
4886 + const char *refname,
4887 + const char *label_ours,
4888 + const char *label_theirs,
4889 + const char *label_base,
4890 + const char *stash_msg)
4860 4891 {
4861 4892 return apply_save_autostash_ref(r, refname, 1,
4862 4893 label_ours, label_theirs, label_base,
modified sequencer.h
@@ -3,6 +3,7 @@
3 3
4 4 #include "strbuf.h"
5 5 #include "strvec.h"
6 + #include "stash.h"
6 7 #include "wt-status.h"
7 8
8 9 struct commit;
@@ -231,13 +232,17 @@ void commit_post_rewrite(struct repository *r,
231 232 void create_autostash(struct repository *r, const char *path);
232 233 void create_autostash_ref(struct repository *r, const char *refname,
233 234 const char *message, bool silent);
234 - int save_autostash(const char *path);
235 - int save_autostash_ref(struct repository *r, const char *refname);
236 - int apply_autostash(const char *path);
237 - int apply_autostash_oid(const char *stash_oid);
238 - int apply_autostash_ref(struct repository *r, const char *refname,
239 - const char *label_ours, const char *label_theirs,
240 - const char *label_base, const char *stash_msg);
235 + enum stash_apply_result save_autostash(const char *path);
236 + enum stash_apply_result save_autostash_ref(struct repository *r,
237 + const char *refname);
238 + enum stash_apply_result apply_autostash(const char *path);
239 + enum stash_apply_result apply_autostash_oid(const char *stash_oid);
240 + enum stash_apply_result apply_autostash_ref(struct repository *r,
241 + const char *refname,
242 + const char *label_ours,
243 + const char *label_theirs,
244 + const char *label_base,
245 + const char *stash_msg);
241 246
242 247 #define SUMMARY_INITIAL_COMMIT (1 << 0)
243 248 #define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)
added stash.h mode 100644
@@ -0,0 +1,21 @@
1 + #ifndef STASH_H
2 + #define STASH_H
3 +
4 + enum stash_apply_result {
5 + /* The stash was applied cleanly, or there was nothing to apply. */
6 + STASH_APPLY_CLEAN = 0,
7 +
8 + /*
9 + * The stash could not be applied because it resulted in
10 + * conflicts. The stash entry is left in place. The "git stash
11 + * apply", "pop" and "branch" subcommands exit with this status
12 + * in this case, mirroring the convention of "git merge-tree" and
13 + * the merge strategies.
14 + */
15 + STASH_APPLY_CONFLICT = 1,
16 +
17 + /* Something went wrong. */
18 + STASH_APPLY_ERROR = -1,
19 + };
20 +
21 + #endif /* STASH_H */
modified t/t2400-worktree-add.sh
@@ -46,10 +46,6 @@ test_expect_success '"add" refuses to checkout locked branch' '
46 46 test_path_is_missing .git/worktrees/zere
47 47 '
48 48
49 - test_expect_success '"add" rejects an empty path' '
50 - test_must_fail git worktree add "" HEAD
51 - '
52 -
53 49 test_expect_success 'checking out paths not complaining about linked checkouts' '
54 50 (
55 51 cd existing_empty &&
@@ -298,11 +294,6 @@ test_expect_success '"add" with <branch> omitted' '
298 294 test_cmp_rev HEAD bat
299 295 '
300 296
301 - test_expect_success '"add" with trailing slash and <branch> omitted' '
302 - git worktree add waffle/bit/ &&
303 - test_cmp_rev HEAD bit
304 - '
305 -
306 297 test_expect_success '"add" checks out existing branch of dwimd name' '
307 298 git branch dwim HEAD~1 &&
308 299 git worktree add dwim &&
@@ -393,14 +384,6 @@ test_expect_success '"add --orphan (no -b)"' '
393 384 test_cmp expected actual
394 385 '
395 386
396 - test_expect_success '"add --orphan with trailing slash (no -b)"' '
397 - test_when_finished "git worktree remove -f -f neworphan" &&
398 - git worktree add --orphan ./neworphan/ &&
399 - echo refs/heads/neworphan >expected &&
400 - git -C neworphan symbolic-ref HEAD >actual &&
401 - test_cmp expected actual
402 - '
403 -
404 387 test_expect_success '"add --orphan --quiet"' '
405 388 test_when_finished "git worktree remove -f -f orphandir" &&
406 389 git worktree add --quiet --orphan -b neworphan orphandir 2>log.actual &&
modified t/t3903-stash.sh
@@ -1791,13 +1791,13 @@ test_expect_success 'stash.index=false overridden by --index' '
1791 1791 test_cmp expect file
1792 1792 '
1793 1793
1794 - test_expect_success 'apply with custom conflict labels' '
1794 + test_expect_success 'apply exits 1 on conflicts' '
1795 1795 git reset --hard initial &&
1796 1796 test_commit label-base conflict-file base-content &&
1797 1797 echo stashed >conflict-file &&
1798 1798 git stash push -m "stashed" &&
1799 1799 test_commit label-upstream conflict-file upstream-content &&
1800 - test_must_fail git -c merge.conflictStyle=diff3 stash apply --label-ours=UP --label-theirs=STASH &&
1800 + test_expect_code 1 git -c merge.conflictStyle=diff3 stash apply --label-ours=UP --label-theirs=STASH &&
1801 1801 test_grep "^<<<<<<< UP" conflict-file &&
1802 1802 test_grep "^||||||| Stash base" conflict-file &&
1803 1803 test_grep "^>>>>>>> STASH" conflict-file
@@ -1809,11 +1809,30 @@ test_expect_success 'apply with empty conflict labels' '
1809 1809 echo stashed >conflict-file &&
1810 1810 git stash push -m "stashed" &&
1811 1811 test_commit empty-label-upstream conflict-file upstream-content &&
1812 - test_must_fail git stash apply --label-ours= --label-theirs= &&
1812 + test_expect_code 1 git stash apply --label-ours= --label-theirs= &&
1813 1813 test_grep "^<<<<<<<$" conflict-file &&
1814 1814 test_grep "^>>>>>>>$" conflict-file
1815 1815 '
1816 1816
1817 + test_expect_success 'pop exits 1 on conflicts and keeps the stash entry' '
1818 + git reset --hard initial &&
1819 + echo stashed >file &&
1820 + git stash push -m pop-stashed &&
1821 + test_commit pop-upstream file upstream-content &&
1822 + test_expect_code 1 git stash pop &&
1823 + git stash list >list &&
1824 + test_grep pop-stashed list
1825 + '
1826 +
1827 + test_expect_success 'stash branch exits with a non-1 status on errors' '
1828 + git reset --hard initial &&
1829 + echo stashed >file &&
1830 + git stash push -m branch-stashed &&
1831 + test_expect_code 128 git stash branch conflicting-branch refs/heads/does-not-exist &&
1832 + git stash list >list &&
1833 + test_grep branch-stashed list
1834 + '
1835 +
1817 1836 test_expect_success 'stash show --include-untracked includes untracked files' '
1818 1837 git reset --hard &&
1819 1838
modified t/t7201-co.sh
@@ -236,10 +236,18 @@ test_expect_success 'checkout -m creates a recoverable stash on conflict' '
236 236 test_must_fail git checkout side 2>stderr &&
237 237 test_grep "Your local changes" stderr &&
238 238 git checkout -m side >actual 2>&1 &&
239 - test_grep "resulted in conflicts" actual &&
240 - test_grep "git stash drop" actual &&
241 - test_grep "git stash pop" actual &&
242 - test_grep "The following paths have local changes" actual &&
239 + cat >expect <<-EOF &&
240 + Your local changes are stashed, however applying them
241 + resulted in conflicts. You can either resolve the conflicts
242 + and then discard the stash with "git stash drop", or, if you
243 + do not want to resolve them now, run "git reset --hard" and
244 + apply the local changes later by running "git stash pop".
245 +
246 + Switched to branch ${SQ}side${SQ}
247 + The following paths have local changes:
248 + M one
249 + EOF
250 + test_cmp expect actual &&
243 251 git log -p -1 --format="%gs%n%B" -g --diff-merges=1 refs/stash >actual &&
244 252 sed /^index/d actual >actual.trimmed &&
245 253 cat >expect <<-EOF &&