Skip to content

Commit

Permalink
test-tool path-utils: support debugging "dubious ownership" issues
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Jan 1, 2025
1 parent b5836c2 commit daf47da
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions t/helper/test-path-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit daf47da

Please sign in to comment.