Merge branch 'sb/hook-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:50:43 +0000 (16:50 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:50:43 +0000 (16:50 -0800)
* 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

1  2 
builtin-commit.c
diff --combined builtin-commit.c
index b159af2e5461a43d9dba11ee7b66676fd68b74b2,6f8d9fbfe627cb48314040673f99a5ef45a87e6e..7aaa5304c7d573f2f7750d58888621b0e82f3712
@@@ -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);
  
        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);