+
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ SYNOPSIS
[--super-prefix=<path>] [--config-env <name>=<envvar>]
<command> [<args>]

DESCRIPTION
-----------
NICE DESCRIPTION
----------------
Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.
Expand Down
52 changes: 33 additions & 19 deletions merge-ort.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,16 @@ static int find_first_merges(struct repository *repo,
oid_to_hex(&a->object.oid));
repo_init_revisions(repo, &revs, NULL);
rev_opts.submodule = path;

/*
* NEEDSWORK: We need this here because the revision iteration
* machinery uses the reference iteration machinery internally
* and that depends on the submodule objects available in our
* object database.
*/
if (add_submodule_odb(path))
return 0;

/* 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);
Expand All @@ -1056,7 +1066,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();
Expand All @@ -1071,7 +1081,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;
}
Expand All @@ -1097,6 +1107,9 @@ static int merge_submodule(struct merge_options *opt,
struct object_array merges;
struct strbuf sb = STRBUF_INIT;

struct merge_options subopt = *opt;
struct repository subrepo;

int i;
int search = !opt->priv->call_depth;

Expand All @@ -1111,43 +1124,44 @@ static int merge_submodule(struct merge_options *opt,
if (is_null_oid(b))
return 0;

if (add_submodule_odb(path)) {
if (get_submodule_repo(&subrepo, path)) {
path_msg(opt, path, 0,
_("Failed to merge submodule %s (not checked out)"),
path);
return 0;
}
subopt.repo = &subrepo;

if (!(commit_o = lookup_commit_reference(opt->repo, o)) ||
!(commit_a = lookup_commit_reference(opt->repo, a)) ||
!(commit_b = lookup_commit_reference(opt->repo, b))) {
path_msg(opt, path, 0,
if (!(commit_o = lookup_commit_reference(subopt.repo, o)) ||
!(commit_a = lookup_commit_reference(subopt.repo, a)) ||
!(commit_b = lookup_commit_reference(subopt.repo, b))) {
path_msg(&subopt, path, 0,
_("Failed to merge submodule %s (commits not present)"),
path);
return 0;
}

/* check whether both changes are forward */
if (!in_merge_bases(commit_o, commit_a) ||
!in_merge_bases(commit_o, commit_b)) {
path_msg(opt, path, 0,
if (!repo_in_merge_bases(subopt.repo, commit_o, commit_a) ||
!repo_in_merge_bases(subopt.repo, commit_o, commit_b)) {
path_msg(&subopt, path, 0,
_("Failed to merge submodule %s "
"(commits don't follow merge-base)"),
path);
return 0;
}

/* Case #1: a is contained in b or vice versa */
if (in_merge_bases(commit_a, commit_b)) {
if (repo_in_merge_bases(subopt.repo, commit_a, commit_b)) {
oidcpy(result, b);
path_msg(opt, path, 1,
path_msg(&subopt, path, 1,
_("Note: Fast-forwarding submodule %s to %s"),
path, oid_to_hex(b));
return 1;
}
if (in_merge_bases(commit_b, commit_a)) {
if (repo_in_merge_bases(subopt.repo, commit_b, commit_a)) {
oidcpy(result, a);
path_msg(opt, path, 1,
path_msg(&subopt, path, 1,
_("Note: Fast-forwarding submodule %s to %s"),
path, oid_to_hex(a));
return 1;
Expand All @@ -1165,21 +1179,21 @@ static int merge_submodule(struct merge_options *opt,
return 0;

/* find commit which merges them */
parent_count = find_first_merges(opt->repo, path, commit_a, commit_b,
parent_count = find_first_merges(subopt.repo, path, commit_a, commit_b,
&merges);
switch (parent_count) {
case 0:
path_msg(opt, path, 0, _("Failed to merge submodule %s"), path);
path_msg(&subopt, path, 0, _("Failed to merge submodule %s"), path);
break;

case 1:
format_commit(&sb, 4,
(struct commit *)merges.objects[0].item);
path_msg(opt, path, 0,
path_msg(&subopt, path, 0,
_("Failed to merge submodule %s, but a possible merge "
"resolution exists:\n%s\n"),
path, sb.buf);
path_msg(opt, path, 1,
path_msg(&subopt, path, 1,
_("If this is correct simply add it to the index "
"for example\n"
"by using:\n\n"
Expand All @@ -1192,7 +1206,7 @@ static int merge_submodule(struct merge_options *opt,
for (i = 0; i < merges.nr; i++)
format_commit(&sb, 4,
(struct commit *)merges.objects[i].item);
path_msg(opt, path, 0,
path_msg(&subopt, path, 0,
_("Failed to merge submodule %s, but multiple "
"possible merges exist:\n%s"), path, sb.buf);
strbuf_release(&sb);
Expand Down
68 changes: 41 additions & 27 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,16 @@ static int find_first_merges(struct repository *repo,
oid_to_hex(&a->object.oid));
repo_init_revisions(repo, &revs, NULL);
rev_opts.submodule = path;

/*
* NEEDSWORK: We need this here because the revision iteration
* machinery uses the reference iteration machinery internally
* and that depends on the submodule objects to be available in
* our object database.
*/
if (add_submodule_odb(path))
return 0;

/* 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);
Expand All @@ -1125,7 +1135,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();
Expand All @@ -1140,7 +1150,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;
}
Expand Down Expand Up @@ -1180,6 +1190,9 @@ static int merge_submodule(struct merge_options *opt,
int parent_count;
struct object_array merges;

struct merge_options subopt = *opt;
struct repository subrepo;

int i;
int search = !opt->priv->call_depth;

Expand All @@ -1199,45 +1212,46 @@ static int merge_submodule(struct merge_options *opt,
if (is_null_oid(b))
return 0;

if (add_submodule_odb(path)) {
if (get_submodule_repo(&subrepo, path)) {
output(opt, 1, _("Failed to merge submodule %s (not checked out)"), path);
return 0;
}
subopt.repo = &subrepo;

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 (!(commit_base = lookup_commit_reference(subopt.repo, base)) ||
!(commit_a = lookup_commit_reference(subopt.repo, a)) ||
!(commit_b = lookup_commit_reference(subopt.repo, b))) {
output(&subopt, 1, _("Failed to merge submodule %s (commits not present)"), path);
return 0;
}

/* check whether both changes are forward */
if (!in_merge_bases(commit_base, commit_a) ||
!in_merge_bases(commit_base, commit_b)) {
output(opt, 1, _("Failed to merge submodule %s (commits don't follow merge-base)"), path);
if (!repo_in_merge_bases(subopt.repo, commit_base, commit_a) ||
!repo_in_merge_bases(subopt.repo, commit_base, commit_b)) {
output(&subopt, 1, _("Failed to merge submodule %s (commits don't follow merge-base)"), path);
return 0;
}

/* Case #1: a is contained in b or vice versa */
if (in_merge_bases(commit_a, commit_b)) {
if (repo_in_merge_bases(subopt.repo, commit_a, commit_b)) {
oidcpy(result, b);
if (show(opt, 3)) {
output(opt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(opt, commit_b);
} else if (show(opt, 2))
output(opt, 2, _("Fast-forwarding submodule %s"), path);
output(&subopt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(&subopt, commit_b);
} else if (show(&subopt, 2))
output(&subopt, 2, _("Fast-forwarding submodule %s"), path);
else
; /* no output */

return 1;
}
if (in_merge_bases(commit_b, commit_a)) {
if (repo_in_merge_bases(subopt.repo, commit_b, commit_a)) {
oidcpy(result, a);
if (show(opt, 3)) {
output(opt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(opt, commit_a);
} else if (show(opt, 2))
output(opt, 2, _("Fast-forwarding submodule %s"), path);
if (show(&subopt, 3)) {
output(&subopt, 3, _("Fast-forwarding submodule %s to the following commit:"), path);
output_commit_title(&subopt, commit_a);
} else if (show(&subopt, 2))
output(&subopt, 2, _("Fast-forwarding submodule %s"), path);
else
; /* no output */

Expand All @@ -1256,18 +1270,18 @@ static int merge_submodule(struct merge_options *opt,
return 0;

/* find commit which merges them */
parent_count = find_first_merges(opt->repo, &merges, path,
parent_count = find_first_merges(subopt.repo, &merges, path,
commit_a, commit_b);
switch (parent_count) {
case 0:
output(opt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
output(&subopt, 1, _("Failed to merge submodule %s (merge following commits not found)"), path);
break;

case 1:
output(opt, 1, _("Failed to merge submodule %s (not fast-forward)"), path);
output(opt, 2, _("Found a possible merge resolution for the submodule:\n"));
output(&subopt, 1, _("Failed to merge submodule %s (not fast-forward)"), path);
output(&subopt, 2, _("Found a possible merge resolution for the submodule:\n"));
print_commit((struct commit *) merges.objects[0].item);
output(opt, 2, _(
output(&subopt, 2, _(
"If this is correct simply add it to the index "
"for example\n"
"by using:\n\n"
Expand All @@ -1277,7 +1291,7 @@ static int merge_submodule(struct merge_options *opt,
break;

default:
output(opt, 1, _("Failed to merge submodule %s (multiple merges found)"), path);
output(&subopt, 1, _("Failed to merge submodule %s (multiple merges found)"), path);
for (i = 0; i < merges.nr; i++)
print_commit((struct commit *) merges.objects[i].item);
}
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载