From: Junio C Hamano Date: Mon, 20 Oct 2014 19:25:30 +0000 (-0700) Subject: Merge branch 'cc/interpret-trailers' X-Git-Tag: v2.2.0-rc0~34 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9d04401ffe18138138e8f765c2bb31420f3efe25?ds=inline;hp=-c Merge branch 'cc/interpret-trailers' 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..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 --- 9d04401ffe18138138e8f765c2bb31420f3efe25 diff --combined .gitignore index 9ec40fa9fb,347d4ff8c2..a05241916c --- a/.gitignore +++ b/.gitignore @@@ -74,6 -74,7 +74,7 @@@ /git-index-pack /git-init /git-init-db + /git-interpret-trailers /git-instaweb /git-log /git-ls-files @@@ -199,7 -200,6 +200,7 @@@ /test-revision-walking /test-run-command /test-sha1 +/test-sha1-array /test-sigchain /test-string-list /test-subprocess diff --combined Makefile index 356feb5c86,3495fff5db..fcd51ac463 --- a/Makefile +++ 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 4cebf32126,fac390233c..18fbf79430 --- a/git.c +++ b/git.c @@@ -14,7 -14,7 +14,7 @@@ const char git_usage_string[] " []"; 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 ' or 'git help '\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) { @@@ -631,8 -613,6 +632,8 @@@ */ sanitize_stdfds(); + restore_sigpipe_to_default(); + git_setup_gettext(); trace_command_performance(argv);