* [PATCH] pull: replace unnecessary sed invocation
@ 2010-03-18 5:10 Stephen Boyd
2010-03-18 13:30 ` Gabriel Filion
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2010-03-18 5:10 UTC (permalink / raw)
To: git, git; +Cc: Junio C Hamano
Getting the shortened branch name is as easy as using the shell's
parameter expansion.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Saw this while reading the code.
git-pull.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 38331a8..246a3a4 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -41,7 +41,7 @@ strategy_args= diffstat= no_commit= squash= no_ff= ff_only=
log_arg= verbosity=
merge_args=
curr_branch=$(git symbolic-ref -q HEAD)
-curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
+curr_branch_short="${curr_branch#refs/heads/}"
rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
--
1.7.0.2.276.g60daf
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: replace unnecessary sed invocation
2010-03-18 5:10 [PATCH] pull: replace unnecessary sed invocation Stephen Boyd
@ 2010-03-18 13:30 ` Gabriel Filion
2010-03-18 14:46 ` Brandon Casey
2010-03-18 14:48 ` Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: Gabriel Filion @ 2010-03-18 13:30 UTC (permalink / raw)
To: Stephen Boyd; +Cc: git, Junio C Hamano
On 2010-03-18 01:10, Stephen Boyd wrote:
> Getting the shortened branch name is as easy as using the shell's
> parameter expansion.
>
> curr_branch=$(git symbolic-ref -q HEAD)
> -curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
> +curr_branch_short="${curr_branch#refs/heads/}"
This modification is a bashism. This syntax is not compatible with other
shells.
--
Gabriel Filion
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: replace unnecessary sed invocation
2010-03-18 13:30 ` Gabriel Filion
@ 2010-03-18 14:46 ` Brandon Casey
2010-03-18 14:48 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Brandon Casey @ 2010-03-18 14:46 UTC (permalink / raw)
To: Gabriel Filion; +Cc: Stephen Boyd, git, Junio C Hamano
On 03/18/2010 08:30 AM, Gabriel Filion wrote:
> On 2010-03-18 01:10, Stephen Boyd wrote:
>> Getting the shortened branch name is as easy as using the shell's
>> parameter expansion.
>>
>> curr_branch=$(git symbolic-ref -q HEAD)
>> -curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
>> +curr_branch_short="${curr_branch#refs/heads/}"
>
> This modification is a bashism. This syntax is not compatible with other
> shells.
But, there is already precedence for using syntax in scripts, so it
is probably ok.
$ egrep -- '\$\{[^}]+#[^}]+\}' *.sh
git-bisect.sh: start_head="${head#refs/heads/}"
git-filter-branch.sh: ref="${ref#refs/tags/}"
git-parse-remote.sh: heads/*) remote=${remote#heads/} ;;
git-parse-remote.sh: refs/heads/*) remote=${remote#refs/heads/} ;;
git-pull.sh: curr_branch=${curr_branch#refs/heads/}
git-pull.sh: echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
git-rebase--interactive.sh: pend="${pend# $p}"
git-rebase--interactive.sh: new_parents=${new_parents# $first_parent}
git-rebase--interactive.sh: if left=${1%...*} right=${1#*...} &&
git-rebase.sh: eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
git-rebase.sh: if left=${onto_name%...*} right=${onto_name#*...} &&
git-stash.sh: branch=${branch#refs/heads/}
git-submodule.sh: url="${url#../}"
git-submodule.sh: url="${url#./}"
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pull: replace unnecessary sed invocation
2010-03-18 13:30 ` Gabriel Filion
2010-03-18 14:46 ` Brandon Casey
@ 2010-03-18 14:48 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2010-03-18 14:48 UTC (permalink / raw)
To: Gabriel Filion; +Cc: Stephen Boyd, git
Gabriel Filion <lelutin@gmail.com> writes:
>> +curr_branch_short="${curr_branch#refs/heads/}"
>
> This modification is a bashism. This syntax is not compatible with other
> shells.
To me, the above looks like "${parameter#word}", which is a plain vanilla
POSIX shell construct that we adopted to use in our scripts.
There are bash-only constructs we decided never to use in our scripts;
among them are "${parameter/pattern/string}" and "${parameter:offset}",
both are not in POSIX.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-18 14:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-18 5:10 [PATCH] pull: replace unnecessary sed invocation Stephen Boyd
2010-03-18 13:30 ` Gabriel Filion
2010-03-18 14:46 ` Brandon Casey
2010-03-18 14:48 ` Junio C Hamano
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).