]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `path_inside_repo()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 19 May 2026 09:52:09 +0000 (11:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2026 10:36:24 +0000 (19:36 +0900)
Stop using `the_repository` in `path_inside_repo()` and instead accept
the repository as a parameter. The injection of `the_repository` is thus
bumped one level higher, where callers now pass it in explicitly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff.c
setup.c
setup.h

index 0b23c41456837f41eb82c1a154ef30af74e11cbf..7ddebce2ac7cecc558c51595a9e13624a355a1eb 100644 (file)
@@ -471,8 +471,8 @@ int cmd_diff(int argc,
                 * as a colourful "diff" replacement.
                 */
                if (nongit || ((argc == i + 2) &&
-                              (!path_inside_repo(prefix, argv[i]) ||
-                               !path_inside_repo(prefix, argv[i + 1]))))
+                              (!path_inside_repo(the_repository, prefix, argv[i]) ||
+                               !path_inside_repo(the_repository, prefix, argv[i + 1]))))
                        no_index = DIFF_NO_INDEX_IMPLICIT;
        }
 
diff --git a/setup.c b/setup.c
index adad6ceec0cfa740640e45d3e55d8bb893a36aa1..4ef6216e829d3fbe11b7bf877ba569d9f613c164 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -160,10 +160,10 @@ char *prefix_path(struct repository *repo, const char *prefix, int len, const ch
        return r;
 }
 
-int path_inside_repo(const char *prefix, const char *path)
+int path_inside_repo(struct repository *repo, const char *prefix, const char *path)
 {
        int len = prefix ? strlen(prefix) : 0;
-       char *r = prefix_path_gently(the_repository, prefix, len, NULL, path);
+       char *r = prefix_path_gently(repo, prefix, len, NULL, path);
        if (r) {
                free(r);
                return 1;
diff --git a/setup.h b/setup.h
index 24034572b150c7e2c164024c0a3385dbcd4a2201..c3247d7fc8d4b7787510a59352f9672a4122cc42 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -146,7 +146,7 @@ void verify_filename(const char *prefix,
                     const char *name,
                     int diagnose_misspelt_rev);
 void verify_non_filename(const char *prefix, const char *name);
-int path_inside_repo(const char *prefix, const char *path);
+int path_inside_repo(struct repository *repo, const char *prefix, const char *path);
 
 void sanitize_stdfds(void);
 int daemonize(void);