All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kate Ebneter <kate@ning.com>
To: "Jeff King" <peff@peff.net>, "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: <git@vger.kernel.org>
Subject: Re: Strange behavior (possible bug) using bash command subsitution with "git branch"
Date: Sun, 08 Nov 2009 15:10:13 -0800	[thread overview]
Message-ID: <C71C8FD5.2243E%kate@ning.com> (raw)
In-Reply-To: <20091108230300.GB17129@coredump.intra.peff.net>

On 11/8/09 3:03 PM, "Jeff King" <peff@peff.net> wrote:

> On Sun, Nov 08, 2009 at 11:49:55PM +0100, Björn Steinbrink wrote:
> 
>>> I ran into a weird situation while working on a script, which is best
>>> described with a little snippet from my gitosis-admin repository:
>>> 
>>>     $ git branch
>>>     * master
>>      ^^^
>> 
>>>     $ branch=$(git branch)
>>>     $ echo $branch
>>>     gitosis.conf keydir master
>> 
>> Your shell expands the *, thus echo sees all the things in the current
>> directory. Use 'echo "$branch"' and you'll see what you expected.
> 
> And more to the point, this is just one reason why one should use
> for-each-ref when scripting (the other is that git-branch's output is
> considered porcelain, and is not guaranteed to remain stable). E.g.:
> 
>   git for-each-ref --format='%(refname:short)' refs/heads/
> 
> would produce the output the original poster wanted.

Ah, sweet, I did not know about that. I ended up doing something entirely
different (short form: my original idea about what I wanted to do was wrong)
but that's very helpful for the future.

Thanks,
Kate Ebneter (who is gradually learning more and more about git)

      reply	other threads:[~2009-11-08 23:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-08 22:11 Strange behavior (possible bug) using bash command subsitution with "git branch" Kate Ebneter
2009-11-08 22:46 ` Sverre Rabbelier
2009-11-08 22:50   ` Kate Ebneter
2009-11-08 22:49 ` Björn Steinbrink
2009-11-08 23:03   ` Jeff King
2009-11-08 23:10     ` Kate Ebneter [this message]

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=C71C8FD5.2243E%kate@ning.com \
    --to=kate@ning.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.