Skip to contentSkip to conversation

tg-push: remove useless warning of missing bases for non-tgish branches

PATCH New Bert Wesarg 2 participants 5 messages Jun 15, 2016 – Aug 13, 2016

lore
Share & tools
lore
#0 lore raw

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

---
 tg-push.sh |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
tg-push.sh +1 -5
index 8d09a02..40849ae 100644
@@ -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
Signature · 1 line
tg: (b725fc9..) bw/push-remove-useless-warning (depends on: master)
#1 lore raw

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

---
 tg-push.sh |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)
tg-push.sh +19 -14
index 40849ae..8e1b43f 100644
@@ -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
Signature · 1 line
tg: (8f4fb90..) bw/push-fixes (depends on: bw/push-remove-useless-warning)
#2 lore raw

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.

---
 tg-push.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
tg-push.sh +2 -2
index 8e1b43f..cd208a0 100644
@@ -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
Signature · 1 line
tg: (cbca164..) bw/push-fixes-2 (depends on: bw/push-fixes)
#3 lore raw

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

Hi,

tg-push.sh for name in $branches; do · line 72

Quoted 5 lines
tg-push.sh +2 -2
-	# 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

Signature · 2 lines
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
#4 lore raw

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

In reply to Bert Wesarg

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

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