]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/checkout-index: stop using `the_repository`
authorUsman Akinyemi <usmanakinyemi202@gmail.com>
Fri, 7 Mar 2025 23:35:07 +0000 (05:05 +0530)
committerJunio C Hamano <gitster@pobox.com>
Sat, 8 Mar 2025 00:52:02 +0000 (16:52 -0800)
commit09cbf1597edde2b0200ecbf469c78689c4dcb12f
tree2531e1230e1b8f7aee9322c31ab1bd2c30f5e73c
parentd9dce89192504c63787b98961ee514937af88e61
builtin/checkout-index: stop using `the_repository`

Remove the_repository global variable in favor of the repository
argument that gets passed in "builtin/checkout-index.c".

When `-h` is passed to the command outside a Git repository, the
`run_builtin()` will call the `cmd_checkout_index()` 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 an instance of "struct index_state" available in the calling
context to both `checkout_all()` and `checkout_file()` 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>
builtin/checkout-index.c
t/t2006-checkout-index-basic.sh