checkout: always provide a path for attribute lookup Always pass a working-directory relative path to attribute lookups during checkout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/src/checkout.c b/src/checkout.c
index 7131591..3a17106 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1520,8 +1520,7 @@ static int blob_content_to_file(
int fd;
int error = 0;
- if (hint_path == NULL)
- hint_path = path;
+ GIT_ASSERT(hint_path != NULL);
if ((error = mkpath2file(data, path, data->opts.dir_mode)) < 0)
return error;
@@ -1789,7 +1788,7 @@ static int checkout_blob(
}
error = checkout_write_content(
- data, &file->id, fullpath->ptr, NULL, file->mode, &st);
+ data, &file->id, fullpath->ptr, file->path, file->mode, &st);
/* update the index unless prevented */
if (!error && (data->strategy & GIT_CHECKOUT_DONT_UPDATE_INDEX) == 0)
@@ -1975,7 +1974,7 @@ static int checkout_write_entry(
checkout_conflictdata *conflict,
const git_index_entry *side)
{
- const char *hint_path = NULL, *suffix;
+ const char *hint_path, *suffix;
git_buf *fullpath;
struct stat st;
int error;
@@ -1998,10 +1997,10 @@ static int checkout_write_entry(
if (checkout_path_suffixed(fullpath, suffix) < 0)
return -1;
-
- hint_path = side->path;
}
+ hint_path = side->path;
+
if ((data->strategy & GIT_CHECKOUT_UPDATE_ONLY) != 0 &&
(error = checkout_safe_for_update_only(data, fullpath->ptr, side->mode)) <= 0)
return error;
@@ -2118,7 +2117,7 @@ static int checkout_write_merge(
filter_session.temp_buf = &data->tmp;
if ((error = git_filter_list__load(
- &fl, data->repo, NULL, git_buf_cstr(&path_workdir),
+ &fl, data->repo, NULL, result.path,
GIT_FILTER_TO_WORKTREE, &filter_session)) < 0 ||
(error = git_filter_list__convert_buf(&out_data, fl, &in_data)) < 0)
goto done;