Clean up commit insertion in git-rev-list
[gitweb.git] / rev-list.c
index abb611f8b50a97b96981bec606a2eb85b8888596..c20fec804e1fd4f88ee03647d5e86bb1e6e06e0c 100644 (file)
@@ -15,10 +15,14 @@ static const char rev_list_usage[] =
                      "  --max-count=nr\n"
                      "  --max-age=epoch\n"
                      "  --min-age=epoch\n"
+                     "  --bisect\n"
+                     "  --objects\n"
+                     "  --unpacked\n"
                      "  --header\n"
                      "  --pretty\n"
                      "  --merge-order [ --show-breaks ]";
 
+static int unpacked = 0;
 static int bisect_list = 0;
 static int tag_objects = 0;
 static int tree_objects = 0;
@@ -59,7 +63,8 @@ static void show_commit(struct commit *commit)
                static char pretty_header[16384];
                pretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header));
                printf("%s%c", pretty_header, hdr_termination);
-       }       
+       }
+       fflush(stdout);
 }
 
 static int filter_commit(struct commit * commit)
@@ -318,6 +323,8 @@ static struct commit_list *limit_list(struct commit_list *list)
                struct commit *commit = pop_most_recent_commit(&list, SEEN);
                struct object *obj = &commit->object;
 
+               if (unpacked && has_sha1_pack(obj->sha1))
+                       obj->flags |= UNINTERESTING;
                if (obj->flags & UNINTERESTING) {
                        mark_parents_uninteresting(commit);
                        if (everybody_uninteresting(list))
@@ -406,8 +413,10 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
 int main(int argc, char **argv)
 {
        struct commit_list *list = NULL;
+       struct commit_list *(*insert)(struct commit *, struct commit_list **);
        int i, limited = 0;
 
+       insert = insert_by_date;
        for (i = 1 ; i < argc; i++) {
                int flags;
                char *arg = argv[i];
@@ -450,11 +459,17 @@ int main(int argc, char **argv)
                        blob_objects = 1;
                        continue;
                }
-               if (!strncmp(arg, "--merge-order", 13)) {
+               if (!strcmp(arg, "--unpacked")) {
+                       unpacked = 1;
+                       limited = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--merge-order")) {
                        merge_order = 1;
+                       insert = commit_list_insert;
                        continue;
                }
-               if (!strncmp(arg, "--show-breaks", 13)) {
+               if (!strcmp(arg, "--show-breaks")) {
                        show_breaks = 1;
                        continue;
                }
@@ -470,7 +485,7 @@ int main(int argc, char **argv)
                commit = get_commit_reference(arg, flags);
                if (!commit)
                        continue;
-               commit_list_insert(commit, &list);
+               insert(commit, &list);
        }
 
        if (!merge_order) {