From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: pasky@suse.cz, git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH 2/2] sort_in_topological_order(): avoid setting a commit flag
Date: Wed, 23 Jul 2008 01:51:36 +0100 (BST) [thread overview]
Message-ID: <alpine.DEB.1.00.0807230150480.8986@racer> (raw)
In-Reply-To: <alpine.DEB.1.00.0807230148130.8986@racer>
We used to set the TOPOSORT flag of commits during the topological
sorting, but we can just as well use the member "indegree" for it:
indegree is now incremented by 1 in the cases where the commit used
to have the TOPOSORT flag.
This is the same behavior as before, since indegree could not be
non-zero when TOPOSORT was unset.
Incidentally, this fixes the bug in show-branch where the 8th column
was not shown: show-branch sorts the commits in topological order,
assuming that all the commit flags are available for show-branch's
private matters.
But this was not true: TOPOSORT was identical to the flag corresponding
to the 8th ref. So the flags for the 8th column were unset by the
topological sorting.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
This is another late-night patch done by yours-truly. However,
I tried extra hard to make sure that every occurrence of
indegree was properly changed, and I am pretty certain that
the reasoning with the unset TOPOSORT is correct.
But please check (I know, not necessary to ask for extra review
for my patches, but nevertheless).
commit.c | 13 ++++++-------
revision.h | 3 +--
t/t3202-show-branch-octopus.sh | 2 +-
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/commit.c b/commit.c
index 5148ec5..9dacfb8 100644
--- a/commit.c
+++ b/commit.c
@@ -436,8 +436,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
/* Mark them and clear the indegree */
for (next = orig; next; next = next->next) {
struct commit *commit = next->item;
- commit->object.flags |= TOPOSORT;
- commit->indegree = 0;
+ commit->indegree = 1;
}
/* update the indegree */
@@ -446,7 +445,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
while (parents) {
struct commit *parent = parents->item;
- if (parent->object.flags & TOPOSORT)
+ if (parent->indegree)
parent->indegree++;
parents = parents->next;
}
@@ -464,7 +463,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
for (next = orig; next; next = next->next) {
struct commit *commit = next->item;
- if (!commit->indegree)
+ if (commit->indegree == 1)
insert = &commit_list_insert(commit, insert)->next;
}
@@ -486,7 +485,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
for (parents = commit->parents; parents ; parents = parents->next) {
struct commit *parent=parents->item;
- if (!(parent->object.flags & TOPOSORT))
+ if (!parent->indegree)
continue;
/*
@@ -494,7 +493,8 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
* when all their children have been emitted thereby
* guaranteeing topological order.
*/
- if (!--parent->indegree) {
+ if (--parent->indegree == 1) {
+ parent->indegree = 0;
if (!lifo)
insert_by_date(parent, &work);
else
@@ -505,7 +505,6 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
* work_item is a commit all of whose children
* have already been emitted. we can emit it now.
*/
- commit->object.flags &= ~TOPOSORT;
*pptr = work_item;
pptr = &work_item->next;
}
diff --git a/revision.h b/revision.h
index fa68c65..f64e8ce 100644
--- a/revision.h
+++ b/revision.h
@@ -12,8 +12,7 @@
#define CHILD_SHOWN (1u<<6)
#define ADDED (1u<<7) /* Parents already parsed and added? */
#define SYMMETRIC_LEFT (1u<<8)
-#define TOPOSORT (1u<<9) /* In the active toposort list.. */
-#define ALL_REV_FLAGS ((1u<<10)-1)
+#define ALL_REV_FLAGS ((1u<<9)-1)
struct rev_info;
struct log_info;
diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch-octopus.sh
index 8d50c23..7fe4a6e 100755
--- a/t/t3202-show-branch-octopus.sh
+++ b/t/t3202-show-branch-octopus.sh
@@ -49,7 +49,7 @@ cat > expect << EOF
+++++++++* [branch10^] initial
EOF
-test_expect_failure 'show-branch with more than 8 branches' '
+test_expect_success 'show-branch with more than 8 branches' '
git show-branch $(for i in $numbers; do echo branch$i; done) > out &&
test_cmp expect out
--
1.6.0.rc0.22.gf2096d.dirty
next prev parent reply other threads:[~2008-07-23 0:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 0:50 [PATCH 1/2] Add test to show that show-branch misses out the 8th column Johannes Schindelin
2008-07-23 0:51 ` Johannes Schindelin [this message]
2008-07-23 1:01 ` [PATCH 2/2] sort_in_topological_order(): avoid setting a commit flag Junio C Hamano
2008-07-23 15:39 ` Jon Loeliger
2008-07-23 21:49 ` Petr Baudis
2008-07-23 22:07 ` Junio C Hamano
2008-07-23 19:02 ` Junio C Hamano
2008-07-23 19:33 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.1.00.0807230150480.8986@racer \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox