From b101793c431b858e49b909bb309a87145fb7348c Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 21 Dec 2017 11:19:06 -0800 Subject: move index_has_changes() from builtin/am.c to merge.c for reuse index_has_changes() is a function we want to reuse outside of just am, making it also available for merge-recursive and merge-ort. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin/am.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'builtin') diff --git a/builtin/am.c b/builtin/am.c index d7513f537..71619f01a 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1142,43 +1142,6 @@ static void refresh_and_write_cache(void) die(_("unable to write index file")); } -/** - * Returns 1 if the index differs from HEAD, 0 otherwise. When on an unborn - * branch, returns 1 if there are entries in the index, 0 otherwise. If an - * strbuf is provided, the space-separated list of files that differ will be - * appended to it. - */ -static 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); - DIFF_OPT_SET(&opt, EXIT_WITH_STATUS); - if (!sb) - DIFF_OPT_SET(&opt, QUICK); - 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 DIFF_OPT_TST(&opt, 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; - } -} - /** * Dies with a user-friendly message on how to proceed after resolving the * problem. This message can be overridden with state->resolvemsg. -- cgit v1.2.1