summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-04-16 10:28:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-16 10:28:10 (GMT)
commit3feaacbaa15f6437a1767935a5ff04fdef0e86e3 (patch)
tree5e0aee35a024e67148c29a351c7f5e57cae62a0a /builtin/checkout.c
parente9bd21c3373278a9eabaf20cb60dbb6aa694e37e (diff)
parenta7256debd4b6ba9f6ccb94c0958ef48cdd8cb664 (diff)
downloadgit-3feaacbaa15f6437a1767935a5ff04fdef0e86e3.zip
git-3feaacbaa15f6437a1767935a5ff04fdef0e86e3.tar.gz
git-3feaacbaa15f6437a1767935a5ff04fdef0e86e3.tar.bz2
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
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0e6037b..f95e797 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -726,6 +726,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
struct tree *result;
struct tree *work;
struct merge_options o;
+ struct strbuf sb = STRBUF_INIT;
+
if (!opts->merge)
return 1;
@@ -736,6 +738,13 @@ static int merge_working_tree(const struct checkout_opts *opts,
if (!old_branch_info->commit)
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 */
/*