topgit tg push feature
PATCH 1/1 topgit tg push feature
The patch should apply cleanly on 9f685cd79.
Or fetch it from branch t/tg-push at git://mawercer.de/topGit
Until now you've had two choices:
git push --all # pushing all top-bases and all other branches or run
git push t/foo top-bases/foo # + all deps manually
tg push allows you to
a) push branch and its base, the branch you're on is used
b) push branch its deps and their bases (adding -r)
using tg push remoteA remoteB you can push to multiple remote locations.
Marc Weber
commit 2db369ff6dcfe9d5c4a9bab3eaf33c2a9b742f3d
Author: Marc Weber <[email protected]> Date: Sat Apr 25 17:52:44 2009 +0200
add tg-push [-r] pushing the branch and its base
-r: also push tgish dependencies
.gitignore +2 -0
@@ -21,6 +21,8 @@ /tg-import.txt /tg-remote /tg-remote.txt +/tg-push +/tg-push.txt /tg .*.swp
README +7 -0
@@ -480,6 +480,13 @@ tg update TODO: tg update -a for updating all topic branches +tg push +~~~~~~~ + git push remote branch doesn't push the base. + git push remote pushes all branches (and bases) + You use tg push [-r] to push only the current branch [ and deps] with + its base to a remote location. + TODO: tg rename
tg-push.sh new file +32 -0
@@ -0,0 +1,57 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# GPLv2 + +recurse= +remotes= + + +## Parse options + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -r) + recurse=1;; + *) + remotes="$remotes $arg";; + esac +done + +if [ -z "$remotes" ]; then + remotes="$(git config topgit.remote 2>/dev/null)" +fi + +if [ -z "$remotes" ]; then + die "no remote location given. Either add a remote as additional argument or set topgit.remote" +fi + +name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +ref_exists "$name" || die "detached HEAD? Can't push that" + +push_branch(){
+ echo "$_dep" >> "$to_be_pushed"
+ base="top-bases/$_dep"
+ if ref_exists "$base"; then
+ echo "top-bases/$_dep" >> "$to_be_pushed"
+ else
+ echo "warning, no base found $base"
+ fi
+}
+
+to_be_pushed="$(mktemp -t tg-depsfile.XXXXXX)"
+trap 'rm -rf "$to_be_pushed"' EXIT
+
+for remote in $remotes; do
+ : > $to_be_pushed # empty file
+
+ if [ -n "$recurse" ]; then
+ recurse_deps push_branch "$name"
+ fi
+ _dep="$name"
+ _dep_is_tgish=1
+ push_branch
+ echo git push $remote cat $to_be_pushed
+ git push $remote cat $to_be_pushed
+done
tg-push.txt new file +3 -0
@@ -0,0 +1,3 @@ + push branch and base. If you also use -r all tgish dependencies + will be pushed as well. + Use tg push remoteA remoteB to push to remoteA and remoteB locations
Quoted 2 lines · Marc Weber
The patch should apply cleanly on
9f685cd79.
Or fetch it from branch t/tg-push atgit://mawercer.de/topGit
Use the t/tg-push branch. I've fixed two small bugs. Sorry for this inconvinience.
Thanks
Marc Weber
updated version is availible:
changes:
* push deps (even non-tgish) by default. You can switch off both by --no-deps and --only-tgish
* fixed remote check
* adding --dry-run
* no longer using temp file.
The patch should apply cleanly on 9f685cd79.
You can also get it by pulling from branch t/tg-push at git://mawercer.de/topGit
commit 30f6a7bc1d656249643f0c59e3095620990351d8
Author: Marc Weber <[email protected]> Date: Tue May 5 11:31:53 2009 +0200
t/tg-push
add tg-push pushing the branch, its deps and their bases
Usage: tg push [(--no-deps | --tgish-only)] remote*
.gitignore +2 -0
@@ -21,6 +21,8 @@ /tg-import.txt /tg-remote /tg-remote.txt +/tg-push +/tg-push.txt /tg .*.swp
README +13 -0
@@ -480,6 +480,19 @@ tg update TODO: tg update -a for updating all topic branches +tg push +~~~~~~~ + Usage: tg push [(--no-deps | --tgish-only)] remote* + + $git push remote branch # this doesn't push the base. + $git push remote # pushes all branches (and bases) + You use + + $tg push remote + to push the current branch, its deps and their both tgish + and non-tgish deps. You may add --no-deps and or --tgish-only + to change this default behaviour + TODO: tg rename
tg-push.sh new file +68 -0
68 lines not on this page · raw message
Uwe K,
what do you think. Is there still much to change to include this patch into upstream?
new patch version. adding small comment saying that the two options --ne-deps and --tgish-only will seldomly used..
Sincerly
Marc Weber
commit c1cff518e3f70e9bd6cb4f2119b86e506ab43776
Author: Marc Weber <[email protected]> Date: Thu May 7 06:46:28 2009 +0200
t/tg-push
add tg-push pushing the branch, its deps and their bases
Usage: tg push [(--no-deps | --tgish-only)] remote*
README +13 -0
@@ -480,6 +480,19 @@ tg update TODO: tg update -a for updating all topic branches +tg push + Usage: tg push [(--no-deps | --tgish-only)] remote* + + $git push remote branch # this doesn't push the base. + $git push remote # pushes all branches (and bases) + You use + + $tg push remote + to push the current branch, its deps and their both tgish + and non-tgish deps. You may add --no-deps and or --tgish-only + to change this default behaviour. Probably youn never want + to do this + TODO: tg rename
tg-push.sh new file +69 -0
69 lines not on this page · raw message
Quoted 4 lines · Marc Weber
Uwe K,
what do you think. Is there still much to change to include this patch into upstream?
I think its a usefull tool, but I haven't tested it yet.
Quoted 27 lines
new patch version. adding small comment saying that the two options --ne-deps and --tgish-only will seldomly used..
Sincerly
Marc Webercommit
c1cff518e3f70e9bd6cb4f2119b86e506ab43776
Author: Marc Weber <[email protected]>
Date: Thu May 7 06:46:28 2009 +0200t/tg-push
add tg-push pushing the branch, its deps and their bases
Usage: tg push [(--no-deps | --tgish-only)] remote*
Signed-off-by Marc Weber <[email protected]>README +0
-0@@ -480,6 +480,19 @@ tg updateTODO: tg update -a for updating all topic branches
Quoted 2 lines
+tg push
+ Usage: tg push [(--no-deps | --tgish-only)] remote*
no need to repeat yourself. 'tg help push' will print the usage from tg-push first. And where is the --dry-run option?
Quoted 8 lines
README +7
-0+ + $git push remote branch # this doesn't push the base. + $git push remote # pushes all branches (and bases) + You use + + $tg push remote + to push the current branch,its deps and their both tgish and non-tgish deps.
This phrase needs rewording, what about: "its deps, both their tgish and non-tgish ones."
Quoted 3 lines
You may add --no-deps and or --tgish-only
+ to change this default behaviour. Probably youn never want
+ to do this
I think a "use these only if you know what you are doing" is better.
Quoted 24 lines
+
TODO: tg renametg-push.sh new file +14
-0@@ -0,0 +1,69 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# GPLv2 + +remotes= + +## Parse options see README + +recurse_deps=1 +tgish_deps_only= + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in
tg-push.sh line 24
Quoted 10 lines
tg-push.sh new file +10
-0+ --no-deps) + recurse_deps=;; + --dry-run) + dry_run=1;; + --tgish-only) + tgish_deps_only=1;; + *) + remotes="$remotes $arg";; + esac +done
now i see why you have the Usage: in the README. common practice is to print the usage if an unknown option was given. see all the other tg-*.sh scripts.
tg-push.sh line 28
Quoted 4 lines
tg-push.sh new file +4
-0+ +if [ -z "$remotes" ]; then + remotes="$(git config topgit.remote 2>/dev/null)" +fi
How effetcts the tg -r REMOTE option this command. Or more exactly why doesn't have this option an effect here?
tg-push.sh line 35
Quoted 7 lines
tg-push.sh new file +7
-0+ +if [ -z "$remotes" ]; then + die "no remote location given. Either add a remote as additional argument or set topgit.remote" +fi + +name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +ref_exists "$name" || die "detached HEAD? Can't push that"
the common error message is: "not a TopGit-controlled branch".
Quoted 23 lines
tg-push.sh new file +23
-0+ +push_branch(){ + # don't push remotes + [ -z "${_dep##refs/remotes/*}" ] && return 0 + # if so desired omit non tgish deps + [ -z "$tgish_deps_only" ] || [ -n "$_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 +} + +for remote in $remotes; do + list="$( + # deps + if [ -n "$recurse_deps" ]; then + recurse_deps push_branch "$name" + fi + # current branch
tg-push.sh line 68
Quoted 10 lines
tg-push.sh new file +10
-0+ _dep="$name" + _dep_is_tgish=1 + push_branch "$name" + )" + echo "pushing:"; echo $list + if [ -n "$dry_run" ]; then + echo git push $remote $list + else + git push $remote $list + fi
why not pass the --dry-run option to git remote?
tg-push.sh line 69
Quoted 1 line
tg-push.sh new file +1
-0+done
Bert
Hi Marc, hi Bert,
Quoted 6 lines · Bert Wesarg
Quoted 4 lines · Marc Weber
Uwe K,
what do you think. Is there still much to change to include this patch into upstream?
I think its a usefull tool, but I haven't tested it yet.
Bert, thanks for your review.
Quoted 38 lines
Quoted 26 lines
new patch version. adding small comment saying that the two options --ne-deps and --tgish-only will seldomly used..
Sincerly
Marc Webercommit
c1cff518e3f70e9bd6cb4f2119b86e506ab43776
Author: Marc Weber <[email protected]>
Date: Thu May 7 06:46:28 2009 +0200t/tg-push
add tg-push pushing the branch, its deps and their bases
Usage: tg push [(--no-deps | --tgish-only)] remote*
Signed-off-by Marc Weber <[email protected]>README +0
-0@@ -480,6 +480,19 @@ tg updateTODO: tg update -a for updating all topic branches
Quoted 2 lines
+tg push
+ Usage: tg push [(--no-deps | --tgish-only)] remote*no need to repeat yourself. 'tg help push' will print the usage from tg-push first. And where is the --dry-run option?
Quoted 7 lines
+ $git push remote branch # this doesn't push the base.
+ $git push remote # pushes all branches (and bases)
+ You use
+
+ $tg push remote
+ to push the current branch,
its deps and their both tgish and non-tgish deps.
Quoted 2 lines
This phrase needs rewording, what about: "its deps, both their tgish and non-tgish ones."
I'd like to have a bit more prose. Something like:
tg push
~~~~~~~
pushes a TopGit-controlled topic branch to a remote repository. By default the remote gets all dependencies (both tgish and non-tgish) and bases pushed to.
Quoted 22 lines
Quoted 22 lines
tg-push.sh new file +19
-0@@ -0,0 +1,69 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# GPLv2 + +remotes= + +## Parse options see README + +recurse_deps=1 +tgish_deps_only= + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + --no-deps) + recurse_deps=;; + --dry-run) + dry_run=1;; + --tgish-only)
Quoted 8 lines
tg-push.sh line 24
Quoted 5 lines
tg-push.sh new file +5
-0+ tgish_deps_only=1;; + *) + remotes="$remotes $arg";; + esac +donenow i see why you have the Usage: in the README. common practice is to print the usage if an unknown option was given. see all the other tg-*.sh scripts.
ack
Quoted 6 lines
tg-push.sh line 28
Quoted 4 lines
tg-push.sh new file +4
-0+ +if [ -z "$remotes" ]; then + remotes="$(git config topgit.remote 2>/dev/null)" +fiHow effetcts the tg -r REMOTE option this command. Or more exactly why doesn't have this option an effect here?
ack
Quoted 9 lines
tg-push.sh line 35
Quoted 7 lines
tg-push.sh new file +7
-0+ +if [ -z "$remotes" ]; then + die "no remote location given. Either add a remote as additional argument or set topgit.remote" +fi + +name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +ref_exists "$name" || die "detached HEAD? Can't push that"the common error message is: "not a TopGit-controlled branch".
Quoted 4 lines
tg-push.sh line 39
Quoted 4 lines
tg-push.sh new file +4
-0+ +push_branch(){ + # don't push remotes + [ -z "${_dep##refs/remotes/*}" ] && return 0
maybe extend the comment to something like:
# if a remote is used ('topgit.remote' configuration variable or
# tg -r $remote, a tg-base implicitly depends on
# refs/remotes/$remote/top-bases/$_dep. Don't push these.You could even test if this is a dependency as described in this comment. Didn't test it, but something like
test "x$_dep" = "xrefs/remotes/$base_remote/top-bases/$_name"
could do the trick.
Quoted 2 lines
tg-push.sh line 41
Quoted 2 lines
tg-push.sh new file +2
-0+ # if so desired omit non tgish deps + [ -z "$tgish_deps_only" ] || [ -n "$_dep_is_tgish" ] || return 0
I've always problems to understand these constructs. Are these any better than
if test ...; then
return 0
fi
? And I think it's more readable to use
tgish_deps_only=false ... --tgish-only) tgish_deps_only=true;; ... if $tgish_deps_only; then ... fi
. (OK, I have to admit, that these constructs are used everywhere in topgit, but I'm not happy with these either.)
Quoted 7 lines
tg-push.sh line 49
Quoted 7 lines
tg-push.sh new file +7
-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
mmh, I wonder why you need to do the top-bases explicitly. recurse_deps doesn't that for you?
Quoted 12 lines
Quoted 12 lines
tg-push.sh new file +12
-0+} + +for remote in $remotes; do + list="$( + # deps + if [ -n "$recurse_deps" ]; then + recurse_deps push_branch "$name" + fi + # current branch + _dep="$name" + _dep_is_tgish=1 + push_branch "$name"
Quoted 8 lines
tg-push.sh line 68
Quoted 7 lines
tg-push.sh new file +7
-0+ )" + echo "pushing:"; echo $list + if [ -n "$dry_run" ]; then + echo git push $remote $list + else + git push $remote $list + fiwhy not pass the --dry-run option to git remote?
s/remote/push/
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
2009/5/7 Uwe Kleine-König <[email protected]>:
Quoted 20 lines
Hi Marc, hi Bert,
Quoted 2 lines
Quoted 2 lines
+ # if so desired omit non tgish deps
+ [ -z "$tgish_deps_only" ] || [ -n "$_dep_is_tgish" ] || return 0I've always problems to understand these constructs. Are these any better than
if test ...; then
return 0
fi? And I think it's more readable to use
tgish_deps_only=false
...
--tgish-only)
tgish_deps_only=true;;...
Quoted 8 lines
if $tgish_deps_only; then
...
fi
. (OK, I have to admit, that these constructs are used everywhere in topgit, but I'm not happy with these either.)
I also like the true/false style, its also useable with the current 'scheme':
$tgish_deps_only && ...
Marc, can you send an updated patch?
I would be interested in investigating this feature, which could be very useful in the context of the discussion in
http://bugs.debian.org/505303 and
http://marc.info/?l=vcs-pkg&m=124186459805688&w=2 about deleting branches, specifically preventing their re-publication. tg-push should allow us to get rid of the push refspecs in the repo config and return to the default of ':', thus preventing a normal push from pushing tips not already present remotely.
I'd still prefer tg-push integrated in git-push (e.g. by way of "related branches" which are always pushed alongside a normal branch), but that's not going to happen any time soon, I am sure...
Signature · 7 lines
martin | http://madduck.net/ | http://two.sentenc.es/ windoze nt crashed. i am the blue screen of death. no one hears your screams. spamtraps: [email protected]
Quoted 1 line · martin f krafft
Marc, can you send an updated patch?
Yes, I'll provide one ASAP (tonight or tomorrow). You already can apply the patch and use it (So do I).
Thanks for all the feedback. I have some other work to do first, sry. If I'm not fast enough: the public repo is read/write. You may just commit as well.
cu all!
Marc Weber
Feedback to Berts reply:
Quoted 1 line
tg-push first. And where is the --dry-run option?
fixed: added -h|--help option
Quoted 2 lines
This phrase needs rewording, what about: "its deps, both their tgish and non-tgish ones."
fixed, used Uwes text.
It looks like this now:
$tg push remote
to push the current branch, its deps and, both their tgish and non-tgish ones. You may add --no-deps and or --tgish-only to change this default behaviour. Use these only if you know what you are doing. They are only present for the sake of completeness.
Quoted 3 lines
now i see why you have the Usage: in the README. common practice is to print the usage if an unknown option was given. see all the other tg-*.sh scripts.
fixed: see -h|--help above. tg export lists the Usage as well in the README. (-> other topic)
Quoted 2 lines
How effetcts the tg -r REMOTE option this command. Or more exactly why doesn't have this option an effect here?
laziness. I thought about that myself. Its fixed now. Usage looks like this:
Usage: tg push [(--dry-run | --no-deps | --tgish-only)] [-r "remote remote2"]* branch*
Quoted 1 line
the common error message is: "not a TopGit-controlled branch".
:-) The point about this is: You can use
$tg push -r "remote1 remote2" non-tgish-branch1 non-tgish-branch2.
tg push will note that it can't find remotes but it'll push those branches. So you can "abuse" tg push to push normal branches to multiple remote locations.
Quoted 1 line
why not pass the --dry-run option to git remote?
git remote -> git push:
I added --dry-run so that I can see the list of branches which would be pushed if I had not used --dry-run. It isn't that important that's why I missed adding it to Usage as well.
Feedback to Uwe Klein Koenigs mail:
Quoted 1 line
I'd like to have a bit more prose. Something like:
fixed/misus
Quoted 6 lines
maybe extend the comment to something like:
# if a remote is used ('topgit.remote' configuration variable or # tg -r $remote, a tg-base implicitly depends on # refs/remotes/$remote/top-bases/$_dep. Don't push these.
Quoted 6 lines
You could even test if this is a dependency as described in this comment. Didn't test it, but something like
test "x$_dep" = "xrefs/remotes/$base_remote/top-bases/$_name"could do the trick.
I've extended the recurse_deps function reading from the global var no_remotes now. It's still ugly but less verbose and more intuitive than adding long comments
Quoted 3 lines
Quoted 1 line
+ [ -z "$tgish_deps_only" ] || [ -n "$_dep_is_tgish" ] || return 0
I've always problems to understand these constructs. Are these any better than
... :-) *lol* You proposed using them :-)
I do have a vary hard time reading writing them as well.
I have to use boolean algebra to wrap my head around those constructs.
Quoted 9 lines
Quoted 7 lines
+ echo "$_dep"
+ local base="top-bases/$_dep"
+ ifref_exists"$base"; then
+ echo "top-bases/$_dep"
+ else
+ echo "warning, no base found $base" 1>&2
+ fimmh, I wonder why you need to do the top-bases explicitly.
recurse_depsdoesn't that for you?
Have a closer look at that function, please:
"
has_remote "top-bases/$_name" && [ -z "$no_remotes" ] &&
echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile"
[..]
ref_exists "refs/top-bases/$_dep" ||
"are all occurrences of top-bases. And both only do checks (or push remotes)
Feedback to Berts 2nd reply:
Quoted 2 lines
I also like the true/false style, its also useable with the current 'scheme':
$tgish_deps_only && ...
great idea. true/false are sh builtins. adopted. I still prefer [ foo -a bar ]; or [ foo -o bar ]; for readability.
Sincerly
Marc Weber
commit cdab940eefc0a56e0daa8b270bace1aba00a3b57
Author: Marc Weber <[email protected]> Date: Mon May 11 05:25:40 2009 +0200
t/tg-push
add tg-push pushing the branch, its deps and their bases
.gitignore +2 -0
@@ -21,6 +21,8 @@ /tg-import.txt /tg-remote /tg-remote.txt +/tg-push +/tg-push.txt /tg .*.swp
README +6 -0
@@ -480,6 +480,12 @@ tg update TODO: tg update -a for updating all topic branches +tg push +~~~~~~~ + pushes a TopGit-controlled topic branch to a remote + repository. By default the remote gets all dependencies + (both tgish and non-tgish) and bases pushed to. + TODO: tg rename
tg-push.sh new file +82 -0
82 lines not on this page · raw message
tg.sh +2 -2
@@ -136,6 +136,7 @@ branch_annihilated() # of the whole function. # If recurse_deps() hits missing dependencies, it will append # them to space-separated $missing_deps list and skip them. +# set no_remotes to any value to omit remote dependencies (-> tg push) recurse_deps() { _cmd="$1"; shift
@@ -145,9 +146,8 @@ recurse_deps() _depsfile="$(mktemp -t tg-depsfile.XXXXXX)" # Check also our base against remote base. Checking our head # against remote head has to be done in the helper. - if has_remote "top-bases/$_name"; then + has_remote "top-bases/$_name" && [ -z "$no_remotes" ] && echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile" - fi # if the branch was annihilated, there exists no .topdeps file if ! branch_annihilated "$_name"; then
also sprach Marc Weber <[email protected]> [2009.05.11.0528 +0200]:
Quoted 4 lines
Quoted 2 lines
I also like the true/false style, its also useable with the current 'scheme':
$tgish_deps_only && ...great idea. true/false are sh builtins. adopted. I still prefer [ foo -a bar ]; or [ foo -o bar ]; for readability.
The patch looks good, I am going to test it now, I hope.
Quick comment: -a and -o are not POSIX-compliant, use [ "$foo" ] || [ "$bar" ] instead.
Signature · 6 lines
martin | http://madduck.net/ | http://two.sentenc.es/ the early bird may get the worm, but the second mouse gets the cheese in the trap. spamtraps: [email protected]
also sprach Marc Weber <[email protected]> [2009.05.11.0528 +0200]:
Quoted 9 lines
commit
cdab940eefc0a56e0daa8b270bace1aba00a3b57Author: Marc Weber <[email protected]> Date: Mon May 11 05:25:40 2009 +0200t/tg-push
add tg-push pushing the branch, its deps and their bases
Signed-off-by Marc Weber <[email protected]>
I tested this feature and it seems to work quite nicely. I have a couple of minor remarks, but otherwise am ready to sign this off and include it upstream.
As soon as this feature is there, we need to disable to push refspecs installed by tg-remote, and also probably add a warning to the hook in case they are present; those are evil.
tg-push.sh line 24
Quoted 3 lines
tg-push.sh new file +3
-0+ -h|--help) + echo "Usage: tg push [(--dry-run | --no-deps | --tgish-only)] [-r "remote remote2"]* branch*" + exit 1;;
--help should not exit non-zero, because if you ask for --help and it prints it, that's not an error.
tg-push.sh line 36
Quoted 3 lines
tg-push.sh new file +3
-0+if [ -z "$remotes" ]; then + remotes="$(git config topgit.remote 2>/dev/null)" +fi
This configuration key was news to me, but only because I usually run tg-remote without --populate, in which case it is not added. This is probably a bug in tg-remote and should be fixed alongside the push refspec removal.
tg-push.sh line 80
Quoted 6 lines
tg-push.sh new file +6
-0+ echo "pushing:"; echo $list + if $dry_run; then + echo git push $remote $list + else + git push $remote $list + fi
git-push has --dry-run, why not use that?
Signature · 5 lines
martin | http://madduck.net/ | http://two.sentenc.es/ due to lack of interest tomorrow has been cancelled. spamtraps: [email protected]
Hi Marc,
just some random nitpicks on top of your patch:
tg-push.sh +6 -10
@@ -8,7 +8,7 @@ remotes= recurse_deps=true tgish_deps_only=false -dry_run=false +dry_run= while [ -n "$1" ]; do arg="$1"; shift
@@ -16,11 +16,11 @@ while [ -n "$1" ]; do --no-deps) recurse_deps=false;; --dry-run) - dry_run=true;; + dry_run="--dry-run";; --tgish-only) tgish_deps_only=true;; -h|--help) - echo "Usage: tg push [(--dry-run | --no-deps | --tgish-only)] [-r "remote remote2"]* branch*" + echo "Usage: tg push [--dry-run] [--no-deps] [--tgish-only] [-r "remote remote2"]* branch*" exit 1;; -r) remotes="$remotes $1"
@@ -44,12 +44,12 @@ if [ -z "$branches" ]; then fi for name in $branches; do - ref_exists "$name" || die "detached HEAD? Can't push that" + ref_exists "$name" || die "detached HEAD? Can't push $name" done push_branch(){ # if so desired omit non tgish deps - $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0 + $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0 echo "$_dep" local base="top-bases/$_dep"
@@ -73,10 +73,6 @@ for remote in $remotes; do push_branch "$name" )" echo "pushing:"; echo $list - if $dry_run; then - echo git push $remote $list - else - git push $remote $list - fi + git push $dry_run "$remote" $list done done
Signature · 11 lines
1.6.2.4 It's untested, but I think it should be enough if it is eyeballed by someone else. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks to Bert Wesarg, Uwe Kleine-König and Martin f Krafft the patch is finally ready to be comitted (?) I included ukleineks last nitpicks.
ukleinek, usage line: remote2 = just another remote location.
Marc Weber
commit 0bfa198a3cae72d75ca1311bb7a8d495ca2b42cc
Author: Marc Weber <[email protected]> Date: Mon May 11 23:04:20 2009 +0200
add tg-push pushing the branch, its deps and their bases
.gitignore +2 -0
@@ -21,6 +21,8 @@ /tg-import.txt /tg-remote /tg-remote.txt +/tg-push +/tg-push.txt /tg .*.swp
README +6 -0
@@ -480,6 +480,12 @@ tg update TODO: tg update -a for updating all topic branches +tg push +~~~~~~~ + pushes a TopGit-controlled topic branch to a remote + repository. By default the remote gets all dependencies + (both tgish and non-tgish) and bases pushed to. + TODO: tg rename
tg-push.sh new file +78 -0
78 lines not on this page · raw message
tg.sh +4 -2
@@ -136,6 +136,7 @@ branch_annihilated() # of the whole function. # If recurse_deps() hits missing dependencies, it will append # them to space-separated $missing_deps list and skip them. +# set no_remotes to any value to omit remote dependencies (-> tg push) recurse_deps() { _cmd="$1"; shift
@@ -145,9 +146,8 @@ recurse_deps() _depsfile="$(mktemp -t tg-depsfile.XXXXXX)" # Check also our base against remote base. Checking our head # against remote head has to be done in the helper. - if has_remote "top-bases/$_name"; then + has_remote "top-bases/$_name" && [ -z "$no_remotes" ] && echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile" - fi # if the branch was annihilated, there exists no .topdeps file if ! branch_annihilated "$_name"; then
@@ -366,6 +366,8 @@ help|--help|-h) --hooks-path) # Internal command echo "@hooksdir@";; +eval) + eval "$@";; *) [ -r "@cmddir@"/tg-$cmd ] || { echo "Unknown subcommand: $cmd" >&2
also sprach Marc Weber <[email protected]> [2009.05.11.2306 +0200]:
Quoted 7 lines
commit
0bfa198a3cae72d75ca1311bb7a8d495ca2b42ccAuthor: Marc Weber <[email protected]> Date: Mon May 11 23:04:20 2009 +0200add tg-push pushing the branch, its deps and their bases
Signed-off-by Marc Weber <[email protected]>
Thanks, Marc!
Signature · 6 lines
martin | http://madduck.net/ | http://two.sentenc.es/
* Overfiend came out of the womb complaining.
-- #debian-devel
spamtraps: [email protected]Hello Marc,
Quoted 5 lines · Marc Weber
Thanks to Bert Wesarg, Uwe Kleine-König and Martin f Krafft the patch is finally ready to be comitted (?) I included ukleineks last nitpicks.
ukleinek, usage line: remote2 = just another remote location.
hhm, so you suggest that you can add more than one remote per -r option? I wouldn't document even if it works now.
Quoted 62 lines
.gitignore +2
-0@@ -21,6 +21,8 @@ /tg-import.txt /tg-remote /tg-remote.txt +/tg-push +/tg-push.txt /tg .*.swpREADME +6
-0@@ -480,6 +480,12 @@ tg update TODO: tg update -a for updating all topic branches +tg push +~~~~~~~ + pushes a TopGit-controlled topic branch to a remote + repository. By default the remote gets all dependencies + (both tgish and non-tgish) and bases pushed to. + TODO: tg renametg-push.sh new file +26
-0@@ -0,0 +1,78 @@ +#!/bin/sh +# TopGit - A different patch queue manager +# GPLv2 + +remotes="$base_remote" # honor -r flag of the tg command + +## Parse options see README + +recurse_deps=true +tgish_deps_only=false +dry_run= + +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + --no-deps) + recurse_deps=false;; + --dry-run) + dry_run=--dry-run;; + --tgish-only) + tgish_deps_only=true;; + -h|--help) + echo "Usage: tg [-r remote] push [--dry-run] [--no-deps] [--tgish-only] [-r "remote2 remote3"]* branch*" + exit 0;; + -r) + remotes="$remotes $1"
tg-push.sh line 36
Quoted 10 lines
tg-push.sh new file +10
-0+ shift + ;; + *) + branches="$branches $arg";; + esac +done + +if [ -z "$remotes" ]; then + remotes="$(git config topgit.remote 2>/dev/null)" +fi
This is obsolete with remotes=$base_remote above, right?
Quoted 65 lines
tg-push.sh new file +41
-0+if [ -z "$remotes" ]; then + die "no remote location given. Either use -r remote argument or set topgit.remote" +fi + +if [ -z "$branches" ]; then + branches="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" +fi + +for name in $branches; do + ref_exists "$name" || die "detached HEAD? Can't push $name" +done + +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 +} + +for remote in $remotes; do + 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 + done +donetg.sh +2
-2@@ -136,6 +136,7 @@ branch_annihilated() # of the whole function. # If recurse_deps() hits missing dependencies, it will append # them to space-separated $missing_deps list and skip them. +# set no_remotes to any value to omit remote dependencies (-> tg push) recurse_deps() { _cmd="$1"; shift@@ -145,9 +146,8 @@ recurse_deps() _depsfile="$(mktemp -t tg-depsfile.XXXXXX)" # Check also our base against remote base. Checking our head # against remote head has to be done in the helper. - if has_remote "top-bases/$_name"; then + has_remote "top-bases/$_name" && [ -z "$no_remotes" ] && echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile" - fi # if the branch was annihilated, there exists no .topdeps file if ! branch_annihilated "$_name"; then
tg.sh help|--help|-h) · line 373
Quoted 8 lines
tg.sh +2
-0@@ -366,6 +366,8 @@ help|--help|-h) --hooks-path) # Internal command echo "@hooksdir@";; +eval) + eval "$@";; *) [ -r "@cmddir@"/tg-$cmd ] || { echo "Unknown subcommand: $cmd" >&2
hhhm, this hunk is new and unused. Intended?
If it's OK for you I fix these up when commiting. I will break out the change to tg.sh as shown yesterday in irc.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 4 lines
hhhm, this hunk is new and unused. Intended?
If it's OK for you I fix these up when commiting. I will break out the change to
tg.shas shown yesterday in irc.
thank you x-times :-)
Sure that's fine with me. I already told you.
Quoted 2 lines
That was my intention my asking for the -r option. The -r option is to 'tg' not a tg-command. And it's still not addressed.
Bert: You're wrong:
tg.sh contains:
base_remote="$(git config topgit.remote 2>/dev/null)" || :
[...]
if [ "$1" = "-r" ]; then
shift
if [ -z "$1" ]; then
echo "Option -r requires an argument." >&2
do_help
exit 1
fi
base_remote="$1"; shift
tg="$tg -r $base_remote"fi
So base_remote is set by config first and then overwritten by the first -r flag. my remotes is initialised with that -r flag.
Boy However its wrong again now:
If you use tg push -r foo it will push to poth: the config value and foo. So probably its best to remove the second -r altogether and replace my remotes by base_remote. You still can use the undocumented -r "remote remote2" feature.
Marc Weber
Quoted 21 lines · Marc Weber
Quoted 2 lines
That was my intention my asking for the -r option. The -r option is to 'tg' not a tg-command. And it's still not addressed.
Bert: You're wrong:
tg.shcontains:base_remote="$(git config topgit.remote 2>/dev/null)" || :
[...]
if [ "$1" = "-r" ]; then
shift
if [ -z "$1" ]; then
echo "Option -r requires an argument." >&2do_help
exit 1
fi
base_remote="$1"; shift
tg="$tg -r $base_remote"
fi
Quoted 2 lines
So
base_remoteis set by config first and then overwritten by the first -r flag. my remotes is initialised with that -r flag.
Ahh, thanks for the pointer, I haven't seen this line.
Unfortunately I haven't tested it yet. But I'm looking forward to use it.
Bert
Quoted 2 lines
Marc Weber
Hello,
Quoted 1 line
Ahh, thanks for the pointer, I haven't seen this line.
I changed the remote handling a bit and pushed it out. IMO we could now remove the push entries added by tg and then call it 0.8 after some testing.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 tg-remote: don't add push specs but warn about existing ones.
topgit used to add some push specs to assert that topbases are pushed, too. This should now be handled by tg-push.
--- tg-remote.sh | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
tg-remote.sh +7 -2
@@ -28,8 +28,13 @@ git config "remote.$name.url" >/dev/null || die "unknown remote '$name'" ## Configure the remote git config --replace-all "remote.$name.fetch" "+refs/top-bases/*:refs/remotes/$name/top-bases/*" "\\+refs/top-bases/\\*:refs/remotes/$name/top-bases/\\*" -git config --replace-all "remote.$name.push" "+refs/top-bases/*:refs/top-bases/*" "\\+refs/top-bases/\\*:refs/top-bases/\\*" -git config --replace-all "remote.$name.push" "+refs/heads/*:refs/heads/*" "\\+refs/heads/\\*:refs/heads/\\*" + +if git config --get-all "remote.$name.push" "\\+refs/top-bases/\\*:refs/top-bases/\\*" >/dev/null && test "xtrue" != "x$(git config --bool --get topgit.dontwarnonoldpushspecs)"; then + info "Probably you want to remove the push specs introduced by an old version of topgit:" + info ' git config --unset-all "remote.'$name'.push" "\\+refs/top-bases/\\*:refs/top-bases/\\*"' + info ' git config --unset-all "remote.'$name'.push" "\\+refs/heads/\\*:refs/heads/\\*"' + info '(or use git config --bool --add topgit.dontwarnonoldpushspecs true to get rid of this warning)' +fi info "Remote $name can now follow TopGit topic branches." if [ -z "$populate" ]; then
Signature · 1 line
1.6.2.4
Re: [PATCH] tg-remote: don't add push specs but warn about existing ones.
also sprach Uwe Kleine-König <[email protected]> [2009.05.13.1204 +0200]:
Quoted 3 lines
Signed-off-by Uwe Kleine-König <[email protected]>Cc Marc Weber <[email protected]>Cc martin f. krafft <[email protected]>
Quoted 10 lines
tg-remote.sh +0
-2@@ -28,8 +28,13 @@ git config "remote.$name.url" >/dev/null || die "unknown remote '$name'" ## Configure the remote git config --replace-all "remote.$name.fetch" "+refs/top-bases/*:refs/remotes/$name/top-bases/*" "\\+refs/top-bases/\\*:refs/remotes/$name/top-bases/\\*" -git config --replace-all "remote.$name.push" "+refs/top-bases/*:refs/top-bases/*" "\\+refs/top-bases/\\*:refs/top-bases/\\*" -git config --replace-all "remote.$name.push" "+refs/heads/*:refs/heads/*" "\\+refs/heads/\\*:refs/heads/\\*"
tg-remote.sh git config "remote.$name.url" >/dev/null || die "unknown remote '$name'" · line 40
Quoted 10 lines
tg-remote.sh +7
-0+ +if git config --get-all "remote.$name.push" "\\+refs/top-bases/\\*:refs/top-bases/\\*" >/dev/null && test "xtrue" != "x$(git config --bool --get topgit.dontwarnonoldpushspecs)"; then + info "Probably you want to remove the push specs introduced by an old version of topgit:" + info ' git config --unset-all "remote.'$name'.push" "\\+refs/top-bases/\\*:refs/top-bases/\\*"' + info ' git config --unset-all "remote.'$name'.push" "\\+refs/heads/\\*:refs/heads/\\*"' + info '(or use git config --bool --add topgit.dontwarnonoldpushspecs true to get rid of this warning)' +fi info "Remote $name can now follow TopGit topic branches." if [ -z "$populate" ]; then
Thanks,
Signature · 9 lines
.''`. martin f. krafft <[email protected]> Related projects: : :' : proud Debian developer http://debiansystem.info `. `'` http://people.debian.org/~madduck http://vcs-pkg.org `- Debian - when you have better things to do than fixing systems "the mind of the thoroughly well-informed man is a dreadful thing. it is like a bric-à-brac shop, all monsters and dust, with everything priced above its proper value." -- oscar wilde
2009/5/12 Uwe Kleine-König <[email protected]>:
Quoted 10 lines
Hello Marc,
Quoted 5 lines · Marc Weber
Thanks to Bert Wesarg, Uwe Kleine-König and Martin f Krafft the patch is finally ready to be comitted (?) I included ukleineks last nitpicks.
ukleinek, usage line: remote2 = just another remote location.
hhm, so you suggest that you can add more than one remote per -r option? I wouldn't document even if it works now.
That was my intention my asking for the -r option. The -r option is to 'tg' not a tg-command. And it's still not addressed.
Bert