Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-22 23:48:38 +0300
committerJunio C Hamano <gitster@pobox.com>2017-12-22 23:48:38 +0300
commitb6825b5c8e8b58943511f2576475accf1593486e (patch)
treede8bc8a4fdf954c8870cb1a1d60f3d38b781d12f /merge.c
parent936d1b989416a95f593bf81ccae8ac62cd83f279 (diff)
parent65170c07d466b18364e0d2b6a360900c073b600f (diff)
Merge branch 'ew/empty-merge-with-dirty-index-maint' into ew/empty-merge-with-dirty-index
* ew/empty-merge-with-dirty-index-maint: merge-recursive: avoid incorporating uncommitted changes in a merge move index_has_changes() from builtin/am.c to merge.c for reuse t6044: recursive can silently incorporate dirty changes in a merge
Diffstat (limited to 'merge.c')
-rw-r--r--merge.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/merge.c b/merge.c
index e5d796c9f2..195b578700 100644
--- a/merge.c
+++ b/merge.c
@@ -1,4 +1,6 @@
#include "cache.h"
+#include "diff.h"
+#include "diffcore.h"
#include "lockfile.h"
#include "commit.h"
#include "run-command.h"
@@ -15,6 +17,37 @@ static const char *merge_argument(struct commit *commit)
return EMPTY_TREE_SHA1_HEX;
}
+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)