summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-08-13 16:14:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-13 21:14:44 (GMT)
commit332a82a52222da253cd5023cd4c5cde2d51636b9 (patch)
tree4764f431d866d341b0bfc81b2faed899c5cb62de /apply.c
parentff82d1260f55836e18625fbae1697dbbe3090531 (diff)
downloadgit-332a82a52222da253cd5023cd4c5cde2d51636b9.zip
git-332a82a52222da253cd5023cd4c5cde2d51636b9.tar.gz
git-332a82a52222da253cd5023cd4c5cde2d51636b9.tar.bz2
apply.c: pass struct apply_state to more functions
we're going to remove the dependency on the_index by moving 'struct index_state *' to somewhere inside struct apply_state. Let's make sure relevant functions have access to this struct now and reduce the diff noise when the actual conversion happens. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/apply.c b/apply.c
index 2476f06..572cd63 100644
--- a/apply.c
+++ b/apply.c
@@ -3374,7 +3374,9 @@ static struct patch *previous_patch(struct apply_state *state,
return previous;
}
-static int verify_index_match(const struct cache_entry *ce, struct stat *st)
+static int verify_index_match(struct apply_state *state,
+ const struct cache_entry *ce,
+ struct stat *st)
{
if (S_ISGITLINK(ce->ce_mode)) {
if (!S_ISDIR(st->st_mode))
@@ -3524,7 +3526,7 @@ static int load_current(struct apply_state *state,
if (checkout_target(&the_index, ce, &st))
return -1;
}
- if (verify_index_match(ce, &st))
+ if (verify_index_match(state, ce, &st))
return error(_("%s: does not match index"), name);
status = load_patch_target(state, &buf, ce, &st, patch, name, mode);
@@ -3694,7 +3696,7 @@ static int check_preimage(struct apply_state *state,
if (checkout_target(&the_index, *ce, st))
return -1;
}
- if (!state->cached && verify_index_match(*ce, st))
+ if (!state->cached && verify_index_match(state, *ce, st))
return error(_("%s: does not match index"), old_name);
if (state->cached)
st_mode = (*ce)->ce_mode;
@@ -4313,7 +4315,9 @@ static int add_index_file(struct apply_state *state,
* 0 if everything went well
* 1 if a recoverable error happened
*/
-static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
+static int try_create_file(struct apply_state *state, const char *path,
+ unsigned int mode, const char *buf,
+ unsigned long size)
{
int fd, res;
struct strbuf nbuf = STRBUF_INIT;
@@ -4371,7 +4375,7 @@ static int create_one_file(struct apply_state *state,
if (state->cached)
return 0;
- res = try_create_file(path, mode, buf, size);
+ res = try_create_file(state, path, mode, buf, size);
if (res < 0)
return -1;
if (!res)
@@ -4380,7 +4384,7 @@ static int create_one_file(struct apply_state *state,
if (errno == ENOENT) {
if (safe_create_leading_directories(path))
return 0;
- res = try_create_file(path, mode, buf, size);
+ res = try_create_file(state, path, mode, buf, size);
if (res < 0)
return -1;
if (!res)
@@ -4402,7 +4406,7 @@ static int create_one_file(struct apply_state *state,
for (;;) {
char newpath[PATH_MAX];
mksnpath(newpath, sizeof(newpath), "%s~%u", path, nr);
- res = try_create_file(newpath, mode, buf, size);
+ res = try_create_file(state, newpath, mode, buf, size);
if (res < 0)
return -1;
if (!res) {