Merge branch 'nd/checkout-m-doc-update'

Doc about the above.

* nd/checkout-m-doc-update:
  checkout.txt: note about losing staged changes with --merge
This commit is contained in:
Junio C Hamano 2019-04-16 19:28:10 +09:00
commit 3feaacbaa1
2 changed files with 11 additions and 0 deletions

View file

@ -242,6 +242,8 @@ should result in deletion of the path).
+ +
When checking out paths from the index, this option lets you recreate When checking out paths from the index, this option lets you recreate
the conflicted merge in the specified paths. the conflicted merge in the specified paths.
+
When switching branches with `--merge`, staged changes may be lost.
--conflict=<style>:: --conflict=<style>::
The same as --merge option above, but changes the way the The same as --merge option above, but changes the way the

View file

@ -726,6 +726,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
struct tree *result; struct tree *result;
struct tree *work; struct tree *work;
struct merge_options o; struct merge_options o;
struct strbuf sb = STRBUF_INIT;
if (!opts->merge) if (!opts->merge)
return 1; return 1;
@ -736,6 +738,13 @@ static int merge_working_tree(const struct checkout_opts *opts,
if (!old_branch_info->commit) if (!old_branch_info->commit)
return 1; return 1;
if (repo_index_has_changes(the_repository,
get_commit_tree(old_branch_info->commit),
&sb))
warning(_("staged changes in the following files may be lost: %s"),
sb.buf);
strbuf_release(&sb);
/* Do more real merge */ /* Do more real merge */
/* /*