git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
37bbdf11cceba42f78062db5a20c40362d789a52 blob 1632 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
/*
 * Builtin "git merge-octopus"
 *
 * Copyright (c) 2020 Alban Gruin
 *
 * Based on git-merge-octopus.sh, written by Junio C Hamano.
 *
 * Resolve two or more trees.
 */

#include "cache.h"
#include "builtin.h"
#include "commit.h"
#include "merge-strategies.h"

static const char builtin_merge_octopus_usage[] =
	"git merge-octopus [<bases>...] -- <head> <remote1> <remote2> [<remotes>...]";

int cmd_merge_octopus(int argc, const char **argv, const char *prefix)
{
	int i, sep_seen = 0;
	struct commit_list *bases = NULL, *remotes = NULL;
	struct commit_list **next_base = &bases, **next_remote = &remotes;
	const char *head_arg = NULL;

	if (argc < 5)
		usage(builtin_merge_octopus_usage);

	setup_work_tree();
	if (repo_read_index(the_repository) < 0)
		die("corrupted cache");

	/* The first parameters up to -- are merge bases; the rest are
	 * heads. */
	for (i = 1; i < argc; i++) {
		if (strcmp(argv[i], "--") == 0)
			sep_seen = 1;
		else if (strcmp(argv[i], "-h") == 0)
			usage(builtin_merge_octopus_usage);
		else if (sep_seen && !head_arg)
			head_arg = argv[i];
		else {
			struct object_id oid;

			get_oid(argv[i], &oid);

			if (!oideq(&oid, the_hash_algo->empty_tree)) {
				struct commit *commit;
				commit = lookup_commit_or_die(&oid, argv[i]);

				if (sep_seen)
					next_remote = commit_list_append(commit, next_remote);
				else
					next_base = commit_list_append(commit, next_base);
			}
		}
	}

	/* Reject if this is not an octopus -- resolve should be used
	 * instead. */
	if (commit_list_count(remotes) < 2)
		return 2;

	return merge_strategies_octopus(the_repository, bases, head_arg, remotes);
}
debug log:

solving 37bbdf11cc ...
found 37bbdf11cc in https://public-inbox.org/git/20200901105705.6059-8-alban.gruin@gmail.com/ ||
	https://public-inbox.org/git/20200625121953.16991-14-alban.gruin@gmail.com/

applying [1/2] https://public-inbox.org/git/20200901105705.6059-8-alban.gruin@gmail.com/
diff --git a/builtin/merge-octopus.c b/builtin/merge-octopus.c
new file mode 100644
index 0000000000..37bbdf11cc

Checking patch builtin/merge-octopus.c...
Applied patch builtin/merge-octopus.c cleanly.

skipping https://public-inbox.org/git/20200625121953.16991-14-alban.gruin@gmail.com/ for 37bbdf11cc
index at:
100644 37bbdf11cceba42f78062db5a20c40362d789a52	builtin/merge-octopus.c

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).