chiark / gitweb /
[TOPGIT] make creating a commit from a topgit branch a function
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 14 Jan 2009 20:26:18 +0000 (21:26 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 25 Feb 2009 19:49:38 +0000 (20:49 +0100)
This helps avoiding code duplication for the next commit.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg-export.sh

index 9e6940fcff23fc1a6bbd5ded2b9a7bf037ece54c..dea24d9d6fa024ba3da1103a584991e7d9f4c7ec 100644 (file)
@@ -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"