Skip to content

Commit b429034

Browse files
chriscoolgitster
authored andcommitted
apply: pass apply state to build_fake_ancestor()
To libify git apply functionality, we will need to read from a different index file in get_current_sha1(). This index file will be stored in "struct apply_state", so let's pass the state to build_fake_ancestor() which will later pass it to get_current_sha1(). Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e1bad2 commit b429034

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apply.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -4042,7 +4042,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20
40424042
}
40434043

40444044
/* Build an index that contains the just the files needed for a 3way merge */
4045-
static int build_fake_ancestor(struct patch *list, const char *filename)
4045+
static int build_fake_ancestor(struct apply_state *state, struct patch *list)
40464046
{
40474047
struct patch *patch;
40484048
struct index_state result = { NULL };
@@ -4089,12 +4089,13 @@ static int build_fake_ancestor(struct patch *list, const char *filename)
40894089
}
40904090
}
40914091

4092-
hold_lock_file_for_update(&lock, filename, LOCK_DIE_ON_ERROR);
4092+
hold_lock_file_for_update(&lock, state->fake_ancestor, LOCK_DIE_ON_ERROR);
40934093
res = write_locked_index(&result, &lock, COMMIT_LOCK);
40944094
discard_index(&result);
40954095

40964096
if (res)
4097-
return error("Could not write temporary index to %s", filename);
4097+
return error("Could not write temporary index to %s",
4098+
state->fake_ancestor);
40984099

40994100
return 0;
41004101
}
@@ -4709,7 +4710,7 @@ static int apply_patch(struct apply_state *state,
47094710
}
47104711

47114712
if (state->fake_ancestor &&
4712-
build_fake_ancestor(list, state->fake_ancestor)) {
4713+
build_fake_ancestor(state, list)) {
47134714
res = -128;
47144715
goto end;
47154716
}

0 commit comments

Comments
 (0)