Set version to 0.13.1
[topgit/pro.git] / tg-push.sh
blobb063d4962eb025af848da38050981d3f045229d3
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # GPLv2
5 ## Parse options
7 recurse_deps=true
8 tgish_deps_only=false
9 dry_run=
10 push_all=false
12 while [ -n "$1" ]; do
13 arg="$1"; shift
14 case "$arg" in
15 --no-deps)
16 recurse_deps=false;;
17 --dry-run)
18 dry_run=--dry-run;;
19 --tgish-only)
20 tgish_deps_only=true;;
21 -a|--all)
22 push_all=true;;
23 -h|--help)
24 echo "Usage: tg push [--dry-run] [--no-deps] [--tgish-only] [-r <remote>] [-a | --all | <branch>...]"
25 exit 0;;
26 -r)
27 remote="$1"
28 shift
31 branches="$branches $arg";;
32 esac
33 done
35 if [ -z "$remote" ]; then
36 remote="$base_remote"
39 if [ -z "$remote" ]; then
40 die "no remote location given. Either use -r remote argument or set topgit.remote"
43 if [ -z "$branches" ]; then
44 if $push_all; then
45 branches="$(non_annihilated_branches)"
46 else
47 branches="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
51 for name in $branches; do
52 ref_exists "$name" || die "detached HEAD? Can't push $name"
53 done
55 _listfile="$(get_temp tg-push-listfile)"
57 push_branch()
59 # FIXME should we abort on missing dependency?
60 [ -z "$_dep_missing" ] || return 0
62 # if so desired omit non tgish deps
63 $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0
65 # filter out plain SHA1s. These don't need to be pushed explicitly as
66 # the patches that depend on the sha1 have it already in their ancestry.
67 is_sha1 "$_dep" && return 0
69 echo "$_dep" >> "$_listfile"
70 [ -z "$_dep_is_tgish" ] ||
71 echo "top-bases/$_dep" >> "$_listfile"
74 for name in $branches; do
75 # current branch
76 # re-use push_branch, which expects some pre-defined variables
77 _dep="$name"
78 _dep_is_tgish=1
79 _dep_missing=
80 ref_exists "top-bases/$_dep" ||
81 _dep_is_tgish=
82 push_branch "$name"
84 # deps but only if branch is tgish
85 $recurse_deps && [ -n "$_dep_is_tgish" ] &&
86 no_remotes=1 recurse_deps push_branch "$name"
87 done
89 # remove multiple occurrences of the same branch
90 sort -u "$_listfile" | xargs git push $dry_run "$remote"