]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-log.c
Handle missing prefix for "Subject:" as if no prefix given
[thirdparty/git.git] / builtin-log.c
index 0aede7683986aff131f9278a968c84622c01181b..5dc2c1c23061e4e25156a373c9692c026652b69a 100644 (file)
@@ -58,6 +58,11 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
        argc = setup_revisions(argc, argv, rev, "HEAD");
        if (rev->diffopt.pickaxe || rev->diffopt.filter)
                rev->always_show_header = 0;
+       if (rev->diffopt.follow_renames) {
+               rev->always_show_header = 0;
+               if (rev->diffopt.nr_paths != 1)
+                       usage("git logs can only follow renames on one pathname at a time");
+       }
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
                if (!strcmp(arg, "--decorate")) {
@@ -260,6 +265,7 @@ static int istitlechar(char c)
 
 static char *extra_headers = NULL;
 static int extra_headers_size = 0;
+static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_patch_suffix = ".patch";
 
 static int git_format_config(const char *var, const char *value)
@@ -285,6 +291,13 @@ static int git_format_config(const char *var, const char *value)
        if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
                return 0;
        }
+       if (!strcmp(var, "format.subjectprefix")) {
+               if (!value)
+                       die("format.subjectprefix without value");
+               fmt_patch_subject_prefix = xstrdup(value);
+               return 0;
+       }
+
        return git_log_config(var, value);
 }
 
@@ -454,6 +467,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        rev.diffopt.msg_sep = "";
        rev.diffopt.recursive = 1;
 
+       rev.subject_prefix = fmt_patch_subject_prefix;
        rev.extra_headers = extra_headers;
 
        /*
@@ -584,7 +598,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                get_patch_ids(&rev, &ids, prefix);
 
        if (!use_stdout)
-               realstdout = fdopen(dup(1), "w");
+               realstdout = xfdopen(xdup(1), "w");
 
        prepare_revision_walk(&rev);
        while ((commit = get_revision(&rev)) != NULL) {
@@ -742,11 +756,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                        sign = '-';
 
                if (verbose) {
-                       static char buf[16384];
+                       char *buf = NULL;
+                       unsigned long buflen = 0;
                        pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
-                                           buf, sizeof(buf), 0, NULL, NULL, 0);
+                                           &buf, &buflen, 0, NULL, NULL, 0);
                        printf("%c %s %s\n", sign,
                               sha1_to_hex(commit->object.sha1), buf);
+                       free(buf);
                }
                else {
                        printf("%c %s\n", sign,