[PATCH] Write sed script directly into temp file, rather than a variable
[git.git] / rev-list.c
index e4d167c..0dd4512 100644 (file)
@@ -9,7 +9,6 @@
 #define INTERESTING    (1u << 1)
 #define COUNTED                (1u << 2)
 #define SHOWN          (1u << 3)
-#define DUPCHECK       (1u << 4)
 
 static const char rev_list_usage[] =
        "usage: git-rev-list [OPTION] commit-id <commit-id>\n"
@@ -39,6 +38,7 @@ static enum cmit_fmt commit_format = CMIT_FMT_RAW;
 static int merge_order = 0;
 static int show_breaks = 0;
 static int stop_traversal = 0;
+static int topo_order = 0;
 
 static void show_commit(struct commit *commit)
 {
@@ -70,19 +70,15 @@ static void show_commit(struct commit *commit)
 
 static int filter_commit(struct commit * commit)
 {
-       if (merge_order && stop_traversal && commit->object.flags & BOUNDARY)
+       if (stop_traversal && (commit->object.flags & BOUNDARY))
                return STOP;
        if (commit->object.flags & (UNINTERESTING|SHOWN))
                return CONTINUE;
        if (min_age != -1 && (commit->date > min_age))
                return CONTINUE;
        if (max_age != -1 && (commit->date < max_age)) {
-               if (!merge_order)
-                       return STOP;
-               else {
-                       stop_traversal = 1;
-                       return CONTINUE;
-               }
+               stop_traversal=1;
+               return merge_order?CONTINUE:STOP;
        }
        if (max_count != -1 && !max_count--)
                return STOP;
@@ -474,6 +470,11 @@ int main(int argc, char **argv)
                        show_breaks = 1;
                        continue;
                }
+               if (!strcmp(arg, "--topo-order")) {
+                       topo_order = 1;
+                       limited = 1;
+                       continue;
+               }
 
                flags = 0;
                if (*arg == '^') {
@@ -486,15 +487,17 @@ int main(int argc, char **argv)
                commit = get_commit_reference(arg, flags);
                if (!commit)
                        continue;
-               if (commit->object.flags & DUPCHECK)
+               if (commit->object.flags & SEEN)
                        continue;
-               commit->object.flags |= DUPCHECK;
+               commit->object.flags |= SEEN;
                insert(commit, &list);
        }
 
        if (!merge_order) {             
                if (limited)
                        list = limit_list(list);
+               if (topo_order)
+                       sort_in_topological_order(&list);
                show_commit_list(list);
        } else {
                if (sort_list_in_merge_order(list, &process_commit)) {