chiark / gitweb /
put die() messages to stderr
[topgit.git] / tg-export.sh
index 748ca54f6c093480684d53982ba72e82daedb412..6d82d55751bd41159f04f20f55b753baaec94c44 100644 (file)
@@ -67,10 +67,9 @@ trap 'rm -rf "$playground"' EXIT
 # Output tree ID of a cleaned-up tree without tg's artifacts.
 pretty_tree()
 {
 # Output tree ID of a cleaned-up tree without tg's artifacts.
 pretty_tree()
 {
-       (export GIT_INDEX_FILE="$playground/^index"
-        git read-tree "$1"
-        git update-index --force-remove ".topmsg" ".topdeps"
-        git write-tree)
+       git ls-tree --full-tree "$1" \
+       | awk -F '      ' '$2 !~ /^.top/' \
+       | git mktree
 }
 
 create_tg_commit()
 }
 
 create_tg_commit()
@@ -185,8 +184,8 @@ quilt()
                echo "Skip empty patch $_dep";
        else
                if "$numbered"; then
                echo "Skip empty patch $_dep";
        else
                if "$numbered"; then
-                       number="$(printf "%04u" $(($(cat "$playground/^number" 2>/dev/null) + 1)))";
-                       bn="$number-$bn";
+                       number="$(echo $(($(cat "$playground/^number" 2>/dev/null) + 1)))";
+                       bn="$(printf "%04u-$bn" $number)";
                        echo "$number" >"$playground/^number";
                fi;
 
                        echo "$number" >"$playground/^number";
                fi;
 
@@ -216,22 +215,25 @@ linearize()
                        # already included, just skip
                        :;
                else
                        # already included, just skip
                        :;
                else
-                       git merge -s recursive "$_dep";
-                       retmerge="$?";
+                       retmerge=0;
+
+                       git merge -s recursive "$_dep" || retmerge="$?";
                        if test "x$retmerge" != "x0"; then
                                echo fix up the merge, commit and then exit;
                                #todo error handling
                        if test "x$retmerge" != "x0"; then
                                echo fix up the merge, commit and then exit;
                                #todo error handling
-                               sh -i
+                               sh -i </dev/tty;
                        fi;
                fi;
        else
                        fi;
                fi;
        else
-               git merge-recursive "$(pretty_tree "refs/top-bases/$_dep")" -- HEAD "$(pretty_tree "refs/heads/$_dep")";
-               retmerge="$?";
+               retmerge=0;
+
+               git merge-recursive "$(pretty_tree "refs/top-bases/$_dep")" -- HEAD "$(pretty_tree "refs/heads/$_dep")" || retmerge="$?";
 
                if test "x$retmerge" != "x0"; then
 
                if test "x$retmerge" != "x0"; then
+                       git rerere;
                        echo "fix up the merge and update the index.  Don't commit!"
                        #todo error handling
                        echo "fix up the merge and update the index.  Don't commit!"
                        #todo error handling
-                       sh -i
+                       sh -i </dev/tty;
                fi
 
                result_tree=$(git write-tree)
                fi
 
                result_tree=$(git write-tree)