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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Sep 4, 2016 at 22:18 UTC
b4290342dd2d957cbcdb100c7d847802746b0730
1 file changed
+5
-4
apply.c
+5
-4
@@ -4042,7 +4042,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20
4042
}
4043
4044
/* 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)
4046
{
4047
struct patch *patch;
4048
struct index_state result = { NULL };
@@ -4089,12 +4089,13 @@ static int build_fake_ancestor(struct patch *list, const char *filename)
4089
}
4090
}
4091
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);
4093
res = write_locked_index(&result, &lock, COMMIT_LOCK);
4094
discard_index(&result);
4095
4096
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);
4099
4100
return 0;
4101
}
@@ -4709,7 +4710,7 @@ static int apply_patch(struct apply_state *state,
4710
}
4711
4712
if (state->fake_ancestor &&
4712
- build_fake_ancestor(list, state->fake_ancestor)) {
4713
+ build_fake_ancestor(state, list)) {
4714
res = -128;
4715
goto end;
4716
}