Skip to contentSkip to conversation

hooks/pre-commit.sh: fix it again

PATCH In review Bert Wesarg 4 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hooks/pre-commit.sh: fix it again

First I think the '#' is a leftover, second this is now a bashism.

---
 hooks/pre-commit.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hooks/pre-commit.sh +2 -2
index a12cfa6..edf2932 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # TopGit - A different patch queue manager
 # (c) Petr Baudis <[email protected]>  2008
 # GPLv2
@@ -20,7 +20,7 @@ tg_util
 if head_=$(git symbolic-ref -q HEAD); then
 	case "$head_" in
 		refs/heads/*)
-			git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
+			git rev-parse -q --verify "${head_/refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
 		*)
 			exit 0;;
 	esac
Signature · 1 line
tg: (fcb488d..) bw/fix-hook-again (depends on: master)
#1 lore raw

also sprach Bert Wesarg <[email protected]> [2009.03.25.1243 +0100]:

Quoted 1 line

First I think the '#' is a leftover, second this is now a bashism.

I think this can be rewritten as POSIX as follows:

hooks/pre-commit.sh tg_util · line 23

Quoted 2 lines
hooks/pre-commit.sh +1 -1
-			git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
+			git rev-parse -q --verify "${head_/refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
  git rev-parse -q --verify "refs/top-bases/${head_##refs/heads/}" >/dev/null || exit 0;;

This turns e.g. refs/heads/foo into foo and prepends refs/top-bases/, which should be the same effect, assuming that the variable's value contains nothing else but the ref's path.

Signature · 8 lines
 .''`.   martin f. krafft <[email protected]>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
 
logik ist analsadismus: gedanken werden gewaltsam
durch einen engen gang gepreßt.
                                                    -- frei nach lacan
#2 lore raw
In reply to Bert Wesarg
Quoted 1 line · Bert Wesarg

First I think the '#' is a leftover, second this is now a bashism.

according to bash(1):

If pattern begins with #, it must match at the beginning of the expanded value of parameter.

And I noticed, too, that this is a bashism. Using dash it fails, even with your patch.

I would prefer to really fix it now.

Best regards
Uwe

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

2009/3/25 Uwe Kleine-König <[email protected]>:

Quoted 6 lines · Bert Wesarg
Quoted 1 line

First I think the '#' is a leftover, second this is now a bashism.

according to bash(1):

       If pattern begins with #, it must match at the beginning of the expanded value of parameter.

That is obviously true, I first removed this # and than switch to bash (after it stills failed), so this was just thinking not testing.

Quoted 5 lines

And I noticed, too, that this is a bashism.  Using dash it fails, even with your patch.

I would prefer to really fix it now.

Thanks. I intended this patch as a bug report.

Bert

Quoted 8 lines

Best regards
Uwe

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

#4 lore raw
In reply to Bert Wesarg

Hello,

hooks/pre-commit.sh tg_util · line 23

Quoted 5 lines

if head_=$(git symbolic-ref -q HEAD); then

hooks/pre-commit.sh +1 -1
 	case "$head_" in
 		refs/heads/*)
-			git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
+			git rev-parse -q --verify "${head_/refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
			git rev-parse -q --verify "refs/top-bases${head_#refs/heads}" >/dev/null || exit 0;;

should work.

But I'm too tired to make a patch now. That probably would only result in more crap...

Uwe

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

PATCH 1/1 hooks/pre-commit.sh: fix bashism

In reply to Bert Wesarg

This was introduced in fcb488d51e72c7414f9beb40ad06bf529b8b38dc. A similar fix was suggested by martin f krafft, too.

---
Hello,

this should fix the issue now.

If I don't get negative feed back I will push this change later today. I'm open for acks, too.

Best regards and thanks
Uwe

 hooks/pre-commit.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hooks/pre-commit.sh +1 -1
index a12cfa6..9d677e9 100644
@@ -20,7 +20,7 @@ tg_util
 if head_=$(git symbolic-ref -q HEAD); then
 	case "$head_" in
 		refs/heads/*)
-			git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
+			git rev-parse -q --verify "refs/top-bases${head_#refs/heads}" >/dev/null || exit 0;;
 		*)
 			exit 0;;
 	esac
Signature · 5 lines
1.6.2

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Tested-by on v1 1/1
#6 lore raw

Re: [PATCH TopGit] hooks/pre-commit.sh: fix bashism

Quoted 2 lines · Uwe Kleine-König

This was introduced in fcb488d51e72c7414f9beb40ad06bf529b8b38dc. A similar fix was suggested by martin f krafft, too.

Works here on ubuntu bin /bin/sh is a link to /bin/dash

Quoted 2 lines
Quoted 19 lines

---
Hello,

this should fix the issue now.

If I don't get negative feed back I will push this change later today. I'm open for acks, too.

Best regards and thanks
Uwe

 hooks/pre-commit.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hooks/pre-commit.sh +0 -0
index a12cfa6..9d677e9 100644

hooks/pre-commit.sh tg_util · line 26

Quoted 8 lines
hooks/pre-commit.sh +1 -1
@@ -20,7 +20,7 @@ tg_util
 if head_=$(git symbolic-ref -q HEAD); then
 	case "$head_" in
 		refs/heads/*)
-			git rev-parse -q --verify "${head_/#refs\/heads/refs\/top-bases}" >/dev/null || exit 0;;
+			git rev-parse -q --verify "refs/top-bases${head_#refs/heads}" >/dev/null || exit 0;;
 		*)
 			exit 0;;
 	esac

Marc

Signature · 4 lines
Pengutronix e.K.                         | Marc Kleine-Budde           |
Linux Solutions for Science and Industry | Phone: +49-231-2826-924     |
Vertretung West/Dortmund                 | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686         | http://www.pengutronix.de   |
author Acked-by Tested-by
#7 lore raw

Re: [PATCH TopGit] hooks/pre-commit.sh: fix bashism

2009/3/26 Marc Kleine-Budde <[email protected]>:

Quoted 9 lines
Quoted 2 lines · Uwe Kleine-König

This was introduced in fcb488d51e72c7414f9beb40ad06bf529b8b38dc. A similar fix was suggested by martin f krafft, too.

Works here on ubuntu bin /bin/sh is a link to /bin/dash

Quoted 2 lines

Thanks Uwe.

Bert