[PATCH] mailinfo: reset CTE after each multipart
[git.git] / rev-list.c
index 7d3ddc6..a554e07 100644 (file)
@@ -12,6 +12,7 @@
 #define COUNTED                (1u << 2)
 #define SHOWN          (1u << 3)
 #define TREECHANGE     (1u << 4)
+#define TMP_MARK       (1u << 5) /* for isolated cases; clean after use */
 
 static const char rev_list_usage[] =
 "git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
@@ -21,6 +22,7 @@ static const char rev_list_usage[] =
 "    --min-age=epoch\n"
 "    --sparse\n"
 "    --no-merges\n"
+"    --remove-empty\n"
 "    --all\n"
 "  ordering output:\n"
 "    --merge-order [ --show-breaks ]\n"
@@ -71,9 +73,21 @@ static void show_commit(struct commit *commit)
        if (show_parents) {
                struct commit_list *parents = commit->parents;
                while (parents) {
-                       printf(" %s", sha1_to_hex(parents->item->object.sha1));
+                       struct object *o = &(parents->item->object);
                        parents = parents->next;
+                       if (o->flags & TMP_MARK)
+                               continue;
+                       printf(" %s", sha1_to_hex(o->sha1));
+                       o->flags |= TMP_MARK;
                }
+               /* TMP_MARK is a general purpose flag that can
+                * be used locally, but the user should clean
+                * things up after it is done with them.
+                */
+               for (parents = commit->parents;
+                    parents;
+                    parents = parents->next)
+                       parents->item->object.flags &= ~TMP_MARK;
        }
        if (commit_format == CMIT_FMT_ONELINE)
                putchar(' ');
@@ -82,7 +96,7 @@ static void show_commit(struct commit *commit)
 
        if (verbose_header) {
                static char pretty_header[16384];
-               pretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header));
+               pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), 0);
                printf("%s%c", pretty_header, hdr_termination);
        }
        fflush(stdout);
@@ -748,6 +762,21 @@ int main(int argc, const char **argv)
                struct commit *commit;
                unsigned char sha1[20];
 
+               /* accept -<digit>, like traditilnal "head" */
+               if ((*arg == '-') && isdigit(arg[1])) {
+                       max_count = atoi(arg + 1);
+                       continue;
+               }
+               if (!strcmp(arg, "-n")) {
+                       if (++i >= argc)
+                               die("-n requires an argument");
+                       max_count = atoi(argv[i]);
+                       continue;
+               }
+               if (!strncmp(arg,"-n",2)) {
+                       max_count = atoi(arg + 2);
+                       continue;
+               }
                if (!strncmp(arg, "--max-count=", 12)) {
                        max_count = atoi(arg + 12);
                        continue;