]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-log.c
Drop strbuf's 'eof' marker, and make read_line a first class citizen.
[git.git] / builtin-log.c
index 13bae3110e05b804db22149e9eb366669a8147c7..e1d3e7d74bcac3c684d63090265c956b1d579288 100644 (file)
@@ -55,6 +55,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
        rev->abbrev = DEFAULT_ABBREV;
        rev->commit_format = CMIT_FMT_DEFAULT;
        rev->verbose_header = 1;
+       rev->diffopt.recursive = 1;
        rev->show_root_diff = default_show_root;
        rev->subject_prefix = fmt_patch_subject_prefix;
        argc = setup_revisions(argc, argv, rev, "HEAD");
@@ -116,7 +117,6 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
        git_config(git_log_config);
        init_revisions(&rev, prefix);
        rev.diff = 1;
-       rev.diffopt.recursive = 1;
        rev.simplify_history = 0;
        cmd_log_init(argc, argv, prefix, &rev);
        if (!rev.diffopt.output_format)
@@ -165,7 +165,6 @@ int cmd_show(int argc, const char **argv, const char *prefix)
        git_config(git_log_config);
        init_revisions(&rev, prefix);
        rev.diff = 1;
-       rev.diffopt.recursive = 1;
        rev.combine_merges = 1;
        rev.dense_combined_merges = 1;
        rev.always_show_header = 1;
@@ -586,12 +585,19 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        }
 
        if (rev.pending.nr == 1) {
-               if (rev.max_count < 0) {
+               if (rev.max_count < 0 && !rev.show_root_diff) {
+                       /*
+                        * This is traditional behaviour of "git format-patch
+                        * origin" that prepares what the origin side still
+                        * does not have.
+                        */
                        rev.pending.objects[0].item->flags |= UNINTERESTING;
                        add_head(&rev);
                }
-               /* Otherwise, it is "format-patch -22 HEAD", and
-                * get_revision() would return only the specified count.
+               /*
+                * Otherwise, it is "format-patch -22 HEAD", and/or
+                * "format-patch --root HEAD".  The user wants
+                * get_revision() to do the usual traversal.
                 */
        }
 
@@ -757,13 +763,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
                        sign = '-';
 
                if (verbose) {
-                       char *buf = NULL;
-                       unsigned long buflen = 0;
-                       pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
-                                           &buf, &buflen, 0, NULL, NULL, 0);
+                       struct strbuf buf;
+                       strbuf_init(&buf, 0);
+                       pretty_print_commit(CMIT_FMT_ONELINE, commit,
+                                           &buf, 0, NULL, NULL, 0);
                        printf("%c %s %s\n", sign,
-                              sha1_to_hex(commit->object.sha1), buf);
-                       free(buf);
+                              sha1_to_hex(commit->object.sha1), buf.buf);
+                       strbuf_release(&buf);
                }
                else {
                        printf("%c %s\n", sign,