From: Pavel Roskin <proski@gnu.org>
To: Petr Baudis <pasky@ucw.cz>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH] gittrack.sh accepts invalid branch names
Date: Wed, 20 Apr 2005 21:28:51 -0400 [thread overview]
Message-ID: <1114046931.20044.11.camel@dv> (raw)
In-Reply-To: <20050420232110.GA12962@pasky.ji.cz>
Hi, Petr!
On Thu, 2005-04-21 at 01:21 +0200, Petr Baudis wrote:
> Dear diary, on Wed, Apr 20, 2005 at 09:48:30PM CEST, I got a letter
> where Pavel Roskin <proski@gnu.org> told me that...
> > --- a/gittrack.sh
> > +++ b/gittrack.sh
> > @@ -35,7 +35,7 @@ die () {
> > mkdir -p .git/heads
> >
> > if [ "$name" ]; then
> > - grep -q $(echo -e "^$name\t" | sed 's/\./\\./g') .git/remotes || \
> > + sed -ne "/^$name\t/p" .git/remotes | grep -q . || \
> > [ -s ".git/heads/$name" ] || \
> > die "unknown branch \"$name\""
>
> This fixes the acceptance, but not the choice.
>
> What does the grep -q . exactly do? Just sets error code based on
> whether the sed output is non-empty?
Yes.
> What about [] instead?
You'll need another pair of quotes for that:
[ "$(sed -ne "/^$name\t/p" .git/remotes)" ]; echo $?
If I remember correctly from my Autoconf hacking experience, not all
shells like mixing quotes and command substitution, and even bash
treated this differently in different versions. I can do more research,
but it seems just too fragile to me.
Another thing I remember is that "case" would not need quotes. For some
historic reasons, the expression between "case" and "in" is subjected to
command substitution, but not word expansion.
So the patch becomes:
--- a/gittrack.sh
+++ b/gittrack.sh
@@ -35,9 +35,11 @@ die () {
mkdir -p .git/heads
if [ "$name" ]; then
- grep -q $(echo -e "^$name\t" | sed 's/\./\\./g') .git/remotes || \
+ case x$(sed -ne "/^$name\t/p" .git/remotes) in
+ x)
[ -s ".git/heads/$name" ] || \
- die "unknown branch \"$name\""
+ die "unknown branch \"$name\"" ;;
+ esac
echo $name >.git/tracking
Looks rather ugly for my taste, but just in case:
Signed-off-by: Pavel Roskin <proski@gnu.org>
By the way, please check all references to .git/remotes - this bug is
not specific to gittrack.sh.
--
Regards,
Pavel Roskin
next prev parent reply other threads:[~2005-04-21 1:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-20 19:48 [PATCH] gittrack.sh accepts invalid branch names Pavel Roskin
2005-04-20 23:21 ` Petr Baudis
2005-04-21 1:28 ` Pavel Roskin [this message]
2005-04-20 23:22 ` Paul Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1114046931.20044.11.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).