Implement automatic fast-forward merge for submodules
This implements a simple merge strategy for submodule hashes. We check whether one side of the merge candidates is already contained in the other and then merge automatically. If both sides contain changes we search for a merge in the submodule. In case a single one exists we check that out and suggest it as the merge resolution. A list of candidates is returned when we find multiple merges that contain both sides of the changes. This is useful for a workflow in which the developers can publish topic branches in submodules and a separate maintainer merges them. In case the developers always wait until their branch gets merged before tracking them in the superproject all merges of branches that contain submodule changes will be resolved automatically. If developers choose to track their feature branch the maintainer might get a conflict but git will search the submodule for a merge and suggest it/them as a resolution. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
9ef6aeb09f
commit
68d03e4a6e
@ -20,6 +20,7 @@
|
||||
#include "attr.h"
|
||||
#include "merge-recursive.h"
|
||||
#include "dir.h"
|
||||
#include "submodule.h"
|
||||
|
||||
static struct tree *shift_tree_object(struct tree *one, struct tree *two,
|
||||
const char *subtree_shift)
|
||||
@ -525,13 +526,15 @@ static void update_file_flags(struct merge_options *o,
|
||||
void *buf;
|
||||
unsigned long size;
|
||||
|
||||
if (S_ISGITLINK(mode))
|
||||
if (S_ISGITLINK(mode)) {
|
||||
/*
|
||||
* We may later decide to recursively descend into
|
||||
* the submodule directory and update its index
|
||||
* and/or work tree, but we do not do that now.
|
||||
*/
|
||||
update_wd = 0;
|
||||
goto update_index;
|
||||
}
|
||||
|
||||
buf = read_sha1_file(sha, &type, &size);
|
||||
if (!buf)
|
||||
@ -716,8 +719,8 @@ static struct merge_file_info merge_file(struct merge_options *o,
|
||||
free(result_buf.ptr);
|
||||
result.clean = (merge_status == 0);
|
||||
} else if (S_ISGITLINK(a->mode)) {
|
||||
result.clean = 0;
|
||||
hashcpy(result.sha, a->sha1);
|
||||
result.clean = merge_submodule(result.sha, one->path, one->sha1,
|
||||
a->sha1, b->sha1);
|
||||
} else if (S_ISLNK(a->mode)) {
|
||||
hashcpy(result.sha, a->sha1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user