threads / patch / 26922

patchparse-remote: replace unnecessary sed invocation

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

## tl;dr

4 messages between Mar 30, 2011 and Mar 31, 2011. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Stephen Boyd· Mar 30, 2011, 08:48 UTC · lore
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(-)
Show changes to git-parse-remote.sh +2 −1
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
Stephen Boyd· Mar 31, 2011, 01:02 UTC · re: Michael Schubert · lore

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

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.

Show changes to git-parse-remote.sh +1 −1
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· Mar 31, 2011, 02:31 UTC · re: Stephen Boyd · lore

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

Stephen Boyd <bebarino@gmail.com> writes:
Show 7 quoted lines
> 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.

Show 16 quoted lines
> 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}
>  }

← back to recent threads