{"thread":{"id":"1090","subject":"[RESUBMITTED PATCH 1/2] Add --topo-order flag to git-rev-list [rev2]","startedAt":"2005-07-02T08:39:40Z","lastAt":"2005-07-02T08:39:40Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"5565","messageId":"20050702083940.19107.qmail@blackcubes.dyndns.org","threadId":"1090","inReplyTo":null,"subject":"[RESUBMITTED PATCH 1/2] Add --topo-order flag to git-rev-list [rev2]","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-07-02T08:39:40Z","receivedAt":"2005-07-02T08:39:40Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nAdded a --topo-order flag to git-rev-list.\n\nWhen this flag is specified, git-rev-list sorts its output\nin topological order. That is:\n\n\ta is reachable from b ==> ord(b) < ord(a)\n\nThis ordering invariant is weaker than the --merge-order invariant\nbut should be sufficient for tools just as gitk that only\nneed the minimum guarantee provided by --topo-order.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\nNote: this patch assumes that my previous patch series that introduces\nsort_in_topological_order() to commit.c has been applied.\n\nA subsequent patch to gitk will make gitk use --topo-order instead\nof --merge-order.\n\n[rev2]\n   * this patch rescues the --topo-order patch that I withdrew\n     by recognizing that if limit_list is called, sort_commit_list\n     does not do a chronological sort\n   * ensures limit_list is called whenever a topological sort is\n     is required\n   * removed excess braces\n---\n\n rev-list.c |   29 +++++++++++++++++++++--------\n 1 files changed, 21 insertions(+), 8 deletions(-)\n\nde8a7f7120581ae60b7e882b15b9099a6fce55dd\ndiff --git a/rev-list.c b/rev-list.c\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -16,7 +16,7 @@ static const char rev_list_usage[] =\n \t\t      \"  --min-age=epoch\\n\"\n \t\t      \"  --header\\n\"\n \t\t      \"  --pretty\\n\"\n-                      \"  --bisect\\n\"\n+\t\t      \"  --bisect\\n\"\n \t\t      \"  --merge-order [ --show-breaks ]\";\n \n static int tag_objects = 0;\n@@ -32,6 +32,7 @@ static int max_count = -1;\n static enum cmit_fmt commit_format = CMIT_FMT_RAW;\n static int merge_order = 0;\n static int show_breaks = 0;\n+static int topo_order=0;\n static int stop_traversal = 0;\n static int bisect_by_cut_option = 0;\n \n@@ -373,11 +374,15 @@ int main(int argc, char **argv)\n \t\t\tblob_objects = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!strncmp(arg, \"--merge-order\", 13)) {\n+\t\tif (!strcmp(arg, \"--merge-order\")) {\n \t\t        merge_order = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!strncmp(arg, \"--show-breaks\", 13)) {\n+\t\tif (!strcmp(arg, \"--topo-order\")) {\n+\t\t        topo_order = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (!strcmp(arg, \"--show-breaks\")) {\n \t\t\tshow_breaks = 1;\n \t\t\tcontinue;\n \t\t}\n@@ -396,14 +401,22 @@ int main(int argc, char **argv)\n \t}\n \n \tif (!merge_order) {\t\t\n-\t        if (limited)\n+\t        if (limited || topo_order || bisect_by_cut_option) {\n+\t\t\t/*\n+\t\t\t * two expected side effects of calling \n+\t\t\t * limit_list are:\n+\t\t\t *    * resulting list contains all the items to process\n+\t\t\t *    * show_commit_list won't do a chronological\n+\t\t\t *      sort\n+\t\t\t*/\n \t\t\tlist = limit_list(list);\n-\t\tif (!bisect_by_cut_option) \n-\t\t\tshow_commit_list(list);\n-\t\telse {\n+\t\t}\n+\t\tif (bisect_by_cut_option || topo_order)\n \t\t\tsort_in_topological_order(&list);\n+\t\tif (bisect_by_cut_option)\n \t\t\tshow_commit(bisect_by_cut(list));\n-\t\t}\n+\t\telse\n+\t\t\tshow_commit_list(list);\n \t} else {\n \t\tif (sort_list_in_merge_order(list, &process_commit)) {\n \t\t\t  die(\"merge order sort failed\\n\");\n------------\n"}]}