git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: gitk problems: can't unset "idinlist(...)"

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 21, 2007, 06:11 UTC
Message-ID
<alpine.LFD.0.999.0707202304350.27249@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.0.999.0707202226130.27249@woody.linux-foundation.org>
On Fri, 20 Jul 2007, Linus Torvalds wrote:
> 
> Junio, didn't we have some parent simplification patches recently?

Yeah. Junio, I think your 11d6596709e04b8d2b429f230b2ed570d013f812 is buggy.

Here's a patch. Not very well tested, but it makes gitk happy and passes all the tests. And I really think Junio's code was very dubious (it did that "p = p->next" *every* time, and then did "pp = &p->next", so "pp" would end up jumping by multiple entries.

The new code only ever changes "pp" - either by moving p->next into it (delete the current entry) or by moving pp forward by one (keep the current entry).

That's much more logical, but somebody should double-check me anyway.
		Linus
---
Subject: Fix up duplicate parents removal
This removes duplicate parents properly, making gitk happy again.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 revision.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/revision.c b/revision.c
index 28b5f2e..7036cf2 100644
--- a/revision.c
+++ b/revision.c
@@ -1323,16 +1323,17 @@ static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp
 
 static void remove_duplicate_parents(struct commit *commit)
 {
-	struct commit_list *p;
-	struct commit_list **pp = &commit->parents;
+	struct commit_list **pp, *p;
 
 	/* Examine existing parents while marking ones we have seen... */
-	for (p = commit->parents; p; p = p->next) {
+	pp = &commit->parents;
+	while ((p = *pp) != NULL) {
 		struct commit *parent = p->item;
-		if (parent->object.flags & TMP_MARK)
+		if (parent->object.flags & TMP_MARK) {
+			*pp = p->next;
 			continue;
+		}
 		parent->object.flags |= TMP_MARK;
-		*pp = p;
 		pp = &p->next;
 	}
 	/* ... and clear the temporary mark */
Previous: Jeff KingNext: Jeff King
Message 7 of 15 in “gitk problems: can't unset "idinlist(...)"”
  1. Linus TorvaldsJul 20, 2007
  2. Jeff KingJul 21, 2007
  3. Linus TorvaldsJul 21, 2007
  4. Junio C HamanoJul 21, 2007
  5. Jeff KingJul 21, 2007
  6. Jeff KingJul 21, 2007
  7. Linus TorvaldsJul 21, 2007
  8. Jeff KingJul 21, 2007
  9. Jeff KingJul 21, 2007
  10. Linus TorvaldsJul 21, 2007
  11. Jeff KingJul 21, 2007
  12. pointer to pointer (was: gitk problems: can't unset "idinlist(...)")David Kastrup, Jul 21, 2007
  13. David KastrupJul 21, 2007
  14. Linus TorvaldsJul 21, 2007
  15. Paul MackerrasJul 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.