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>

Nguyễn Thái Ngọc Duy committed Apr 16, 2019 at 16:33 UTC 0381f7f3e9c1ba03e56d360ce123cac84552955e
1 file changed +4 -4
sha1-name.c
+4 -4
@@ -1719,12 +1719,12 @@ static void diagnose_invalid_index_path(struct repository *r,
1719 }
1720
1721
1722 -static char *resolve_relative_path(const char *rel)
1722 +static char *resolve_relative_path(struct repository *r, const char *rel)
1723 {
1724 if (!starts_with(rel, "./") && !starts_with(rel, "../"))
1725 return NULL;
1726
1727 - if (!is_inside_work_tree())
1727 + if (r != the_repository || !is_inside_work_tree())
1728 die("relative path syntax can't be used outside working tree.");
1729
1730 /* 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,
1785 stage = name[1] - '0';
1786 cp = name + 3;
1787 }
1788 - new_path = resolve_relative_path(cp);
1788 + new_path = resolve_relative_path(repo, cp);
1789 if (!new_path) {
1790 namelen = namelen - (cp - name);
1791 } else {
@@ -1839,7 +1839,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
1839 const char *filename = cp+1;
1840 char *new_filename = NULL;
1841
1842 - new_filename = resolve_relative_path(filename);
1842 + new_filename = resolve_relative_path(repo, filename);
1843 if (new_filename)
1844 filename = new_filename;
1845 if (flags & GET_OID_FOLLOW_SYMLINKS) {