replace.c: use the ref transaction functions for updates
[gitweb.git] / builtin / log.c
index b97373da3b2687e18b5eba96382049382d1536fd..a7ba211731ecc02523c4509878679f050c151f0b 100644 (file)
@@ -63,6 +63,8 @@ static int parse_decoration_style(const char *var, const char *value)
                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,13 +160,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
        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;
@@ -503,7 +501,7 @@ static void show_rev_tweak_rev(struct rev_info *rev, struct setup_revision_opt *
                /* There was no "-m" on the command line */
                rev->ignore_merges = 0;
                if (!rev->first_parent_only && !rev->combine_merges) {
-                       /* No "--first-parent", "-c", nor "--cc" */
+                       /* No "--first-parent", "-c", or "--cc" */
                        rev->combine_merges = 1;
                        rev->dense_combined_merges = 1;
                }
@@ -673,6 +671,7 @@ static void add_header(const char *value)
 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 {
@@ -742,6 +741,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
        }
        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;
@@ -844,8 +845,13 @@ static void gen_message_id(struct rev_info *info, char *base)
 
 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)
@@ -1230,6 +1236,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            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()
        };
@@ -1447,6 +1455,18 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        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) {