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

[PATCH 2/2] Catch history inconsistency in cg-admin-rewritehist.

From
Yann Dirson <ydirson@altern.org>
Date
May 9, 2006, 22:32 UTC
Message-ID
<20060509223235.20814.475.stgit@gandelf.nowhere.earth>
In-Reply-To
<20060509222738.20814.57282.stgit@gandelf.nowhere.earth>

This assertion is triggered by a bug in "cg-object-id -p", which ignores grafts, when we attempt to rewrite a grafted commit whose original parent does not get rewritten.

Dying here prevents to leave the user with a corrupted rewriten history.
Signed-off-by: Yann Dirson <ydirson@altern.org>
---
 cg-admin-rewritehist |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/cg-admin-rewritehist b/cg-admin-rewritehist
index 958a8ab..8dd33f2 100755
--- a/cg-admin-rewritehist
+++ b/cg-admin-rewritehist
@@ -218,9 +218,13 @@ while read commit; do
 
 	parentstr=
 	for parent in $(cg-object-id -p $commit); do
-		for reparent in $(cat ../map/$parent); do
-			parentstr="$parentstr -p $reparent"
-		done
+		if [ -r "../map/$parent" ]; then
+			for reparent in $(cat "../map/$parent"); do
+				parentstr="$parentstr -p $reparent"
+			done
+		else
+			die "assertion failed: parent $parent for commit $commit not found in rewritten ones"
+		fi
 	done
 	if [ "$filter_parent" ]; then
 		parentstr="$(echo "$parentstr" | eval "$filter_parent")"
Previous: Yann Dirson
Message 3 of 3 in “Support for "set -e" in cogito script, and assertion in rewritehist”
  1. 0/2 Support for "set -e" in cogito script, and assertion in rewritehistYann Dirson, May 9, 2006
  2. 1/2 Suppress use of unsafe idiomatic use of && in cg-XlibYann Dirson, May 9, 2006
  3. 2/2 Catch history inconsistency in cg-admin-rewritehist.Yann Dirson, May 9, 2006

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.