{"thread":{"id":"1135","subject":"[PATCH 8/13] Fix handling of duplicates by topological order.","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":"5717","messageId":"20050706163934.9947.qmail@blackcubes.dyndns.org","threadId":"1135","inReplyTo":null,"subject":"[PATCH 8/13] Fix handling of duplicates by topological order.","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":"\n\tgit-rev-list --topo-order HEAD HEAD\n\ncaused a segmentation violation.\n\nThis has now been fixed.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n\n commit.c   |   15 +++++++++++----\n commit.h   |    3 +++\n epoch.h    |   13 ++++++-------\n rev-list.c |    8 ++++----\n 4 files changed, 24 insertions(+), 15 deletions(-)\n\n60a355172fdf6583465e1c237a3e82af64065332\ndiff --git a/commit.c b/commit.c\n--- a/commit.c\n+++ b/commit.c\n@@ -374,11 +374,17 @@ void sort_in_topological_order(struct co\n \tstruct sort_node * next_nodes;\n \tint count = 0;\n \n-\t/* determine the size of the list */\n-\twhile (next) {\n-\t\tnext = next->next;\n-\t\tcount++;\n+\t/* determine the size of the list and elide duplicates */\n+\twhile (*pptr) {\n+\t\tnext=*pptr;\n+\t\tif (!(next->item->object.flags & DUPCHECK)) {\n+\t\t\tcount++;\n+\t\t\tnext->item->object.flags |= DUPCHECK;\n+\t\t\tpptr=&next->next;\n+\t\t} else\n+\t\t\t*pptr=next->next;\n \t}\n+\tpptr=list;\n \t/* allocate an array to help sort the list */\n \tnodes = xcalloc(count, sizeof(*nodes));\n \t/* link the list to the array */\n@@ -387,6 +393,7 @@ void sort_in_topological_order(struct co\n \twhile (next) {\n \t\tnext_nodes->list_item = next;\n \t\tnext->item->object.util = next_nodes;\n+\t\tnext->item->object.flags &= ~DUPCHECK;\n \t\tnext_nodes++;\n \t\tnext = next->next;\n \t}\ndiff --git a/commit.h b/commit.h\n--- a/commit.h\n+++ b/commit.h\n@@ -4,6 +4,9 @@\n #include \"object.h\"\n #include \"tree.h\"\n \n+#define DUPCHECK (1u<<0)\n+#define LAST_COMMIT_FLAG (DUPCHECK)\n+\n struct commit_list {\n \tstruct commit *item;\n \tstruct commit_list *next;\ndiff --git a/epoch.h b/epoch.h\n--- a/epoch.h\n+++ b/epoch.h\n@@ -1,6 +1,6 @@\n #ifndef EPOCH_H\n #define EPOCH_H\n-\n+#include \"commit.h\"\n \n // return codes for emitter_func\n #define STOP     0\n@@ -10,12 +10,11 @@ typedef int (*emitter_func) (struct comm\n \n int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter);\n \n-#define UNINTERESTING   (1u<<2)\n-#define BOUNDARY        (1u<<3)\n-#define VISITED         (1u<<4)\n-#define DISCONTINUITY   (1u<<5)\n-#define DUPCHECK        (1u<<6)\n-#define LAST_EPOCH_FLAG (1u<<6)\n+#define UNINTERESTING   (LAST_COMMIT_FLAG<<1)\n+#define BOUNDARY        (LAST_COMMIT_FLAG<<2)\n+#define VISITED         (LAST_COMMIT_FLAG<<3)\n+#define DISCONTINUITY   (LAST_COMMIT_FLAG<<4)\n+#define LAST_EPOCH_FLAG (LAST_COMMIT_FLAG<<4)\n \n \n #endif\t/* EPOCH_H */\ndiff --git a/rev-list.c b/rev-list.c\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -5,10 +5,10 @@\n #include \"blob.h\"\n #include \"epoch.h\"\n \n-#define SEEN\t\t(1u << 0)\n-#define INTERESTING\t(1u << 1)\n-#define COUNTED\t\t(1u << 2)\n-#define SHOWN\t\t(LAST_EPOCH_FLAG << 2)\n+#define SEEN        (LAST_EPOCH_FLAG << 1)\n+#define INTERESTING (LAST_EPOCH_FLAG << 2)\n+#define COUNTED     (LAST_EPOCH_FLAG << 3)\n+#define SHOWN       (LAST_EPOCH_FLAG << 4)\n \n static const char rev_list_usage[] =\n \t\"usage: git-rev-list [OPTION] commit-id <commit-id>\\n\"\n------------\n"}]}