2 # TopGit - A different patch queue manager
28 echo "Usage: ${tgname:-tg} [...] push [--dry-run] [--force] [--no-deps] [--tgish-only] [-r <remote>] [-a | --all | <branch>...]"
35 v_strip_ref arg
"$arg"
36 branches
="${branches:+$branches }$arg";;
40 if [ -z "$remote" ]; then
44 if [ -z "$remote" ]; then
45 die
"no remote location given. Either use -r remote argument or set topgit.remote"
48 if [ -z "$branches" ]; then
49 if [ -n "$push_all" ]; then
50 branches
="$(non_annihilated_branches | paste -s -d " " -)"
52 v_verify_topgit_branch branches HEAD
55 oldbranches
="$branches"
57 while read name
&& [ -n "$name" ]; do
58 if [ "$name" = "HEAD" ]; then
59 sr
="$(git symbolic-ref --quiet HEAD)" ||
:
60 [ -n "$sr" ] || die
"cannot push a detached HEAD"
61 case "$sr" in refs
/heads
/*);;*)
62 die
"HEAD is a symref to other than refs/heads/..."
64 branches
="${branches:+$branches }${sr#refs/heads/}"
66 ref_exists
"refs/heads/$name" || die
"no such ref: refs/heads/$name"
67 branches
="${branches:+$branches }$name"
70 $(sed 'y/ /\n/' <<-LIST
78 _listfile
="$(get_temp tg-push-listfile)"
82 # FIXME should we abort on missing dependency?
83 [ -z "$_dep_missing" ] ||
return 0
85 # if so desired omit non tgish deps
86 [ -z "$tgish_deps_only" ] ||
[ -n "$_dep_is_tgish" ] ||
return 0
88 # filter out plain SHA1s. These don't need to be pushed explicitly as
89 # the patches that depend on the sha1 have it already in their ancestry.
90 ! is_sha1
"$_dep" ||
return 0
92 echol
"$_dep" >> "$_listfile"
93 [ -z "$_dep_is_tgish" ] ||
94 echo "$topbases/$_dep" >> "$_listfile"
98 while read name
&& [ -n "$name" ]; do
100 # re-use push_branch, which expects some pre-defined variables
104 ref_exists
"refs/$topbases/$_dep" ||
108 # deps but only if branch is tgish
109 [ -z "$recurse_deps" ] ||
[ -z "$_dep_is_tgish" ] ||
110 recurse_deps push_branch
"$name"
112 $(sed 'y/ /\n/' <<LIST
118 # remove multiple occurrences of the same branch
119 sort -u "$_listfile" |
sed 's,[^A-Za-z0-9/_.+-],\\&,g' |
xargs git push
$dry_run $force "$remote"