sha1-name.c: remove the_repo from resolve_relative_path()
"remove" is not entirely correct. But at least the function is aware that if the given repo is not the_repository, then $CWD and is_inside_work_tree() means nothing. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
0488481e79
commit
0381f7f3e9
|
|
@ -1719,12 +1719,12 @@ static void diagnose_invalid_index_path(struct repository *r,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *resolve_relative_path(const char *rel)
|
static char *resolve_relative_path(struct repository *r, const char *rel)
|
||||||
{
|
{
|
||||||
if (!starts_with(rel, "./") && !starts_with(rel, "../"))
|
if (!starts_with(rel, "./") && !starts_with(rel, "../"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!is_inside_work_tree())
|
if (r != the_repository || !is_inside_work_tree())
|
||||||
die("relative path syntax can't be used outside working tree.");
|
die("relative path syntax can't be used outside working tree.");
|
||||||
|
|
||||||
/* die() inside prefix_path() if resolved path is outside worktree */
|
/* die() inside prefix_path() if resolved path is outside worktree */
|
||||||
|
|
@ -1785,7 +1785,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
|
||||||
stage = name[1] - '0';
|
stage = name[1] - '0';
|
||||||
cp = name + 3;
|
cp = name + 3;
|
||||||
}
|
}
|
||||||
new_path = resolve_relative_path(cp);
|
new_path = resolve_relative_path(repo, cp);
|
||||||
if (!new_path) {
|
if (!new_path) {
|
||||||
namelen = namelen - (cp - name);
|
namelen = namelen - (cp - name);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1839,7 +1839,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
|
||||||
const char *filename = cp+1;
|
const char *filename = cp+1;
|
||||||
char *new_filename = NULL;
|
char *new_filename = NULL;
|
||||||
|
|
||||||
new_filename = resolve_relative_path(filename);
|
new_filename = resolve_relative_path(repo, filename);
|
||||||
if (new_filename)
|
if (new_filename)
|
||||||
filename = new_filename;
|
filename = new_filename;
|
||||||
if (flags & GET_OID_FOLLOW_SYMLINKS) {
|
if (flags & GET_OID_FOLLOW_SYMLINKS) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue