]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'en/dirty-merge-fixes'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Aug 2018 22:30:45 +0000 (15:30 -0700)
The recursive merge strategy did not properly ensure there was no
change between HEAD and the index before performing its operation,
which has been corrected.

* en/dirty-merge-fixes:
  merge: fix misleading pre-merge check documentation
  merge-recursive: enforce rule that index matches head before merging
  t6044: add more testcases with staged changes before a merge is invoked
  merge-recursive: fix assumption that head tree being merged is HEAD
  merge-recursive: make sure when we say we abort that we actually abort
  t6044: add a testcase for index matching head, when head doesn't match HEAD
  t6044: verify that merges expected to abort actually abort
  index_has_changes(): avoid assuming operating on the_index
  read-cache.c: move index_has_changes() from merge.c

1  2 
Documentation/git-merge.txt
builtin/am.c
cache.h
merge-recursive.c
merge.c
read-cache.c

Simple merge
diff --cc builtin/am.c
Simple merge
diff --cc cache.h
Simple merge
Simple merge
diff --cc merge.c
index 0783858739f84028df6eef85d3673c944fabb912,fb5eaf24622f2f0b6c8dfd1bdc6fb051e31007d5..e30e03fb84a7677520d208a5688bb7170c22bf8e
+++ b/merge.c
  
  static const char *merge_argument(struct commit *commit)
  {
 -      if (commit)
 -              return oid_to_hex(&commit->object.oid);
 -      else
 -              return EMPTY_TREE_SHA1_HEX;
 +      return oid_to_hex(commit ? &commit->object.oid : the_hash_algo->empty_tree);
  }
  
- int index_has_changes(struct strbuf *sb)
- {
-       struct object_id head;
-       int i;
-       if (!get_oid_tree("HEAD", &head)) {
-               struct diff_options opt;
-               diff_setup(&opt);
-               opt.flags.exit_with_status = 1;
-               if (!sb)
-                       opt.flags.quick = 1;
-               do_diff_cache(&head, &opt);
-               diffcore_std(&opt);
-               for (i = 0; sb && i < diff_queued_diff.nr; i++) {
-                       if (i)
-                               strbuf_addch(sb, ' ');
-                       strbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);
-               }
-               diff_flush(&opt);
-               return opt.flags.has_changes != 0;
-       } else {
-               for (i = 0; sb && i < active_nr; i++) {
-                       if (i)
-                               strbuf_addch(sb, ' ');
-                       strbuf_addstr(sb, active_cache[i]->name);
-               }
-               return !!active_nr;
-       }
- }
  int try_merge_command(const char *strategy, size_t xopts_nr,
                      const char **xopts, struct commit_list *common,
                      const char *head_arg, struct commit_list *remotes)
diff --cc read-cache.c
Simple merge