From: Junio C Hamano Date: Mon, 16 Jun 2014 19:18:41 +0000 (-0700) Subject: Merge branch 'lt/log-auto-decorate' X-Git-Tag: v2.1.0-rc0~109 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3009afd54ecbac1b7cd556085cd2d32f3d6772d3?ds=inline;hp=-c Merge branch 'lt/log-auto-decorate' * lt/log-auto-decorate: git log: support "auto" decorations --- 3009afd54ecbac1b7cd556085cd2d32f3d6772d3 diff --combined builtin/log.c index 83b6c489fc,df6396c9c3..a7ba211731 --- a/builtin/log.c +++ b/builtin/log.c @@@ -63,6 -63,8 +63,8 @@@ static int parse_decoration_style(cons return DECORATE_FULL_REFS; else if (!strcmp(value, "short")) return DECORATE_SHORT_REFS; + else if (!strcmp(value, "auto")) + return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0; return -1; } @@@ -158,9 -160,13 +160,9 @@@ static void cmd_log_init_finish(int arg if (rev->show_notes) init_display_notes(&rev->notes_opt); - if (rev->diffopt.pickaxe || rev->diffopt.filter) + if (rev->diffopt.pickaxe || rev->diffopt.filter || + DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) rev->always_show_header = 0; - if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) { - rev->always_show_header = 0; - if (rev->diffopt.pathspec.nr != 1) - usage("git logs can only follow renames on one pathname at a time"); - } if (source) rev->show_source = 1; @@@ -669,7 -675,6 +671,7 @@@ static void add_header(const char *valu static int thread; static int do_signoff; static const char *signature = git_version_string; +static const char *signature_file; static int config_cover_letter; enum { @@@ -739,8 -744,6 +741,8 @@@ static int git_format_config(const cha } if (!strcmp(var, "format.signature")) return git_config_string(&signature, var, value); + if (!strcmp(var, "format.signaturefile")) + return git_config_pathname(&signature_file, var, value); if (!strcmp(var, "format.coverletter")) { if (value && !strcasecmp(value, "auto")) { config_cover_letter = COVER_AUTO; @@@ -843,13 -846,8 +845,13 @@@ static void gen_message_id(struct rev_i static void print_signature(void) { - if (signature && *signature) - printf("-- \n%s\n\n", signature); + if (!signature || !*signature) + return; + + printf("-- \n%s", signature); + if (signature[strlen(signature)-1] != '\n') + putchar('\n'); + putchar('\n'); } static void add_branch_description(struct strbuf *buf, const char *branch_name) @@@ -1234,8 -1232,6 +1236,8 @@@ int cmd_format_patch(int argc, const ch PARSE_OPT_OPTARG, thread_callback }, OPT_STRING(0, "signature", &signature, N_("signature"), N_("add a signature")), + OPT_FILENAME(0, "signature-file", &signature_file, + N_("add a signature from a file")), OPT__QUIET(&quiet, N_("don't print the patch filenames")), OPT_END() }; @@@ -1453,18 -1449,6 +1455,18 @@@ cover_letter = (config_cover_letter == COVER_ON); } + if (!signature) { + ; /* --no-signature inhibits all signatures */ + } else if (signature && signature != git_version_string) { + ; /* non-default signature already set */ + } else if (signature_file) { + struct strbuf buf = STRBUF_INIT; + + if (strbuf_read_file(&buf, signature_file, 128) < 0) + die_errno(_("unable to read signature file '%s'"), signature_file); + signature = strbuf_detach(&buf, NULL); + } + if (in_reply_to || thread || cover_letter) rev.ref_message_ids = xcalloc(1, sizeof(struct string_list)); if (in_reply_to) {