Skip to content

Commit e62d112

Browse files
newrengitster
authored andcommitted
merge-recursive: give callers of handle_content_merge() access to contents
Pass a merge_file_info struct to handle_content_merge() so that the callers can access the oid and mode of the result afterward. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d169fd commit e62d112

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

merge-recursive.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,7 +2982,8 @@ static int handle_modify_delete(struct merge_options *opt,
29822982
_("modify"), _("modified"));
29832983
}
29842984

2985-
static int handle_content_merge(struct merge_options *opt,
2985+
static int handle_content_merge(struct merge_file_info *mfi,
2986+
struct merge_options *opt,
29862987
const char *path,
29872988
int is_dirty,
29882989
const struct diff_filespec *o,
@@ -2991,7 +2992,6 @@ static int handle_content_merge(struct merge_options *opt,
29912992
struct rename_conflict_info *ci)
29922993
{
29932994
const char *reason = _("content");
2994-
struct merge_file_info mfi;
29952995
unsigned df_conflict_remains = 0;
29962996

29972997
if (!is_valid(o))
@@ -3004,7 +3004,7 @@ static int handle_content_merge(struct merge_options *opt,
30043004

30053005
if (merge_mode_and_contents(opt, o, a, b, path,
30063006
opt->branch1, opt->branch2,
3007-
opt->call_depth * 2, &mfi))
3007+
opt->call_depth * 2, mfi))
30083008
return -1;
30093009

30103010
/*
@@ -3013,13 +3013,13 @@ static int handle_content_merge(struct merge_options *opt,
30133013
* b) The merge matches what was in HEAD (content, mode, pathname)
30143014
* c) The target path is usable (i.e. not involved in D/F conflict)
30153015
*/
3016-
if (mfi.clean && was_tracked_and_matches(opt, path, &mfi.blob) &&
3016+
if (mfi->clean && was_tracked_and_matches(opt, path, &mfi->blob) &&
30173017
!df_conflict_remains) {
30183018
int pos;
30193019
struct cache_entry *ce;
30203020

30213021
output(opt, 3, _("Skipped %s (merged same as existing)"), path);
3022-
if (add_cacheinfo(opt, &mfi.blob, path,
3022+
if (add_cacheinfo(opt, &mfi->blob, path,
30233023
0, (!opt->call_depth && !is_dirty), 0))
30243024
return -1;
30253025
/*
@@ -3035,11 +3035,11 @@ static int handle_content_merge(struct merge_options *opt,
30353035
ce = opt->repo->index->cache[pos];
30363036
ce->ce_flags |= CE_SKIP_WORKTREE;
30373037
}
3038-
return mfi.clean;
3038+
return mfi->clean;
30393039
}
30403040

3041-
if (!mfi.clean) {
3042-
if (S_ISGITLINK(mfi.blob.mode))
3041+
if (!mfi->clean) {
3042+
if (S_ISGITLINK(mfi->blob.mode))
30433043
reason = _("submodule");
30443044
output(opt, 1, _("CONFLICT (%s): Merge conflict in %s"),
30453045
reason, path);
@@ -3053,15 +3053,15 @@ static int handle_content_merge(struct merge_options *opt,
30533053
if (opt->call_depth) {
30543054
remove_file_from_index(opt->repo->index, path);
30553055
} else {
3056-
if (!mfi.clean) {
3056+
if (!mfi->clean) {
30573057
if (update_stages(opt, path, o, a, b))
30583058
return -1;
30593059
} else {
30603060
int file_from_stage2 = was_tracked(opt, path);
30613061

30623062
if (update_stages(opt, path, NULL,
3063-
file_from_stage2 ? &mfi.blob : NULL,
3064-
file_from_stage2 ? NULL : &mfi.blob))
3063+
file_from_stage2 ? &mfi->blob : NULL,
3064+
file_from_stage2 ? NULL : &mfi->blob))
30653065
return -1;
30663066
}
30673067

@@ -3072,15 +3072,15 @@ static int handle_content_merge(struct merge_options *opt,
30723072
path);
30733073
}
30743074
output(opt, 1, _("Adding as %s instead"), new_path);
3075-
if (update_file(opt, 0, &mfi.blob, new_path)) {
3075+
if (update_file(opt, 0, &mfi->blob, new_path)) {
30763076
free(new_path);
30773077
return -1;
30783078
}
30793079
free(new_path);
3080-
mfi.clean = 0;
3081-
} else if (update_file(opt, mfi.clean, &mfi.blob, path))
3080+
mfi->clean = 0;
3081+
} else if (update_file(opt, mfi->clean, &mfi->blob, path))
30823082
return -1;
3083-
return !is_dirty && mfi.clean;
3083+
return !is_dirty && mfi->clean;
30843084
}
30853085

30863086
static int handle_rename_normal(struct merge_options *opt,
@@ -3091,7 +3091,8 @@ static int handle_rename_normal(struct merge_options *opt,
30913091
struct rename_conflict_info *ci)
30923092
{
30933093
/* Merge the content and write it out */
3094-
return handle_content_merge(opt, path, was_dirty(opt, path),
3094+
struct merge_file_info mfi;
3095+
return handle_content_merge(&mfi, opt, path, was_dirty(opt, path),
30953096
o, a, b, ci);
30963097
}
30973098

@@ -3256,8 +3257,10 @@ static int process_entry(struct merge_options *opt,
32563257
a, b);
32573258
} else {
32583259
/* case D: Modified in both, but differently. */
3260+
struct merge_file_info mfi;
32593261
int is_dirty = 0; /* unpack_trees would have bailed if dirty */
3260-
clean_merge = handle_content_merge(opt, path, is_dirty,
3262+
clean_merge = handle_content_merge(&mfi, opt, path,
3263+
is_dirty,
32613264
o, a, b, NULL);
32623265
}
32633266
} else if (!o_valid && !a_valid && !b_valid) {

0 commit comments

Comments
 (0)