{"thread":{"id":"930","subject":"[PATCH 6/7] Remove DUPCHECK, UNINTERESTING flags from epoch.h","startedAt":"2005-06-14T02:04:45Z","lastAt":"2005-06-14T02:04:45Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"4933","messageId":"20050614020445.23350.qmail@blackcubes.dyndns.org","threadId":"930","inReplyTo":null,"subject":"[PATCH 6/7] Remove DUPCHECK, UNINTERESTING flags from epoch.h","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-06-14T02:04:45Z","receivedAt":"2005-06-14T02:04:45Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nThis change:\n\n* moves --show-breaks detection into show_commit of rev-list.c,\n  thereby cleaning up the logic in epoch.c\n* replaces epoch.c's use of VISITED flag with the SEEN flag\n* removes UNINTERESTING, DUPCHECK and DISCONTINUITY flags\n  from epoch.h\n* defines a new flag, LAST_TRAVERSAL_FLAG to allow other modules\n  to use flags not used by epoch.c\n* redefines flags private to rev-list.c in terms of LAST_TRAVERSAL_FLAG\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n\n epoch.c     |   22 ++++++++--------------\n epoch.h     |   14 ++++++--------\n rev-list.c  |   26 +++++++++++++++-----------\n traversal.h |    1 +\n 4 files changed, 30 insertions(+), 33 deletions(-)\n\ndiff --git a/epoch.c b/epoch.c\n--- a/epoch.c\n+++ b/epoch.c\n@@ -26,11 +26,9 @@ static struct fraction *one = NULL;\n static struct fraction *zero = NULL;\n \n #define HAS_EXACTLY_ONE_PARENT(n) ((n)->parents && !(n)->parents->next)\n-#define IS_UNINTERESTING(c) ((c)->object.flags & UNINTERESTING)\n-#define IS_VISITED(c) ((c)->object.flags & VISITED)\n+#define IS_SEEN(c) ((c)->object.flags & SEEN)\n #define IS_BASE(c) ((c)->object.flags & BASE)\n #define IS_LOCAL(c) ((c)->object.flags & LOCAL)\n-#define IS_DISCONTINUITY(c) ((c)->object.flags & DISCONTINUITY)\n \n /* leave the assertions defined for now, maybe null def them later */\n #define ASSERT(x,m,c) if (!(x)) { assertion_failed(__LINE__, __FUNCTION__, m, c); } else {}\n@@ -220,8 +218,8 @@ static void visit_edge(struct traversal \n {\n \t/*\n \t * pre-condition:\n-\t * \tfrom->object.flags & VISITED &&\n-\t * \tto->object.util => (to->object.flags & VISITED)\n+\t * \tfrom->object.flags & SEEN &&\n+\t * \tto->object.util => (to->object.flags & SEEN)\n \t */ \n \tif (traversal->edge_visitor)\n \t\t(*(traversal->edge_visitor))(from, to);\n@@ -249,10 +247,10 @@ static void clean_commit(struct traversa\n \tif (traversal->clean)\n \t\t(*(traversal->clean))(commit);\n \tcommit->object.util = NULL;\n-\tcommit->object.flags &= ~(EPOCH_FLAGS);\n+\tcommit->object.flags &= ~(TRAVERSAL_FLAGS);\n \t/*\n \t * post-condition:\n-\t * \tcommit->object.util == NULL && !(commit->object.flag & EPOCH_FLAGS)\n+\t * \tcommit->object.util == NULL && !(commit->object.flag & TRAVERSAL_FLAGS)\n \t */\t\t\n }\n \n@@ -438,13 +436,13 @@ static void sort_unvisited(\n \tstruct commit_list *parents = NULL;\n         struct commit * top = *stack?(*stack)->item:NULL;\n \n-\tif (IS_VISITED(head)) {\n+\tif (IS_SEEN(head)) {\n \t\tif (!IS_BASE(head)) {\n \t\t\tvisit_commit(traversal, head, 0);\n \t\t}\n \t\treturn;\n \t}\n-\thead->object.flags |= VISITED;\n+\thead->object.flags |= SEEN;\n         if (IS_BASE(head)) {\n \t\tASSERT(!top, \"stack empty on visit to base\", head);\n \t} else {\n@@ -461,10 +459,6 @@ static void sort_unvisited(\n \t\t\tvisit_edge(traversal, head, parent);\n \t\t\tsort_unvisited(parent, stack, traversal);\n \t\t}\t\t\n-\t\ttop=(*stack)?(*stack)->item:NULL;\n-\t\tif (top && !is_parent_of(top, head)) {\n-\t\t\ttop->object.flags |= DISCONTINUITY;\n-\t\t}\t\t\t\n \t\tcommit_list_insert(head, stack);\t\n         }\n }\n@@ -626,7 +620,7 @@ int traverse_from_head(struct commit *he\n \t\t\tbase->object.flags |= (BOUNDARY|BASE);\n \t\t\t\n \t\t/* reset flags set by last iteration */\n-\t\tnext->object.flags &= ~(BASE|VISITED);\n+\t\tnext->object.flags &= ~(BASE|SEEN);\n \t\t\n \t\t/* sort with the optimal algorithm */\n \t\tif (HAS_EXACTLY_ONE_PARENT(next))\ndiff --git a/epoch.h b/epoch.h\n--- a/epoch.h\n+++ b/epoch.h\n@@ -4,15 +4,13 @@\n /**\n  * Flags used by merge order logic and also by rev-list.c\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 LOCAL          (1u<<7)\n-#define BASE           (1u<<8)\n+#define SEEN                    (1u<<0)\n+#define BOUNDARY                (SEEN<<1)\n+#define LOCAL                   (BOUNDARY<<1)\n+#define BASE                    (LOCAL<<1)\n+#define LAST_TRAVERSAL_FLAG     (BASE)\n \n-#define EPOCH_FLAGS (UNINTERESTING|BOUNDARY|VISITED|DISCONTINUITY|DUPCHECK|LOCAL|BASE)\n+#define TRAVERSAL_FLAGS         (BOUNDARY|SEEN|LOCAL|BASE)\n \n /**\n  * Return codes for emitter method. Also used by rev-list.c\ndiff --git a/rev-list.c b/rev-list.c\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -3,8 +3,9 @@\n #include \"epoch.h\"\n #include \"user.h\"\n \n-#define SEEN\t\t(1u << 0)\n-#define INTERESTING\t(1u << 1)\n+#define INTERESTING\t(LAST_TRAVERSAL_FLAG << 1)\n+#define UNINTERESTING   (INTERESTING << 1)\n+#define DUPCHECK        (UNINTERESTING << 1)\n \n static const char rev_list_usage[] =\n \t\"usage: git-rev-list [OPTION] commit-id <commit-id>\\n\"\n@@ -34,16 +35,18 @@ static char * local_author = NULL;\n static int prune_at_author = 0;\n static int wrt_author = 0;\n static int stop_traversal = 0;\n+static struct commit * last_printed = NULL;\n \n static void show_commit(struct commit *commit)\n {\n+\n \tif (show_breaks) {\n \t\tprefix = \"| \";\n-\t\tif (commit->object.flags & DISCONTINUITY) {\n-\t\t\tprefix = \"^ \";     \n-\t\t} else if (commit->object.flags & BOUNDARY) {\n+\t\tif (commit->object.flags & BOUNDARY) {\n \t\t\tprefix = \"= \";\n-\t\t} \n+\t\t} else if (last_printed && !is_parent_of(commit, last_printed)) {\n+\t\t\tprefix = \"^ \";     \n+\t\t}\n         }        \t\t\n \tprintf(\"%s%s\", prefix, sha1_to_hex(commit->object.sha1));\n \tif (show_parents) {\n@@ -59,6 +62,7 @@ static void show_commit(struct commit *c\n \t\tpretty_print_commit(commit_format, commit->buffer, ~0, pretty_header, sizeof(pretty_header));\n \t\tprintf(\"%s%c\", pretty_header, hdr_termination);\n \t}\t\n+\tlast_printed = commit;\n }\n \n static int filter_commit(struct commit * commit)\n@@ -198,7 +202,7 @@ static void mark_authors_own_uninteresti\n  */\n static void mark_ancestors_uninteresting(struct commit * head, struct commit *parent)\n {\n-\tunsigned int flags, visited, boundary, uninteresting;\n+\tunsigned int flags, seen, boundary, uninteresting;\n \tstruct commit_list *next;\n \n \tif (!(head->object.flags & UNINTERESTING)) {\n@@ -206,7 +210,7 @@ static void mark_ancestors_uninteresting\n \t}\n \n \tflags = parent->object.flags;\n-\tvisited = flags & VISITED;\n+\tseen = flags & SEEN;\n \tboundary = flags & BOUNDARY;\n \tuninteresting = flags & UNINTERESTING;\n \n@@ -215,9 +219,9 @@ static void mark_ancestors_uninteresting\n \t * We only need to recurse if\n \t *      we are not on the boundary and\n \t *      we have not already been marked uninteresting and\n-\t *      we have already been visited.\n+\t *      we have already been seen.\n \t *\n-\t * The main sort_unvisited traverse will mark unreachable\n+\t * The main traversal will mark unreachable\n \t * all uninteresting, unvisited parents as they are visited\n \t * so there is no need to duplicate that traversal here.\n \t *\n@@ -226,7 +230,7 @@ static void mark_ancestors_uninteresting\n \t * uninteresting or will be once the sort_unvisited\n \t * traverse reaches them.\n \t */\n-\tif (uninteresting || boundary || !visited)\n+\tif (uninteresting || boundary || !seen)\n \t\treturn;\n \tfor (next = parent->parents; next; next = next->next)\n \t\tmark_ancestors_uninteresting(parent, next->item);\ndiff --git a/traversal.h b/traversal.h\nnew file mode 100644\n--- /dev/null\n+++ b/traversal.h\n@@ -0,0 +1 @@\n+/* workaround for git-apply issue */\n------------\n"}]}