Commit 848bd009 by Edward Thomson

blob: improve `create_from_disk` attribute lookups

Resolve absolute paths to be working directory relative when looking up
attributes.  Importantly, now we will _never_ pass an absolute path down
to attribute lookup functions.
parent 0f4256b8
......@@ -277,21 +277,20 @@ int git_blob_create_from_disk(
{
int error;
git_buf full_path = GIT_BUF_INIT;
const char *workdir, *hintpath;
const char *workdir, *hintpath = NULL;
if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
git_buf_dispose(&full_path);
return error;
}
hintpath = git_buf_cstr(&full_path);
workdir = git_repository_workdir(repo);
if (workdir && !git__prefixcmp(hintpath, workdir))
hintpath += strlen(workdir);
if (workdir && !git__prefixcmp(full_path.ptr, workdir))
hintpath = full_path.ptr + strlen(workdir);
error = git_blob__create_from_paths(
id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, true);
id, NULL, repo, git_buf_cstr(&full_path), hintpath, 0, !!hintpath);
git_buf_dispose(&full_path);
return error;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment