threads / patch / 19060

patchtopgit tg push feature

Subject: [PATCH] topgit tg push feature

## tl;dr

22 messages between Apr 25, 2009 and May 13, 2009. Diffs are folded; open one to read it.

replies: 21people: 5as markdown or json

Marc Weber· Apr 25, 2009, 16:13 UTC · lore

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 <marco-oweber@gmx.de>
Date:   Sat Apr 25 17:52:44 2009 +0200
    add tg-push [-r] pushing the branch and its base
    
    -r: also push tgish dependencies
    
    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Show changes to 4 files +68 −0

.gitignore, README, tg-push.sh, tg-push.txt

diff --git a/.gitignore b/.gitignore
index eb56446..2f6d991 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-push
+/tg-push.txt
 /tg
 .*.swp
 
diff --git a/README b/README
index d2f095d..f90a7b3 100644
--- a/README
+++ b/README
@@ -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
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644
index 0000000..0f8c964
--- /dev/null
+++ b/tg-push.sh
@@ -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
diff --git a/tg-push.txt b/tg-push.txt
new file mode 100644
index 0000000..de9b259
--- /dev/null
+++ b/tg-push.txt
@@ -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
Marc Weber· Apr 25, 2009, 16:34 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

On Sat, Apr 25, 2009 at 06:13:00PM +0200, Marc Weber wrote:
> The patch should apply cleanly on 9f685cd79.
> Or fetch it from branch t/tg-push at git://mawercer.de/topGit

Use the t/tg-push branch. I've fixed two small bugs. Sorry for this inconvinience.

Thanks Marc Weber

Marc Weber· May 5, 2009, 09:34 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

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 <marco-oweber@gmx.de>
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*
    
    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Show changes to 3 files +83 −0

.gitignore, README, tg-push.sh

diff --git a/.gitignore b/.gitignore
index eb56446..2f6d991 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-push
+/tg-push.txt
 /tg
 .*.swp
 
diff --git a/README b/README
index d2f095d..290e883 100644
--- a/README
+++ b/README
@@ -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
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644
index 0000000..e79c19f
--- /dev/null
+++ b/tg-push.sh
@@ -0,0 +1,68 @@
+#!/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)
+		tgish_deps_only=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(){
+	# don't push remotes, don't push non tg branches
+	[ -n "${_dep##*/remotes/*}" ] || [ -n "$_dep_is_tgish" ] || 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
+		_dep="$name"
+		_dep_is_tgish=1
+	)"
+	echo "pushing:"; echo $list
+	if [ -n "$dry_run" ]; then
+		echo git push $remote $list
+	else
+		git push $remote $list
+	fi
+done
Marc Weber· May 7, 2009, 04:59 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

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 <marco-oweber@gmx.de>
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*
    
    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Show changes to 2 files +82 −0

README, tg-push.sh

diff --git a/README b/README
index d2f095d..6f2b2bc 100644
--- a/README
+++ b/README
@@ -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
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644
index 0000000..49124e6
--- /dev/null
+++ b/tg-push.sh
@@ -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)
+		tgish_deps_only=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(){
+	# 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
+		_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
+done
Bert Wesarg· May 7, 2009, 05:45 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

On Thu, May 7, 2009 at 06:59, Marc Weber <marco-oweber@gmx.de> wrote:
> 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.
Show 29 quoted lines
>
> 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 <marco-oweber@gmx.de>
> 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*
>
>    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
>
> diff --git a/README b/README
> index d2f095d..6f2b2bc 100644
> --- a/README
> +++ b/README
> @@ -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*

no need to repeat yourself. 'tg help push' will print the usage from tg-push first. And where is the --dry-run option?

Show 8 quoted 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.

This phrase needs rewording, what about: "its deps, both their tgish and non-tgish ones."

> 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.
Show 34 quoted lines
> +
>  TODO: tg rename
>
>
> diff --git a/tg-push.sh b/tg-push.sh
> new file mode 100644
> index 0000000..49124e6
> --- /dev/null
> +++ b/tg-push.sh
> @@ -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)
> +               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.

> +
> +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?

Show 7 quoted lines
> +
> +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".
Show 33 quoted lines
> +
> +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
> +               _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?
> +done
Bert
Uwe Kleine-König· May 7, 2009, 08:43 UTC · re: Bert Wesarg · lore

Re: [PATCH] topgit tg push feature

Hi Marc, hi Bert,
On Thu, May 07, 2009 at 07:45:21AM +0200, Bert Wesarg wrote:
Show 6 quoted lines
> On Thu, May 7, 2009 at 06:59, Marc Weber <marco-oweber@gmx.de> wrote:
> > 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.
 
Show 40 quoted lines
> > 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 <marco-oweber@gmx.de>
> > 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*
> >
> >    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
> >
> > diff --git a/README b/README
> > index d2f095d..6f2b2bc 100644
> > --- a/README
> > +++ b/README
> > @@ -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*
> no need to repeat yourself. 'tg help push' will print the usage from
> tg-push first. And where is the --dry-run option?
> 
> > +       $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."
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.
Show 30 quoted lines
> > --- /dev/null
> > +++ b/tg-push.sh
> > @@ -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)
> > +               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.
ack
 
Show 6 quoted lines
> > +
> > +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?
ack
 
Show 13 quoted lines
> > +
> > +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".
> 
> > +
> > +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.
> > +       # 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.)

Show 7 quoted lines
> > +       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?

Show 20 quoted lines
> > +}
> > +
> > +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"
> > +       )"
> > +       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?
s/remote/push/
 
Best regards
Uwe
-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Bert Wesarg· May 7, 2009, 09:50 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] topgit tg push feature

2009/5/7 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
Show 28 quoted lines
> Hi Marc, hi Bert,
>> > +       # 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.)
I also like the true/false style, its also useable with the current 'scheme':
       $tgish_deps_only && ...
martin f krafft· May 9, 2009, 10:36 UTC · re: Bert Wesarg · lore

Re: [PATCH] topgit tg push feature

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...

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
windoze nt crashed.
i am the blue screen of death.
no one hears your screams.
 
spamtraps: madduck.bogus@madduck.net
Marc Weber· May 9, 2009, 19:09 UTC · re: martin f krafft · lore

Re: [PATCH] topgit tg push feature

On Sat, May 09, 2009 at 12:36:25PM +0200, martin f krafft wrote:
> 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

Marc Weber· May 11, 2009, 03:28 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

Feedback to Berts reply:
  > tg-push first. And where is the --dry-run option?
  fixed: added -h|--help option
  >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.
  >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)
  >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*
  > 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.
  > 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:
  > I'd like to have a bit more prose.  Something like:
  fixed/misus
  > 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.
  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
  > > +       [ -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.
  > > +       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?
  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:
  >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 <marco-oweber@gmx.de>
Date:   Mon May 11 05:25:40 2009 +0200
    t/tg-push
    
    add tg-push  pushing the branch, its deps and their bases
    
    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Show changes to 4 files +92 −2

.gitignore, README, tg-push.sh, tg.sh

diff --git a/.gitignore b/.gitignore
index eb56446..2f6d991 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-push
+/tg-push.txt
 /tg
 .*.swp
 
diff --git a/README b/README
index d2f095d..495c70b 100644
--- a/README
+++ b/README
@@ -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
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644
index 0000000..0fa7854
--- /dev/null
+++ b/tg-push.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# GPLv2
+
+remotes=
+
+## Parse options see README
+
+recurse_deps=true
+tgish_deps_only=false
+dry_run=false
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	--no-deps)
+		recurse_deps=false;;
+	--dry-run)
+		dry_run=true;;
+	--tgish-only)
+		tgish_deps_only=true;;
+	-h|--help)
+		echo "Usage: tg push [(--dry-run | --no-deps | --tgish-only)] [-r "remote remote2"]* branch*"
+		exit 1;;
+	-r)
+		remotes="$remotes $1"
+		shift
+		;;
+	*)
+		branches="$branches $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 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 that"
+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
+		if $dry_run; then
+			echo git push $remote $list
+		else
+			git push $remote $list
+		fi
+	done
+done
diff --git a/tg.sh b/tg.sh
index 0804f73..94f38f4 100644
--- a/tg.sh
+++ b/tg.sh
@@ -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
martin f krafft· May 11, 2009, 07:25 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

also sprach Marc Weber <marco-oweber@gmx.de> [2009.05.11.0528 +0200]:
>   >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.

-- 
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: madduck.bogus@madduck.net
martin f krafft· May 11, 2009, 07:47 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

also sprach Marc Weber <marco-oweber@gmx.de> [2009.05.11.0528 +0200]:
Show 9 quoted lines
> commit cdab940eefc0a56e0daa8b270bace1aba00a3b57
> Author: Marc Weber <marco-oweber@gmx.de>
> Date:   Mon May 11 05:25:40 2009 +0200
> 
>     t/tg-push
>     
>     add tg-push  pushing the branch, its deps and their bases
>     
>     Signed-off-by: Marc Weber <marco-oweber@gmx.de>

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.

> +	-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.

> +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.

Show 6 quoted lines
> +		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?
-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
due to lack of interest tomorrow has been cancelled.
 
spamtraps: madduck.bogus@madduck.net
Uwe Kleine-König· May 11, 2009, 19:55 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

Hi Marc,
just some random nitpicks on top of your patch:
Show changes to tg-push.sh +6 −10
diff --git a/tg-push.sh b/tg-push.sh
index 0fa7854..8897a18 100644
--- a/tg-push.sh
+++ b/tg-push.sh
@@ -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
-- 
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/  |
Marc Weber· May 11, 2009, 21:06 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] topgit tg push feature

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 <marco-oweber@gmx.de>
Date:   Mon May 11 23:04:20 2009 +0200
    add tg-push pushing the branch, its deps and their bases
    
    Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Show changes to 4 files +90 −2

.gitignore, README, tg-push.sh, tg.sh

diff --git a/.gitignore b/.gitignore
index eb56446..2f6d991 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-push
+/tg-push.txt
 /tg
 .*.swp
 
diff --git a/README b/README
index d2f095d..495c70b 100644
--- a/README
+++ b/README
@@ -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
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644
index 0000000..5df5073
--- /dev/null
+++ b/tg-push.sh
@@ -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"
+		shift
+		;;
+	*)
+		branches="$branches $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 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
+done
diff --git a/tg.sh b/tg.sh
index 0804f73..7d98dbd 100644
--- a/tg.sh
+++ b/tg.sh
@@ -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
martin f krafft· May 11, 2009, 21:39 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

also sprach Marc Weber <marco-oweber@gmx.de> [2009.05.11.2306 +0200]:
Show 7 quoted lines
> commit 0bfa198a3cae72d75ca1311bb7a8d495ca2b42cc
> Author: Marc Weber <marco-oweber@gmx.de>
> Date:   Mon May 11 23:04:20 2009 +0200
> 
>     add tg-push pushing the branch, its deps and their bases
>     
>     Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Signed-off-by: martin f. krafft <madduck@madduck.net>
Thanks, Marc!
-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
* Overfiend came out of the womb complaining.
                                                    -- #debian-devel
 
spamtraps: madduck.bogus@madduck.net
Uwe Kleine-König· May 12, 2009, 05:13 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

Hello Marc,
On Mon, May 11, 2009 at 11:06:14PM +0200, Marc Weber wrote:
Show 5 quoted lines
> 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.

Show 72 quoted lines
> diff --git a/.gitignore b/.gitignore
> index eb56446..2f6d991 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -21,6 +21,8 @@
>  /tg-import.txt
>  /tg-remote
>  /tg-remote.txt
> +/tg-push
> +/tg-push.txt
>  /tg
>  .*.swp
>  
> diff --git a/README b/README
> index d2f095d..495c70b 100644
> --- a/README
> +++ b/README
> @@ -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
>  
>  
> diff --git a/tg-push.sh b/tg-push.sh
> new file mode 100644
> index 0000000..5df5073
> --- /dev/null
> +++ b/tg-push.sh
> @@ -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"
> +		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?
Show 73 quoted lines
> +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
> +done
> diff --git a/tg.sh b/tg.sh
> index 0804f73..7d98dbd 100644
> --- a/tg.sh
> +++ b/tg.sh
> @@ -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
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

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Bert Wesarg· May 12, 2009, 06:22 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] topgit tg push feature

2009/5/12 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
Show 10 quoted lines
> Hello Marc,
>
> On Mon, May 11, 2009 at 11:06:14PM +0200, Marc Weber wrote:
>> 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
Marc Weber· May 12, 2009, 07:54 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] topgit tg push feature

> 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.

thank you x-times :-) Sure that's fine with me. I already told you.

>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
Bert Wesarg· May 12, 2009, 08:55 UTC · re: Marc Weber · lore

Re: [PATCH] topgit tg push feature

On Tue, May 12, 2009 at 09:54, Marc Weber <marco-oweber@gmx.de> wrote:
Show 23 quoted 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.
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
>
> Marc Weber
Uwe Kleine-König· May 12, 2009, 09:02 UTC · re: Bert Wesarg · lore

Re: [PATCH] topgit tg push feature

Hello,
> 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

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Uwe Kleine-König· May 13, 2009, 10:04 UTC · re: Uwe Kleine-König · lore

[PATCH] 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.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Marc Weber <marco-oweber@gmx.de>
Cc: martin f. krafft <madduck@debian.org>
Cc: 528442@bugs.debian.org
---
 tg-remote.sh |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Show changes to tg-remote.sh +7 −2
diff --git a/tg-remote.sh b/tg-remote.sh
index 3a40081..86dcd9a 100644
--- a/tg-remote.sh
+++ b/tg-remote.sh
@@ -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
-- 
1.6.2.4
martin f krafft· May 13, 2009, 11:42 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] tg-remote: don't add push specs but warn about existing ones.

also sprach Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [2009.05.13.1204 +0200]:
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Marc Weber <marco-oweber@gmx.de>
> Cc: martin f. krafft <madduck@debian.org>
Signed-off-by: martin f. krafft <madduck@debian.org>
Show 20 quoted lines
> diff --git a/tg-remote.sh b/tg-remote.sh
> index 3a40081..86dcd9a 100644
> --- a/tg-remote.sh
> +++ b/tg-remote.sh
> @@ -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
Thanks,
-- 
 .''`.   martin f. krafft <madduck@d.o>      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

← back to recent threads