Code

diff/status: refactor opportunistic index update
[git.git] / builtin / rev-list.c
index 5679170e82ed644d4c3eb4f71f26aa0ac9acce24..efe9360e2fdb9aac3bae0c61c85531041f24708a 100644 (file)
@@ -50,6 +50,15 @@ static void show_commit(struct commit *commit, void *data)
 
        graph_show_commit(revs->graph);
 
+       if (revs->count) {
+               if (commit->object.flags & SYMMETRIC_LEFT)
+                       revs->count_left++;
+               else
+                       revs->count_right++;
+               finish_commit(commit, data);
+               return;
+       }
+
        if (info->show_timestamp)
                printf("%lu ", commit->date);
        if (info->header_prefix)
@@ -133,9 +142,12 @@ static void show_commit(struct commit *commit, void *data)
                                 */
                                if (graph_show_remainder(revs->graph))
                                        putchar('\n');
+                               if (revs->commit_format == CMIT_FMT_ONELINE)
+                                       putchar('\n');
                        }
                } else {
-                       if (buf.len)
+                       if (revs->commit_format != CMIT_FMT_USERFORMAT ||
+                           buf.len)
                                printf("%s%c", buf.buf, info->hdr_termination);
                }
                strbuf_release(&buf);
@@ -313,7 +325,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 
        git_config(git_default_config, NULL);
        init_revisions(&revs, prefix);
-       revs.abbrev = 0;
+       revs.abbrev = DEFAULT_ABBREV;
        revs.commit_format = CMIT_FMT_UNSPECIFIED;
        argc = setup_revisions(argc, argv, &revs, NULL);
 
@@ -397,5 +409,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
                             quiet ? finish_object : show_object,
                             &info);
 
+       if (revs.count) {
+               if (revs.left_right)
+                       printf("%d\t%d\n", revs.count_left, revs.count_right);
+               else
+                       printf("%d\n", revs.count_left + revs.count_right);
+       }
+
        return 0;
 }