Merge branch 'jt/add-submodule-odb-clean-up' into jt/no-abuse-alternate-odb-for-submodules
* jt/add-submodule-odb-clean-up: revision: remove "submodule" from opt struct repository: support unabsorbed in repo_submodule_init submodule: remove unnecessary unabsorbed fallback
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#include "repository.h"
|
||||
#include "revision.h"
|
||||
#include "string-list.h"
|
||||
#include "submodule-config.h"
|
||||
#include "submodule.h"
|
||||
#include "tag.h"
|
||||
#include "tree-walk.h"
|
||||
@ -1110,7 +1111,6 @@ static int find_first_merges(struct repository *repo,
|
||||
xsnprintf(merged_revision, sizeof(merged_revision), "^%s",
|
||||
oid_to_hex(&a->object.oid));
|
||||
repo_init_revisions(repo, &revs, NULL);
|
||||
rev_opts.submodule = path;
|
||||
/* FIXME: can't handle linked worktrees in submodules yet */
|
||||
revs.single_worktree = path != NULL;
|
||||
setup_revisions(ARRAY_SIZE(rev_args)-1, rev_args, &revs, &rev_opts);
|
||||
@ -1120,7 +1120,7 @@ static int find_first_merges(struct repository *repo,
|
||||
die("revision walk setup failed");
|
||||
while ((commit = get_revision(&revs)) != NULL) {
|
||||
struct object *o = &(commit->object);
|
||||
if (in_merge_bases(b, commit))
|
||||
if (repo_in_merge_bases(repo, b, commit))
|
||||
add_object_array(o, NULL, &merges);
|
||||
}
|
||||
reset_revision_walk();
|
||||
@ -1135,7 +1135,7 @@ static int find_first_merges(struct repository *repo,
|
||||
contains_another = 0;
|
||||
for (j = 0; j < merges.nr; j++) {
|
||||
struct commit *m2 = (struct commit *) merges.objects[j].item;
|
||||
if (i != j && in_merge_bases(m2, m1)) {
|
||||
if (i != j && repo_in_merge_bases(repo, m2, m1)) {
|
||||
contains_another = 1;
|
||||
break;
|
||||
}
|
||||
@ -1171,6 +1171,8 @@ static int merge_submodule(struct merge_options *opt,
|
||||
const struct object_id *base, const struct object_id *a,
|
||||
const struct object_id *b)
|
||||
{
|
||||
struct repository subrepo;
|
||||
int ret = 0;
|
||||
struct commit *commit_base, *commit_a, *commit_b;
|
||||
int parent_count;
|
||||
struct object_array merges;
|
||||
@ -1194,27 +1196,36 @@ static int merge_submodule(struct merge_options *opt,
|
||||
if (is_null_oid(b))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* NEEDSWORK: Remove this when all submodule object accesses are
|
||||
* through explicitly specified repositores.
|
||||
*/
|
||||
if (add_submodule_odb(path)) {
|
||||
output(opt, 1, _("Failed to merge submodule %s (not checked out)"), path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(commit_base = lookup_commit_reference(opt->repo, base)) ||
|
||||
!(commit_a = lookup_commit_reference(opt->repo, a)) ||
|
||||
!(commit_b = lookup_commit_reference(opt->repo, b))) {
|
||||
output(opt, 1, _("Failed to merge submodule %s (commits not present)"), path);
|
||||
if (repo_submodule_init(&subrepo, opt->repo, path, null_oid())) {
|
||||
output(opt, 1, _("Failed to merge submodule %s (not checked out)"), path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(commit_base = lookup_commit_reference(&subrepo, base)) ||
|
||||
!(commit_a = lookup_commit_reference(&subrepo, a)) ||
|
||||
!(commit_b = lookup_commit_reference(&subrepo, b))) {
|
||||
output(opt, 1, _("Failed to merge submodule %s (commits not present)"), path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* check whether both changes are forward */
|
||||
if (!in_merge_bases(commit_base, commit_a) ||
|
||||
!in_merge_bases(commit_base, commit_b)) {
|
||||
if (!repo_in_merge_bases(&subrepo, commit_base, commit_a) ||
|
||||
!repo_in_merge_bases(&subrepo, commit_base, commit_b)) {
|
||||
output(opt, 1, _("Failed to merge submodule %s (commits don't follow merge-base)"), path);
|
||||
return 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Case #1: a is contained in b or vice versa */
|
||||
if (in_merge_bases(commit_a, commit_b)) {
|
||||
if (repo_in_merge_bases(&subrepo, commit_a, commit_b)) {
|
||||
oidcpy(result, b);
|
||||
if (show(opt, 3)) {
|
||||
output(opt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
|
||||
@ -1224,9 +1235,10 @@ static int merge_submodule(struct merge_options *opt,
|
||||
else
|
||||
; /* no output */
|
||||
|
||||
return 1;
|
||||
ret = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
if (in_merge_bases(commit_b, commit_a)) {
|
||||
if (repo_in_merge_bases(&subrepo, commit_b, commit_a)) {
|
||||
oidcpy(result, a);
|
||||
if (show(opt, 3)) {
|
||||
output(opt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
|
||||
@ -1236,7 +1248,8 @@ static int merge_submodule(struct merge_options *opt,
|
||||
else
|
||||
; /* no output */
|
||||
|
||||
return 1;
|
||||
ret = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1248,10 +1261,10 @@ static int merge_submodule(struct merge_options *opt,
|
||||
|
||||
/* Skip the search if makes no sense to the calling context. */
|
||||
if (!search)
|
||||
return 0;
|
||||
goto cleanup;
|
||||
|
||||
/* find commit which merges them */
|
||||
parent_count = find_first_merges(opt->repo, &merges, path,
|
||||
parent_count = find_first_merges(&subrepo, &merges, path,
|
||||
commit_a, commit_b);
|
||||
switch (parent_count) {
|
||||
case 0:
|
||||
@ -1278,7 +1291,9 @@ static int merge_submodule(struct merge_options *opt,
|
||||
}
|
||||
|
||||
object_array_clear(&merges);
|
||||
return 0;
|
||||
cleanup:
|
||||
repo_clear(&subrepo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int merge_mode_and_contents(struct merge_options *opt,
|
||||
|
||||
Reference in New Issue
Block a user