{"thread":{"id":"1138","subject":"[PATCH 5/13] Introduce --topo-order switch to git-rev-list","startedAt":"2005-07-06T16:39:34Z","lastAt":"2005-07-06T16:39:34Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":13},"messages":[{"id":"5720","messageId":"20050706163934.9888.qmail@blackcubes.dyndns.org","threadId":"1138","inReplyTo":null,"subject":"[PATCH 5/13] Introduce --topo-order switch to git-rev-list","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-07-06T16:39:34Z","receivedAt":"2005-07-06T16:39:34Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nThis patch introduces a --topo-order switch to git-rev-list.\n\nWhen this --switch is specified, a minimal topological sort\nweaker than the --merge-order sort is applied to the output\nlist.\n\nThe invariant of the resulting list is:\n\ta is reachable from b => ord(b) < ord(a)\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n\n Documentation/git-rev-list.txt |    9 +++++++--\n rev-list.c                     |   27 +++++++++++++++++++++++++--\n 2 files changed, 32 insertions(+), 4 deletions(-)\n\n99d3a2318171f611f1c186a7ed4881b2f34b6b49\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -9,13 +9,15 @@ git-rev-list - Lists commit objects in r\n \n SYNOPSIS\n --------\n-'git-rev-list' [ *--max-count*=number ] [ *--max-age*=timestamp ] [ *--min-age*=timestamp ] [ *--merge-order* [ *--show-breaks* ] ] <commit>\n+'git-rev-list' [ *--max-count*=number ] [ *--max-age*=timestamp ] [ *--min-age*=timestamp ] [ *--merge-order* ] [ *--show-breaks* ] [ *--topo-order* ] <commit>... ^<prune>...\n \n DESCRIPTION\n -----------\n Lists commit objects in reverse chronological order starting at the\n given commit, taking ancestry relationship into account.  This is\n-useful to produce human-readable log output.\n+useful to produce human-readable log output. If prune points are specified\n+with ^<prune>... arguments, the output will not include any commits reachable\n+from (and including) the prune points.\n \n If *--merge-order* is specified, the commit history is decomposed into a\n unique sequence of minimal, non-linear epochs and maximal, linear epochs.\n@@ -59,6 +61,9 @@ represent an arbtirary DAG in a linear f\n \n *--show-breaks* implies **-merge-order*.\n \n+If *--topo-order* is specified, the commit history is sorted in a topological\n+order that is weaker than the topological order generated by *--merge-order*.\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org>\ndiff --git a/rev-list.c b/rev-list.c\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -20,6 +20,7 @@ static const char rev_list_usage[] =\n \t\t      \"  --unpacked\\n\"\n \t\t      \"  --header\\n\"\n \t\t      \"  --pretty\\n\"\n+\t\t      \"  --topo-order\\n\"\n \t\t      \"  --merge-order [ --show-breaks ]\";\n \n static int unpacked = 0;\n@@ -38,10 +39,12 @@ static enum cmit_fmt commit_format = CMI\n static int merge_order = 0;\n static int show_breaks = 0;\n static int stop_traversal = 0;\n+static int topo_order = 0;\n \n struct rev_list_fns {\n \tstruct commit_list * (*insert)(struct commit *, struct commit_list **);\n \tstruct commit_list * (*limit)(struct commit_list *);\n+\tvoid (*sort)(struct commit_list **);\n \tvoid (*process)(struct commit_list *);\n };\n \n@@ -425,12 +428,21 @@ static void merge_order_sort(struct comm\n struct rev_list_fns default_fns = {\n \t&insert_by_date,\n \t&limit_list,\n-        &show_commit_list\n+\tNULL,\n+\t&show_commit_list\n+};\n+\n+struct rev_list_fns topo_order_fns = {\n+\t&insert_by_date,\n+\t&limit_list,\n+\t&sort_in_topological_order,\n+\t&show_commit_list\n };\n \n struct rev_list_fns merge_order_fns = {\n \t&commit_list_insert,\n \tNULL,\n+\tNULL,\n \t&merge_order_sort\n };\n \n@@ -439,7 +451,7 @@ int main(int argc, char **argv)\n \tstruct commit_list *list = NULL;\n \tstruct commit_list *sorted = NULL;\n \tstruct commit_list **list_tail = &list;\n-\tstruct rev_list_fns * fns = &default_fns;\n+\tstruct rev_list_fns * fns = NULL;\n \tint i, limited = 0;\n \n \tfor (i = 1 ; i < argc; i++) {\n@@ -498,6 +510,11 @@ int main(int argc, char **argv)\n \t\t\tmerge_order = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--topo-order\")) {\n+\t\t        topo_order = 1;\n+\t\t\tlimited=1;\n+\t\t\tcontinue;\n+\t\t}\n \n \t\tflags = 0;\n \t\tif (*arg == '^') {\n@@ -512,11 +529,17 @@ int main(int argc, char **argv)\n \t}\n \tif (merge_order)\n \t\tfns=&merge_order_fns;\n+\telse if (topo_order)\n+\t\tfns=&topo_order_fns;\n+\telse\n+\t\tfns=&default_fns;\n \twhile (list)\n \t\tfns->insert(pop_commit(&list), &sorted);\n \tlist=sorted;\n \tif (limited && fns->limit)\n \t\tlist = fns->limit(list);\n+\tif (fns->sort)\n+\t\tfns->sort(&list);\n \tfns->process(list);\n \treturn 0;\n }\n------------\n"}]}