Merge branch 'as/pre-push-hook'
authorJunio C Hamano <gitster@pobox.com>
Thu, 24 Jan 2013 05:19:25 +0000 (21:19 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Jan 2013 05:19:25 +0000 (21:19 -0800)
Add an extra hook so that "git push" that is run without making
sure what is being pushed is sane can be checked and rejected (as
opposed to the user deciding not pushing).

* as/pre-push-hook:
Add sample pre-push hook script
push: Add support for pre-push hooks
hooks: Add function to check if a hook exists

1  2 
builtin/commit.c
diff --combined builtin/commit.c
index 7c2a3d48b4ac6bf6f55539946adacb433b51dabb,65d08d21f4469c64ff3881e589d21a86b8373134..38b9a9cc0d0e1beba3258f907e95ae1ad76f85f5
@@@ -103,7 -103,7 +103,7 @@@ static enum 
        CLEANUP_NONE,
        CLEANUP_ALL
  } cleanup_mode;
 -static char *cleanup_arg;
 +static const char *cleanup_arg;
  
  static enum commit_whence whence;
  static int use_editor = 1, include_status = 1;
@@@ -1320,8 -1320,6 +1320,8 @@@ static int git_commit_config(const cha
                include_status = git_config_bool(k, v);
                return 0;
        }
 +      if (!strcmp(k, "commit.cleanup"))
 +              return git_config_string(&cleanup_arg, k, v);
  
        status = git_gpg_config(k, v, NULL);
        if (status)
        return git_status_config(k, v, s);
  }
  
- static const char post_rewrite_hook[] = "hooks/post-rewrite";
  static int run_rewrite_hook(const unsigned char *oldsha1,
                            const unsigned char *newsha1)
  {
        int code;
        size_t n;
  
-       if (access(git_path(post_rewrite_hook), X_OK) < 0)
+       argv[0] = find_hook("post-rewrite");
+       if (!argv[0])
                return 0;
  
-       argv[0] = git_path(post_rewrite_hook);
        argv[1] = "amend";
        argv[2] = NULL;