Skip to contentSkip to conversation

parse-remote: replace unnecessary sed invocation

PATCH In review Stephen Boyd 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parse-remote: replace unnecessary sed invocation

Just use parameter expansion instead.

---

Cleaning out the attic.

 git-parse-remote.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
git-parse-remote.sh +2 -1
index e7013f7..9168879 100644
@@ -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}
 }
Signature · 1 line
1.7.4.2.422.g537d99
#1 lore raw
Quoted 2 lines

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

                                           ^^^
Signature · 1 line
ms
#2 lore raw
Quoted 3 lines · Michael Schubert
Quoted 2 lines

+       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.

git-parse-remote.sh +1 -1
index 9168879..ea093d2 100644
@@ -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}
 }
#3 lore raw
Quoted 7 lines · Stephen Boyd
Quoted 3 lines · Michael Schubert

Review

Quoted 2 lines
(quoted diff) +2 -0
+       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.

Quoted 16 lines

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

git-parse-remote.sh +1 -1
index 9168879..ea093d2 100644
@@ -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}
 }