Merge branch 'lt/log-auto-decorate'
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 19:18:41 +0000 (12:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jun 2014 19:18:41 +0000 (12:18 -0700)
* lt/log-auto-decorate:
git log: support "auto" decorations

1  2 
builtin/log.c
diff --combined builtin/log.c
index 83b6c489fcb789dde11172a66fa03f948ca8f759,df6396c9c3d9f19b8e4d21a2873be3ebe0360944..a7ba211731ecc02523c4509878679f050c151f0b
@@@ -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()
        };
                        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) {