Merge branch 'cc/interpret-trailers'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2014 19:25:30 +0000 (12:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2014 19:25:32 +0000 (12:25 -0700)
A new filter to programatically edit the tail end of the commit log
messages.

* cc/interpret-trailers:
Documentation: add documentation for 'git interpret-trailers'
trailer: add tests for commands in config file
trailer: execute command from 'trailer.<name>.command'
trailer: add tests for "git interpret-trailers"
trailer: add interpret-trailers command
trailer: put all the processing together and print
trailer: parse trailers from file or stdin
trailer: process command line trailer arguments
trailer: read and process config information
trailer: process trailers from input message and arguments
trailer: add data structures and basic functions

1  2 
.gitignore
Makefile
git.c
diff --combined .gitignore
index 9ec40fa9fbc645532c9bc36b65521e6771d14324,347d4ff8c2551b589c92cdbc460aa84aaec67c3e..a05241916c9c9a3760a6e98670a7f6427d553d77
@@@ -74,6 -74,7 +74,7 @@@
  /git-index-pack
  /git-init
  /git-init-db
+ /git-interpret-trailers
  /git-instaweb
  /git-log
  /git-ls-files
  /test-revision-walking
  /test-run-command
  /test-sha1
 +/test-sha1-array
  /test-sigchain
  /test-string-list
  /test-subprocess
diff --combined Makefile
index 356feb5c86023d00a41ac8bca7d44f9779c39ad0,3495fff5db0f501b6ae7476b5eaf93cb4ea0012d..fcd51ac463a2f4ae2d748b30df36604d6190fb90
+++ b/Makefile
@@@ -14,11 -14,11 +14,11 @@@ all:
  # Define INLINE to a suitable substitute (such as '__inline' or '') if git
  # fails to compile with errors about undefined inline functions or similar.
  #
 -# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
 +# Define SNPRINTF_RETURNS_BOGUS if you are on a system which snprintf()
  # or vsnprintf() return -1 instead of number of characters which would
  # have been written to the final string if enough space had been available.
  #
 -# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
 +# Define FREAD_READS_DIRECTORIES if you are on a system which succeeds
  # when attempting to read from an fopen'ed directory.
  #
  # Define NO_OPENSSL environment variable if you do not have OpenSSL.
@@@ -568,7 -568,6 +568,7 @@@ TEST_PROGRAMS_NEED_X += test-revision-w
  TEST_PROGRAMS_NEED_X += test-run-command
  TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
  TEST_PROGRAMS_NEED_X += test-sha1
 +TEST_PROGRAMS_NEED_X += test-sha1-array
  TEST_PROGRAMS_NEED_X += test-sigchain
  TEST_PROGRAMS_NEED_X += test-string-list
  TEST_PROGRAMS_NEED_X += test-subprocess
@@@ -764,6 -763,7 +764,7 @@@ LIB_OBJS += submodule.
  LIB_OBJS += symlinks.o
  LIB_OBJS += tag.o
  LIB_OBJS += trace.o
+ LIB_OBJS += trailer.o
  LIB_OBJS += transport.o
  LIB_OBJS += transport-helper.o
  LIB_OBJS += tree-diff.o
@@@ -828,6 -828,7 +829,7 @@@ BUILTIN_OBJS += builtin/hash-object.
  BUILTIN_OBJS += builtin/help.o
  BUILTIN_OBJS += builtin/index-pack.o
  BUILTIN_OBJS += builtin/init-db.o
+ BUILTIN_OBJS += builtin/interpret-trailers.o
  BUILTIN_OBJS += builtin/log.o
  BUILTIN_OBJS += builtin/ls-files.o
  BUILTIN_OBJS += builtin/ls-remote.o
@@@ -1349,9 -1350,6 +1351,9 @@@ ifdef NO_REGE
        COMPAT_CFLAGS += -Icompat/regex
        COMPAT_OBJS += compat/regex/regex.o
  endif
 +ifdef NATIVE_CRLF
 +      BASIC_CFLAGS += -DNATIVE_CRLF
 +endif
  
  ifdef USE_NED_ALLOCATOR
         COMPAT_CFLAGS += -Icompat/nedmalloc
diff --combined git.c
index 4cebf32126014938533b66cb57164c6602a1675c,fac390233c69c5300db4439160f7d8ebea6b7fd2..18fbf79430687a473e9306f2bb65abbaec161bb4
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -14,7 -14,7 +14,7 @@@ const char git_usage_string[] 
        "           <command> [<args>]";
  
  const char git_more_info_string[] =
 -      N_("'git help -a' and 'git help -g' lists available subcommands and some\n"
 +      N_("'git help -a' and 'git help -g' list available subcommands and some\n"
           "concept guides. See 'git help <command>' or 'git help <concept>'\n"
           "to read about a specific subcommand or concept.");
  
@@@ -282,7 -282,8 +282,7 @@@ static int handle_alias(int *argcp, con
                                  "trace: alias expansion: %s =>",
                                  alias_command);
  
 -              new_argv = xrealloc(new_argv, sizeof(char *) *
 -                                  (count + *argcp));
 +              REALLOC_ARRAY(new_argv, count + *argcp);
                /* insert after command name */
                memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
  
@@@ -417,6 -418,7 +417,7 @@@ static struct cmd_struct commands[] = 
        { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
        { "init", cmd_init_db, NO_SETUP },
        { "init-db", cmd_init_db, NO_SETUP },
+       { "interpret-trailers", cmd_interpret_trailers, RUN_SETUP },
        { "log", cmd_log, RUN_SETUP },
        { "ls-files", cmd_ls_files, RUN_SETUP },
        { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
@@@ -592,26 -594,6 +593,26 @@@ static int run_argv(int *argcp, const c
        return done_alias;
  }
  
 +/*
 + * Many parts of Git have subprograms communicate via pipe, expect the
 + * upstream of a pipe to die with SIGPIPE when the downstream of a
 + * pipe does not need to read all that is written.  Some third-party
 + * programs that ignore or block SIGPIPE for their own reason forget
 + * to restore SIGPIPE handling to the default before spawning Git and
 + * break this carefully orchestrated machinery.
 + *
 + * Restore the way SIGPIPE is handled to default, which is what we
 + * expect.
 + */
 +static void restore_sigpipe_to_default(void)
 +{
 +      sigset_t unblock;
 +
 +      sigemptyset(&unblock);
 +      sigaddset(&unblock, SIGPIPE);
 +      sigprocmask(SIG_UNBLOCK, &unblock, NULL);
 +      signal(SIGPIPE, SIG_DFL);
 +}
  
  int main(int argc, char **av)
  {
         */
        sanitize_stdfds();
  
 +      restore_sigpipe_to_default();
 +
        git_setup_gettext();
  
        trace_command_performance(argv);