aboutsummaryrefslogtreecommitdiffstats
path: root/t/t3004-ls-files-basic.sh
diff options
context:
space:
mode:
authorUsman Akinyemi <usmanakinyemi202@gmail.com>2025-03-08 05:05:05 +0530
committerJunio C Hamano <gitster@pobox.com>2025-03-07 16:52:01 -0800
commitd9c5cfb18f4dff87db7d28846bd754c009f6043d (patch)
treedd3837e770d9883544a81a63ed26d345263abad3 /t/t3004-ls-files-basic.sh
parent72fe8bfac832a1f1b9b7cdc4efa793c48e13933e (diff)
downloadgit-d9c5cfb18f4dff87db7d28846bd754c009f6043d.tar.gz
builtin/ls-files: stop using `the_repository`
Remove the_repository global variable in favor of the repository argument that gets passed in "builtin/ls-files.c". When `-h` is passed to the command outside a Git repository, the `run_builtin()` will call the `cmd_ls_files()` function with `repo` set to NULL and then early in the function, `show_usage_with_options_if_asked()` call will give the options help and exit. Pass the repository available in the calling context to both `expand_objectsize()` and `show_ru_info()` to remove their dependency on the global `the_repository` variable. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3004-ls-files-basic.sh')
-rwxr-xr-xt/t3004-ls-files-basic.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh
index a1078f8701..4034a5a59f 100755
--- a/t/t3004-ls-files-basic.sh
+++ b/t/t3004-ls-files-basic.sh
@@ -34,6 +34,13 @@ test_expect_success 'ls-files -h in corrupt repository' '
test_grep "[Uu]sage: git ls-files " broken/usage
'
+test_expect_success 'ls-files does not crash with -h' '
+ test_expect_code 129 git ls-files -h >usage &&
+ test_grep "[Uu]sage: git ls-files " usage &&
+ test_expect_code 129 nongit git ls-files -h >usage &&
+ test_grep "[Uu]sage: git ls-files " usage
+'
+
test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
mkdir subs &&
ln -s nosuch link &&