Remove cmd_usage() routine and re-organize the help/usage code.
The cmd_usage() routine was causing warning messages due to a NULL format parameter being passed in three out of four calls. This is a problem if you want to compile with -Werror. A simple solution is to simply remove the GNU __attribute__ format pragma from the cmd_usage() declaration in the header file. The function interface was somewhat muddled anyway, so re-write the code to finesse the problem. [jc: this incidentally revealed that t9100 test assumed that the output from "git help" to be fixed in stone, but this patch lower-cases "Usage" to "usage". Update the test not to rely on "git help" output.] Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
8e76483ce0
commit
822a7d5071
7
git.c
7
git.c
@ -15,6 +15,9 @@
|
||||
|
||||
#include "builtin.h"
|
||||
|
||||
const char git_usage_string[] =
|
||||
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
|
||||
|
||||
static void prepend_to_path(const char *dir, int len)
|
||||
{
|
||||
const char *old_path = getenv("PATH");
|
||||
@ -78,7 +81,7 @@ static int handle_options(const char*** argv, int* argc)
|
||||
setenv("GIT_DIR", getcwd(git_dir, 1024), 1);
|
||||
} else {
|
||||
fprintf(stderr, "Unknown option: %s\n", cmd);
|
||||
cmd_usage(0, NULL, NULL);
|
||||
usage(git_usage_string);
|
||||
}
|
||||
|
||||
(*argv)++;
|
||||
@ -375,7 +378,7 @@ int main(int argc, const char **argv, char **envp)
|
||||
}
|
||||
|
||||
if (errno == ENOENT)
|
||||
cmd_usage(0, exec_path, "'%s' is not a git-command", cmd);
|
||||
help_unknown_cmd(cmd);
|
||||
|
||||
fprintf(stderr, "Failed to run command '%s': %s\n",
|
||||
cmd, strerror(errno));
|
||||
|
Reference in New Issue
Block a user