Skip to content

Commit 0381f7f

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0488481 commit 0381f7f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sha1-name.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,12 +1719,12 @@ static void diagnose_invalid_index_path(struct repository *r,
17191719
}
17201720

17211721

1722-
static char *resolve_relative_path(const char *rel)
1722+
static char *resolve_relative_path(struct repository *r, const char *rel)
17231723
{
17241724
if (!starts_with(rel, "./") && !starts_with(rel, "../"))
17251725
return NULL;
17261726

1727-
if (!is_inside_work_tree())
1727+
if (r != the_repository || !is_inside_work_tree())
17281728
die("relative path syntax can't be used outside working tree.");
17291729

17301730
/* 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,
17851785
stage = name[1] - '0';
17861786
cp = name + 3;
17871787
}
1788-
new_path = resolve_relative_path(cp);
1788+
new_path = resolve_relative_path(repo, cp);
17891789
if (!new_path) {
17901790
namelen = namelen - (cp - name);
17911791
} else {
@@ -1839,7 +1839,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
18391839
const char *filename = cp+1;
18401840
char *new_filename = NULL;
18411841

1842-
new_filename = resolve_relative_path(filename);
1842+
new_filename = resolve_relative_path(repo, filename);
18431843
if (new_filename)
18441844
filename = new_filename;
18451845
if (flags & GET_OID_FOLLOW_SYMLINKS) {

0 commit comments

Comments
 (0)