Skip to content

Commit 21149dc

Browse files
committed
test-tool path-utils: support debugging "dubious ownership" issues
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>
1 parent 51a8889 commit 21149dc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

t/helper/test-path-utils.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,25 @@ int cmd__path_utils(int argc, const char **argv)
503503
return !!res;
504504
}
505505

506+
if (argc > 1 && !strcmp(argv[1], "is_path_owned_by_current_user")) {
507+
int res = 0;
508+
509+
for (int i = 2; i < argc; i++) {
510+
struct strbuf buf = STRBUF_INIT;
511+
512+
if (is_path_owned_by_current_user(argv[i], &buf))
513+
printf("'%s' is owned by current SID\n", argv[i]);
514+
else {
515+
printf("'%s' is not owned by current SID: %s\n", argv[i], buf.buf);
516+
res = 1;
517+
}
518+
519+
strbuf_release(&buf);
520+
}
521+
522+
return res;
523+
}
524+
506525
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
507526
argv[1] ? argv[1] : "(there was none)");
508527
return 1;

0 commit comments

Comments
 (0)