Merge branch 'nd/checkout-m'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:14 +0000 (16:41 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:14 +0000 (16:41 +0900)
"git checkout -m <other>" was about carrying the differences
between HEAD and the working-tree files forward while checking out
another branch, and ignored the differences between HEAD and the
index. The command has been taught to abort when the index and the
HEAD are different.

* nd/checkout-m:
checkout: prevent losing staged changes with --merge
read-tree: add --quiet
unpack-trees: rename "gently" flag to "quiet"
unpack-trees: keep gently check inside add_rejected_path

1  2 
Documentation/git-read-tree.txt
builtin/checkout.c
unpack-trees.c
Simple merge
index 2e72a5e5a944e99ef7e3e44cdcb2e8b2feb22a90,7cd01f62be0c249911731a824805af9193664f66..ffa776c6e10c9665489bd4ca6eac1d35efb011c8
@@@ -737,14 -738,13 +738,20 @@@ static int merge_working_tree(const str
                         */
                        if (!old_branch_info->commit)
                                return 1;
+                       old_tree = get_commit_tree(old_branch_info->commit);
+                       if (repo_index_has_changes(the_repository, old_tree, &sb))
+                               die(_("cannot continue with staged changes in "
+                                     "the following files:\n%s"), sb.buf);
+                       strbuf_release(&sb);
  
 +                      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 */
  
                        /*
diff --cc unpack-trees.c
Simple merge