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

[PATCH] [TOPGIT] make creating a commit from a topgit branch a function

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Jan 14, 2009, 21:27 UTC
Message-ID
<1231968443-13960-2-git-send-email-u.kleine-koenig@pengutronix.de>
In-Reply-To
<1231968443-13960-1-git-send-email-u.kleine-koenig@pengutronix.de>
This helps avoiding code duplication for the next commit.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 tg-export.sh |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/tg-export.sh b/tg-export.sh
index 9e6940f..dea24d9 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -71,14 +71,11 @@ pretty_tree()
 	 git write-tree)
 }
 
-# collapsed_commit NAME
-# Produce a collapsed commit of branch NAME.
-collapsed_commit()
+create_tg_commit()
 {
 	name="$1"
-
-	rm -f "$playground/^pre" "$playground/^post"
-	>"$playground/^body"
+	tree="$2"
+	parent="$3"
 
 	# Get commit message and authorship information
 	git cat-file blob "$name:.topmsg" | git mailinfo "$playground/^msg" /dev/null > "$playground/^info"
@@ -92,6 +89,20 @@ collapsed_commit()
 	test -n "$GIT_AUTHOR_EMAIL" && export GIT_AUTHOR_EMAIL
 	test -n "$GIT_AUTHOR_DATE" && export GIT_AUTHOR_DATE
 
+	(printf '%s\n\n' "$SUBJECT"; cat "$playground/^msg") |
+	git stripspace |
+	git commit-tree "$tree" -p "$parent"
+}
+
+# collapsed_commit NAME
+# Produce a collapsed commit of branch NAME.
+collapsed_commit()
+{
+	name="$1"
+
+	rm -f "$playground/^pre" "$playground/^post"
+	>"$playground/^body"
+
 	# Determine parent
 	parent="$(cut -f 1 "$playground/$name^parents")"
 	if [ "$(cat "$playground/$name^parents" | wc -l)" -gt 1 ]; then
@@ -107,9 +118,7 @@ collapsed_commit()
 	if branch_empty "$name"; then
 		echo "$parent";
 	else
-		(printf '%s\n\n' "$SUBJECT"; cat "$playground/^msg") |
-		git stripspace |
-		git commit-tree "$(pretty_tree "$name")" -p "$parent"
+		create_tg_commit "$name" "$(pretty_tree $name)" "$parent"
 	fi;
 
 	echo "$name" >>"$playground/^ticker"
-- 
1.5.6.5
Previous: Uwe Kleine-KönigNext: martin f krafft
Message 2 of 7 in “[TOPGIT] make tg remote idempotent”
  1. [TOPGIT] make tg remote idempotentUwe Kleine-König, Jan 14, 2009
  2. [TOPGIT] make creating a commit from a topgit branch a functionUwe Kleine-König, Jan 14, 2009
  3. martin f krafftJan 21, 2009
  4. Uwe Kleine-KönigJan 21, 2009
  5. martin f krafftJan 22, 2009
  6. Uwe Kleine-KönigJan 21, 2009
  7. martin f krafftJan 21, 2009

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.