X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-push.sh;h=199d7389b48ea4563ac2217022f410b2aebf4d4b;hp=8d09a020846e7105210c34c96e868a56e962b183;hb=ff59ac7fce3326e0b0163a780ecb49dd3b1de8d1;hpb=b725fc951a37854fc65945ac5bcab3bc61ccbd94 diff --git a/tg-push.sh b/tg-push.sh index 8d09a02..199d738 100644 --- a/tg-push.sh +++ b/tg-push.sh @@ -45,31 +45,36 @@ for name in $branches; do ref_exists "$name" || die "detached HEAD? Can't push $name" done +_listfile="$(mktemp -t tg-push-listfile.XXXXXX)" +trap "rm -f \"$_listfile\"" 0 + push_branch() { # if so desired omit non tgish deps $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0 - echo "$_dep" - local base="top-bases/$_dep" - if ref_exists "$base"; then - echo "top-bases/$_dep" - else - echo "warning, no base found $base" 1>&2 - fi + # filter out plain SHA1s. These don't need to be pushed explicitly as + # the patches that depend on the sha1 have it already in their ancestry. + is_sha1 "$_dep" && return 0 + + echo "$_dep" >> "$_listfile" + [ -z "$_dep_is_tgish" ] || + echo "top-bases/$_dep" >> "$_listfile" } for name in $branches; do - list="$( - # deps - if $recurse_deps; then - no_remotes=1 recurse_deps push_branch "$name" - fi - # current branch - _dep="$name" - _dep_is_tgish=1 - push_branch "$name" - )" - echo "pushing:"; echo $list - git push $dry_run "$remote" $list + # current branch + # re-use push_branch, which expects some pre-defined variables + _dep="$name" + _dep_is_tgish=1 + ref_exists "top-bases/$_dep" || + _dep_is_tgish= + push_branch "$name" + + # deps but only if branch is tgish + $recurse_deps && [ -n "$_dep_is_tgish" ] && + no_remotes=1 recurse_deps push_branch "$name" + + # remove multiple occurrences of the same branch + sort -u "$_listfile" | xargs git push $dry_run "$remote" done