threads / patch / 19553

v2, 3 partsRe: [TopGit PATCH v2 2/3] tg-push: prevent multiple occurences of branches

Subject: Re: [TopGit PATCH v2 2/3] tg-push: prevent multiple occurences of branches

## tl;dr

5 messages between May 27, 2009 and May 28, 2009. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Bert Wesarg· May 27, 2009, 08:16 UTC · lore

[PATCH TopGit 1/3] tg-push: remove useless warning of missing bases for non-tgish branches

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-push.sh |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
Show changes to tg-push.sh +1 −5
diff --git a/tg-push.sh b/tg-push.sh
index 8d09a02..40849ae 100644
--- a/tg-push.sh
+++ b/tg-push.sh
@@ -51,12 +51,8 @@ push_branch()
 	$tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0
 
 	echo "$_dep"
-	local base="top-bases/$_dep"
-	if ref_exists "$base"; then
+	[ -z "$_dep_is_tgish" ] ||
 		echo "top-bases/$_dep"
-	else
-		echo "warning, no base found $base" 1>&2
-	fi
 }
 
 for name in $branches; do
-- 
tg: (b725fc9..) bw/push-remove-useless-warning (depends on: master)
Bert Wesarg· May 27, 2009, 08:16 UTC · re: Bert Wesarg · lore

[TopGit PATCH v2 2/3] tg-push: prevent multiple occurences of branches

So, I finally tried the tg-push and got a lot of warnings and errors:

warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master warning, no base found top-bases/master

error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/master is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/master error: Ref refs/heads/bw/log is at a16df35cc7009b36f6f71717ae3d9a3dc29987da but expected 0000000000000000000000000000000000000000 error: failed to lock refs/heads/bw/log error: Ref refs/top-bases/bw/log is at b725fc951a37854fc65945ac5bcab3bc61ccbd94 but expected 0000000000000000000000000000000000000000 error: failed to lock refs/top-bases/bw/log

 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] master -> master (failed to lock)
 ! [remote rejected] bw/log -> bw/log (failed to lock)
 ! [remote rejected] refs/top-bases/bw/log -> refs/top-bases/bw/log (failed to lock)
Also the result was ok this output is defintive not ok.

To prevent multiple occurences of the same branchname we sort -u these at the end, as suggested by Uwe.

Regards, Bert

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-push.sh |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)
Show changes to tg-push.sh +19 −14
diff --git a/tg-push.sh b/tg-push.sh
index 40849ae..8e1b43f 100644
--- a/tg-push.sh
+++ b/tg-push.sh
@@ -45,27 +45,32 @@ for name in $branches; do
 	ref_exists "$name" || die "detached HEAD? Can't push $name"
 done
 
+_listfile="$(mktemp -t tg-push-listfile.XXXXXX)"
+trap "rm -f \"$_listfile\"" 0
+
 push_branch()
 {
 	# if so desired omit non tgish deps
 	$tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0
 
-	echo "$_dep"
+	echo "$_dep" >> "$_listfile"
 	[ -z "$_dep_is_tgish" ] ||
-		echo "top-bases/$_dep"
+		echo "top-bases/$_dep" >> "$_listfile"
 }
 
 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
+	# current branch
+	# re-use push_branch, which expects some pre-defined variables
+	_dep="$name"
+	_dep_is_tgish=1
+	ref_exists "top-bases/$_dep" ||
+		_dep_is_tgish=
+	push_branch "$name"
+
+	# deps
+	$recurse_deps &&
+		no_remotes=1 recurse_deps push_branch "$name"
+
+	# remove multiple occurrences of the same branch
+	sort -u "$_listfile" | xargs git push $dry_run "$remote"
 done
-- 
tg: (8f4fb90..) bw/push-fixes (depends on: bw/push-remove-useless-warning)
Bert Wesarg· May 27, 2009, 08:17 UTC · re: Bert Wesarg · lore

[TopGit PATCH v2 3/3] tg-push: handle non-tgish branches

tg push dies if you give it a non-tgish branch:

$ tg push -r push-test master fatal: Not a valid object name refs/top-bases/master fatal: ambiguous argument '^{tree}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions fatal: Not a valid object name master:.topdeps

Fix this.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 tg-push.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to tg-push.sh +2 −2
diff --git a/tg-push.sh b/tg-push.sh
index 8e1b43f..cd208a0 100644
--- a/tg-push.sh
+++ b/tg-push.sh
@@ -67,8 +67,8 @@ for name in $branches; do
 		_dep_is_tgish=
 	push_branch "$name"
 
-	# deps
-	$recurse_deps &&
+	# deps but only if branch is tgish
+	$recurse_deps && [ -n "$_dep_is_tgish" ] &&
 		no_remotes=1 recurse_deps push_branch "$name"
 
 	# remove multiple occurrences of the same branch
-- 
tg: (cbca164..) bw/push-fixes-2 (depends on: bw/push-fixes)
Uwe Kleine-König· May 28, 2009, 07:24 UTC · re: Bert Wesarg · lore

Re: [TopGit PATCH v2 3/3] tg-push: handle non-tgish branches

Hi,
Show 5 quoted lines
> -	# deps
> -	$recurse_deps &&
> +	# deps but only if branch is tgish
> +	$recurse_deps && [ -n "$_dep_is_tgish" ] &&
>  		no_remotes=1 recurse_deps push_branch "$name"
OK, wait for 1-2/3.

Best regards Uwe

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

I didn't try, but looks OK. I'd do some commit log massaging, but I can do that while commiting. I just wait for 1/3.

Thanks Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

← back to recent threads