From: Junio C Hamano Date: Thu, 22 Jan 2009 00:50:43 +0000 (-0800) Subject: Merge branch 'sb/hook-cleanup' X-Git-Tag: v1.6.2-rc0~108 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1afcde6da1221bdb85a3630d995f9ca384042cb9?hp=-c Merge branch 'sb/hook-cleanup' * sb/hook-cleanup: run_hook(): allow more than 9 hook arguments run_hook(): check the executability of the hook before filling argv api-run-command.txt: talk about run_hook() Move run_hook() from builtin-commit.c into run-command.c (libgit) checkout: don't crash on file checkout before running post-checkout hook --- 1afcde6da1221bdb85a3630d995f9ca384042cb9 diff --combined builtin-commit.c index b159af2e54,6f8d9fbfe6..7aaa5304c7 --- a/builtin-commit.c +++ b/builtin-commit.c @@@ -361,40 -361,6 +361,6 @@@ static int run_status(FILE *fp, const c return s.commitable; } - static int run_hook(const char *index_file, const char *name, ...) - { - struct child_process hook; - const char *argv[10], *env[2]; - char index[PATH_MAX]; - va_list args; - int i; - - va_start(args, name); - argv[0] = git_path("hooks/%s", name); - i = 0; - do { - if (++i >= ARRAY_SIZE(argv)) - die ("run_hook(): too many arguments"); - argv[i] = va_arg(args, const char *); - } while (argv[i]); - va_end(args); - - snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file); - env[0] = index; - env[1] = NULL; - - if (access(argv[0], X_OK) < 0) - return 0; - - memset(&hook, 0, sizeof(hook)); - hook.argv = argv; - hook.no_stdin = 1; - hook.stdout_to_stderr = 1; - hook.env = env; - - return run_command(&hook); - } - static int is_a_merge(const unsigned char *sha1) { struct commit *commit = lookup_commit(sha1); @@@ -624,6 -590,7 +590,6 @@@ static int prepare_to_commit(const cha if (!commitable && !in_merge && !allow_empty && !(amend && is_a_merge(head_sha1))) { run_status(stdout, index_file, prefix, 0); - unlink(commit_editmsg); return 0; } @@@ -865,9 -832,6 +831,9 @@@ int cmd_status(int argc, const char **a if (wt_status_use_color == -1) wt_status_use_color = git_use_color_default; + if (diff_use_color_default == -1) + diff_use_color_default = git_use_color_default; + argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix); index_file = prepare_index(argc, argv, prefix); @@@ -883,7 -847,7 +849,7 @@@ static void print_summary(const char *p { struct rev_info rev; struct commit *commit; - static const char *format = "format:%h: \"%s\""; + static const char *format = "format:%h] %s"; unsigned char junk_sha1[20]; const char *head = resolve_ref("HEAD", junk_sha1, 0, NULL); @@@ -910,7 -874,7 +876,7 @@@ rev.diffopt.break_opt = 0; diff_setup_done(&rev.diffopt); - printf("[%s%s]: created ", + printf("[%s%s ", !prefixcmp(head, "refs/heads/") ? head + 11 : !strcmp(head, "HEAD") ? @@@ -947,9 -911,6 +913,9 @@@ int cmd_commit(int argc, const char **a git_config(git_commit_config, NULL); + if (wt_status_use_color == -1) + wt_status_use_color = git_use_color_default; + argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix); index_file = prepare_index(argc, argv, prefix);