# [PATCH] parse-remote: replace unnecessary sed invocation

4 messages from 2011-03-30 to 2011-03-31. Participants: Stephen Boyd, Michael Schubert, Junio C Hamano.
Thread: https://gitlist.dev/t/26922

## Stephen Boyd, 2011-03-30 08:48

Subject: [PATCH] parse-remote: replace unnecessary sed invocation
Message-ID: <1301474920-6718-1-git-send-email-bebarino@gmail.com>
URL: https://gitlist.dev/e/1301474920-6718-1-git-send-email-bebarino%40gmail.com

```
Just use parameter expansion instead.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

Cleaning out the attic.

 git-parse-remote.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index e7013f7..9168879 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -5,7 +5,8 @@
 GIT_DIR=$(git rev-parse -q --git-dir) || :;
 
 get_default_remote () {
-	curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
+	curr_branch=$(git symbolic-ref -q HEAD)
+	curr_branch="${cur_branch#refs/heads/}"
 	origin=$(git config --get "branch.$curr_branch.remote")
 	echo ${origin:-origin}
 }
-- 
1.7.4.2.422.g537d99

```

## Michael Schubert, 2011-03-30 18:31

Subject: Re: [PATCH] parse-remote: replace unnecessary sed invocation
Message-ID: <AANLkTikBD4T3hdyT2h=2dzw-QO1BnBp3eT=WGj5s5dC3@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikBD4T3hdyT2h%3D2dzw-QO1BnBp3eT%3DWGj5s5dC3%40mail.gmail.com
In-Reply-To: <1301474920-6718-1-git-send-email-bebarino@gmail.com>

```
> +       curr_branch=$(git symbolic-ref -q HEAD)
> +       curr_branch="${cur_branch#refs/heads/}"
                                           ^^^



-- 
ms

```

## Stephen Boyd, 2011-03-31 01:02

Subject: Re: [PATCH] parse-remote: replace unnecessary sed invocation
Message-ID: <AANLkTin3R8ApTZ97Cw67dN7_s_ycX8sQThypMq2N6eJi@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin3R8ApTZ97Cw67dN7_s_ycX8sQThypMq2N6eJi%40mail.gmail.com
In-Reply-To: <AANLkTikBD4T3hdyT2h=2dzw-QO1BnBp3eT=WGj5s5dC3@mail.gmail.com>

```
On Wed, Mar 30, 2011 at 11:31 AM, Michael Schubert <mschub@elegosoft.com> wrote:
>> +       curr_branch=$(git symbolic-ref -q HEAD)
>> +       curr_branch="${cur_branch#refs/heads/}"
>                                           ^^^

Ah! How did this pass the test suite... Anyway, looks like Junio
applied this patch to maint already :-( Sorry.

Junio, please apply this (probably word wrapped since this is gmail
interface) and drop your trust level of me by a few points.

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 9168879..ea093d2 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -6,7 +6,7 @@ GIT_DIR=$(git rev-parse -q --git-dir) || :;

 get_default_remote () {
        curr_branch=$(git symbolic-ref -q HEAD)
-       curr_branch="${cur_branch#refs/heads/}"
+       curr_branch="${curr_branch#refs/heads/}"
        origin=$(git config --get "branch.$curr_branch.remote")
        echo ${origin:-origin}
 }

```

## Junio C Hamano, 2011-03-31 02:31

Subject: Re: [PATCH] parse-remote: replace unnecessary sed invocation
Message-ID: <7vlizwkokr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vlizwkokr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTin3R8ApTZ97Cw67dN7_s_ycX8sQThypMq2N6eJi@mail.gmail.com>

```
Stephen Boyd <bebarino@gmail.com> writes:

> On Wed, Mar 30, 2011 at 11:31 AM, Michael Schubert <mschub@elegosoft.com> wrote:
>>> +       curr_branch=$(git symbolic-ref -q HEAD)
>>> +       curr_branch="${cur_branch#refs/heads/}"
>>                                           ^^^
>
> Ah! How did this pass the test suite... Anyway, looks like Junio
> applied this patch to maint already :-( Sorry.

Heh, I was wondering what those three carets under ads in "#refs/heads/"
was pointing at, and didn't see you had only one R in the variable name.

Thanks for a correction, and Michael, please be a bit more specific (and
point the correct part with your carret) when you send your messages.

> Junio, please apply this (probably word wrapped since this is gmail
> interface) and drop your trust level of me by a few points.
>
> diff --git a/git-parse-remote.sh b/git-parse-remote.sh
> index 9168879..ea093d2 100644
> --- a/git-parse-remote.sh
> +++ b/git-parse-remote.sh
> @@ -6,7 +6,7 @@ GIT_DIR=$(git rev-parse -q --git-dir) || :;
>
>  get_default_remote () {
>         curr_branch=$(git symbolic-ref -q HEAD)
> -       curr_branch="${cur_branch#refs/heads/}"
> +       curr_branch="${curr_branch#refs/heads/}"
>         origin=$(git config --get "branch.$curr_branch.remote")
>         echo ${origin:-origin}
>  }

```
