Re: [PATCH v2 2/4] run_builtin(): save "-h" detection result for later use
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:49:50
Nguyễn Thái Ngọc Duy [off-list ref] writes:
When run_builtin() sees "-h" as the first argument, it assumes: - this is the call for help usage - the real git command will only print help usage then exit So it skips all setup in this case. Unfortunately, some commands do other things before calling parse_options(), which is often where the help usage is printed. Some of those things may try to access the repository unnecessarily. If a repository is broken, the command may die() before it prints help usage, not really helpful.
What does die() message say in that case? If it says "your repository is broken", that may be more useful than giving a help message. I dunno.
Demonstrating "git foo -h" fails depends on individual commands and is generally difficult to do. Instead GIT_TRACE is used to check if a command does set repo. If it does, it is supposed to fail if repo setup code chokes.
Hmm, I am not sure I understand this one. If you are interested in changing the behaviour of these commands when run with "-h" in a corrupt repository, perhaps you can deliberately corrupt the test repository in the trash directory you start with, and run these commands there, no? For a good measure, you could use CEILING_DIRECTORIES to make sure the tests do not climb up to the project repository.