X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-export.sh;h=d68a6acd6d7286fabb1e59fde256dea29283d0f1;hp=486ec94ba00f97e831848648ecb6c37272d5e823;hb=120b1ea119b87b3ea292f0c2e2416540e790fcd1;hpb=cfed23b5b79563c7224df89fec8b5e3d91874784;ds=sidebyside diff --git a/tg-export.sh b/tg-export.sh index 486ec94..d68a6ac 100644 --- a/tg-export.sh +++ b/tg-export.sh @@ -54,7 +54,13 @@ if [ -z "$branches" ]; then name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || die "not on a TopGit-controlled branch" + branches="$name" +else + name="${branches##*,}" # the last of the comma-separated items fi +# $name holds the current branch +# $branches holds the comma-separated list of branches +# $name is equal to the last of the list of branches playground="$(get_temp tg-export -d)" @@ -89,7 +95,7 @@ create_tg_commit() # Produce a collapsed commit of branch NAME. collapsed_commit() { - name="$1" + local name; name="$1" rm -f "$playground/^pre" "$playground/^post" >"$playground/^body" @@ -270,17 +276,10 @@ driver() # Call driver on all the branches - this will happen # in topological order. -if [ -z "$branches" ]; then +echo "$branches" | tr , '\n' | while read name; do recurse_deps driver "$name" (_ret=0; _dep="$name"; _name=""; _dep_is_tgish=1; driver) -else - echo "$branches" | tr ',' '\n' | while read _dep; do - _dep_is_tgish=1 - $driver - done - name="$(echo "$branches" | sed 's/.*,//')" -fi - +done if [ "$driver" = "collapse" ]; then git update-ref "refs/heads/$output" "$(cat "$playground/$name")" ""