]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-tool path-utils: support debugging "dubious ownership" issues
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 25 Mar 2025 10:38:30 +0000 (10:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Mar 2025 11:45:56 +0000 (04:45 -0700)
This adds a new sub-sub-command for `test-tool`, simply passing through
the command-line arguments to the `is_path_owned_by_current_user()`
function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-path-utils.c

index 72ac8d1b1b011de48ddc62dfae4b21f4132559a0..f3c59e5028561cec633714b1e90d4717f4af613c 100644 (file)
@@ -504,6 +504,25 @@ int cmd__path_utils(int argc, const char **argv)
                return !!res;
        }
 
+       if (argc > 1 && !strcmp(argv[1], "is_path_owned_by_current_user")) {
+               int res = 0;
+
+               for (int i = 2; i < argc; i++) {
+                       struct strbuf buf = STRBUF_INIT;
+
+                       if (is_path_owned_by_current_user(argv[i], &buf))
+                               printf("'%s' is owned by current SID\n", argv[i]);
+                       else {
+                               printf("'%s' is not owned by current SID: %s\n", argv[i], buf.buf);
+                               res = 1;
+                       }
+
+                       strbuf_release(&buf);
+               }
+
+               return res;
+       }
+
        fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
                argv[1] ? argv[1] : "(there was none)");
        return 1;