git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] topgit  tg push feature
@ 2009-04-25 16:13 Marc Weber
  2009-04-25 16:34 ` Marc Weber
  0 siblings, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-04-25 16:13 UTC (permalink / raw)
  To: git; +Cc: u.kleine-koenig

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>

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit  tg push feature
  2009-04-25 16:13 [PATCH] topgit tg push feature Marc Weber
@ 2009-04-25 16:34 ` Marc Weber
  2009-05-05  9:34   ` Marc Weber
  0 siblings, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-04-25 16:34 UTC (permalink / raw)
  To: git; +Cc: u.kleine-koenig

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-04-25 16:34 ` Marc Weber
@ 2009-05-05  9:34   ` Marc Weber
  2009-05-07  4:59     ` Marc Weber
  0 siblings, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-05-05  9:34 UTC (permalink / raw)
  To: git; +Cc: u.kleine-koenig

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>

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-05  9:34   ` Marc Weber
@ 2009-05-07  4:59     ` Marc Weber
  2009-05-07  5:45       ` Bert Wesarg
  0 siblings, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-05-07  4:59 UTC (permalink / raw)
  To: git; +Cc: u.kleine-koenig

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>

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-07  4:59     ` Marc Weber
@ 2009-05-07  5:45       ` Bert Wesarg
  2009-05-07  8:43         ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Bert Wesarg @ 2009-05-07  5:45 UTC (permalink / raw)
  To: Marc Weber, git, u.kleine-koenig

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.

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

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

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-07  5:45       ` Bert Wesarg
@ 2009-05-07  8:43         ` Uwe Kleine-König
  2009-05-07  9:50           ` Bert Wesarg
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2009-05-07  8:43 UTC (permalink / raw)
  To: Marc Weber; +Cc: Bert Wesarg, git

Hi Marc, hi Bert,


On Thu, May 07, 2009 at 07:45:21AM +0200, Bert Wesarg wrote:
> 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.
 
> > 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.

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


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

> > +}
> > +
> > +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/  |

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-07  8:43         ` Uwe Kleine-König
@ 2009-05-07  9:50           ` Bert Wesarg
  2009-05-09 10:36             ` martin f krafft
  0 siblings, 1 reply; 22+ messages in thread
From: Bert Wesarg @ 2009-05-07  9:50 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Marc Weber, git

2009/5/7 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> 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 && ...

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-07  9:50           ` Bert Wesarg
@ 2009-05-09 10:36             ` martin f krafft
  2009-05-09 19:09               ` Marc Weber
  0 siblings, 1 reply; 22+ messages in thread
From: martin f krafft @ 2009-05-09 10:36 UTC (permalink / raw)
  To: Bert Wesarg, Uwe Kleine-König, Marc Weber, git

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

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

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-09 10:36             ` martin f krafft
@ 2009-05-09 19:09               ` Marc Weber
  2009-05-11  3:28                 ` Marc Weber
  0 siblings, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-05-09 19:09 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-09 19:09               ` Marc Weber
@ 2009-05-11  3:28                 ` Marc Weber
  2009-05-11  7:25                   ` martin f krafft
                                     ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Marc Weber @ 2009-05-11  3:28 UTC (permalink / raw)
  To: git

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>

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11  3:28                 ` Marc Weber
@ 2009-05-11  7:25                   ` martin f krafft
  2009-05-11  7:47                   ` martin f krafft
  2009-05-11 19:55                   ` Uwe Kleine-König
  2 siblings, 0 replies; 22+ messages in thread
From: martin f krafft @ 2009-05-11  7:25 UTC (permalink / raw)
  To: Marc Weber, git

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

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

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11  3:28                 ` Marc Weber
  2009-05-11  7:25                   ` martin f krafft
@ 2009-05-11  7:47                   ` martin f krafft
  2009-05-11 19:55                   ` Uwe Kleine-König
  2 siblings, 0 replies; 22+ messages in thread
From: martin f krafft @ 2009-05-11  7:47 UTC (permalink / raw)
  To: Marc Weber, git

[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]

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

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

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11  3:28                 ` Marc Weber
  2009-05-11  7:25                   ` martin f krafft
  2009-05-11  7:47                   ` martin f krafft
@ 2009-05-11 19:55                   ` Uwe Kleine-König
  2009-05-11 21:06                     ` Marc Weber
  2 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2009-05-11 19:55 UTC (permalink / raw)
  To: Marc Weber, git

Hi Marc,

just some random nitpicks on top of your patch:

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11 19:55                   ` Uwe Kleine-König
@ 2009-05-11 21:06                     ` Marc Weber
  2009-05-11 21:39                       ` martin f krafft
  2009-05-12  5:13                       ` Uwe Kleine-König
  0 siblings, 2 replies; 22+ messages in thread
From: Marc Weber @ 2009-05-11 21:06 UTC (permalink / raw)
  To: git

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>

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11 21:06                     ` Marc Weber
@ 2009-05-11 21:39                       ` martin f krafft
  2009-05-12  5:13                       ` Uwe Kleine-König
  1 sibling, 0 replies; 22+ messages in thread
From: martin f krafft @ 2009-05-11 21:39 UTC (permalink / raw)
  To: Marc Weber, git

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-11 21:06                     ` Marc Weber
  2009-05-11 21:39                       ` martin f krafft
@ 2009-05-12  5:13                       ` Uwe Kleine-König
  2009-05-12  6:22                         ` Bert Wesarg
  2009-05-12  7:54                         ` Marc Weber
  1 sibling, 2 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2009-05-12  5:13 UTC (permalink / raw)
  To: Marc Weber, git

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.

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

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-12  5:13                       ` Uwe Kleine-König
@ 2009-05-12  6:22                         ` Bert Wesarg
  2009-05-12  7:54                         ` Marc Weber
  1 sibling, 0 replies; 22+ messages in thread
From: Bert Wesarg @ 2009-05-12  6:22 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Marc Weber, git

2009/5/12 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> 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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-12  5:13                       ` Uwe Kleine-König
  2009-05-12  6:22                         ` Bert Wesarg
@ 2009-05-12  7:54                         ` Marc Weber
  2009-05-12  8:55                           ` Bert Wesarg
  1 sibling, 1 reply; 22+ messages in thread
From: Marc Weber @ 2009-05-12  7:54 UTC (permalink / raw)
  To: git

> 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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-12  7:54                         ` Marc Weber
@ 2009-05-12  8:55                           ` Bert Wesarg
  2009-05-12  9:02                             ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Bert Wesarg @ 2009-05-12  8:55 UTC (permalink / raw)
  To: Marc Weber, git

On Tue, May 12, 2009 at 09:54, Marc Weber <marco-oweber@gmx.de> wrote:
>>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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] topgit tg push feature
  2009-05-12  8:55                           ` Bert Wesarg
@ 2009-05-12  9:02                             ` Uwe Kleine-König
  2009-05-13 10:04                               ` [PATCH] tg-remote: don't add push specs but warn about existing ones Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2009-05-12  9:02 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Marc Weber, git

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

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH] tg-remote: don't add push specs but warn about existing ones.
  2009-05-12  9:02                             ` Uwe Kleine-König
@ 2009-05-13 10:04                               ` Uwe Kleine-König
  2009-05-13 11:42                                 ` martin f krafft
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2009-05-13 10:04 UTC (permalink / raw)
  To: git; +Cc: Marc Weber, martin f. krafft, 528442

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(-)

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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] tg-remote: don't add push specs but warn about existing ones.
  2009-05-13 10:04                               ` [PATCH] tg-remote: don't add push specs but warn about existing ones Uwe Kleine-König
@ 2009-05-13 11:42                                 ` martin f krafft
  0 siblings, 0 replies; 22+ messages in thread
From: martin f krafft @ 2009-05-13 11:42 UTC (permalink / raw)
  To: Uwe Kleine-König, git, Marc Weber, 528442

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

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>

> 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

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-05-13 11:42 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-25 16:13 [PATCH] topgit tg push feature Marc Weber
2009-04-25 16:34 ` Marc Weber
2009-05-05  9:34   ` Marc Weber
2009-05-07  4:59     ` Marc Weber
2009-05-07  5:45       ` Bert Wesarg
2009-05-07  8:43         ` Uwe Kleine-König
2009-05-07  9:50           ` Bert Wesarg
2009-05-09 10:36             ` martin f krafft
2009-05-09 19:09               ` Marc Weber
2009-05-11  3:28                 ` Marc Weber
2009-05-11  7:25                   ` martin f krafft
2009-05-11  7:47                   ` martin f krafft
2009-05-11 19:55                   ` Uwe Kleine-König
2009-05-11 21:06                     ` Marc Weber
2009-05-11 21:39                       ` martin f krafft
2009-05-12  5:13                       ` Uwe Kleine-König
2009-05-12  6:22                         ` Bert Wesarg
2009-05-12  7:54                         ` Marc Weber
2009-05-12  8:55                           ` Bert Wesarg
2009-05-12  9:02                             ` Uwe Kleine-König
2009-05-13 10:04                               ` [PATCH] tg-remote: don't add push specs but warn about existing ones Uwe Kleine-König
2009-05-13 11:42                                 ` martin f krafft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).