{"thread":{"id":"23061","subject":"Re: [PATCH] pull: replace unnecessary sed invocation","startedAt":"2010-03-18T05:10:45Z","lastAt":"2010-03-18T14:48:39Z","messageCount":4,"participants":["Gabriel Filion","Brandon Casey","Junio C Hamano","Stephen Boyd"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"299175","messageId":"1268889045-21751-1-git-send-email-bebarino@gmail.com","threadId":"23061","inReplyTo":null,"subject":"[PATCH] pull: replace unnecessary sed invocation","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2010-03-18T05:10:45Z","receivedAt":"2010-03-18T05:10:45Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Getting the shortened branch name is as easy as using the shell's\nparameter expansion.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nSaw this while reading the code.\n\n git-pull.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 38331a8..246a3a4 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -41,7 +41,7 @@ strategy_args= diffstat= no_commit= squash= no_ff= ff_only=\n log_arg= verbosity=\n merge_args=\n curr_branch=$(git symbolic-ref -q HEAD)\n-curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n+curr_branch_short=\"${curr_branch#refs/heads/}\"\n rebase=$(git config --bool branch.$curr_branch_short.rebase)\n while :\n do\n-- \n1.7.0.2.276.g60daf\n\n"},{"id":"137090","messageId":"4BA22AEE.8000606@gmail.com","threadId":"23061","inReplyTo":"1268889045-21751-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH] pull: replace unnecessary sed invocation","fromName":"Gabriel Filion","fromEmail":"lelutin@gmail.com","sentAt":"2010-03-18T13:30:22Z","receivedAt":"2010-03-18T13:30:22Z","isPatch":true,"sender":{"key":"lelutin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/108728?v=4"},"body":"On 2010-03-18 01:10, Stephen Boyd wrote:\n> Getting the shortened branch name is as easy as using the shell's\n> parameter expansion.\n> \n>  curr_branch=$(git symbolic-ref -q HEAD)\n> -curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n> +curr_branch_short=\"${curr_branch#refs/heads/}\"\n\nThis modification is a bashism. This syntax is not compatible with other\nshells.\n\n-- \nGabriel Filion\n"},{"id":"137093","messageId":"5rEymC6ZWmCbugaX54NzNsnDmRUKU5-au3DQ0l_p5YIjUz7xRlUzXA@cipher.nrlssc.navy.mil","threadId":"23061","inReplyTo":"4BA22AEE.8000606@gmail.com","subject":"Re: [PATCH] pull: replace unnecessary sed invocation","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2010-03-18T14:46:39Z","receivedAt":"2010-03-18T14:46:39Z","isPatch":true,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 03/18/2010 08:30 AM, Gabriel Filion wrote:\n> On 2010-03-18 01:10, Stephen Boyd wrote:\n>> Getting the shortened branch name is as easy as using the shell's\n>> parameter expansion.\n>>\n>>  curr_branch=$(git symbolic-ref -q HEAD)\n>> -curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n>> +curr_branch_short=\"${curr_branch#refs/heads/}\"\n> \n> This modification is a bashism. This syntax is not compatible with other\n> shells.\n\nBut, there is already precedence for using syntax in scripts, so it\nis probably ok.\n\n$ egrep -- '\\$\\{[^}]+#[^}]+\\}' *.sh\ngit-bisect.sh:                  start_head=\"${head#refs/heads/}\"\ngit-filter-branch.sh:           ref=\"${ref#refs/tags/}\"\ngit-parse-remote.sh:        heads/*) remote=${remote#heads/} ;;\ngit-parse-remote.sh:        refs/heads/*) remote=${remote#refs/heads/} ;;\ngit-pull.sh:    curr_branch=${curr_branch#refs/heads/}\ngit-pull.sh:            echo \"Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'\"\ngit-rebase--interactive.sh:             pend=\"${pend# $p}\"\ngit-rebase--interactive.sh:                     new_parents=${new_parents# $first_parent}\ngit-rebase--interactive.sh:             if      left=${1%...*} right=${1#*...} &&\ngit-rebase.sh:  eval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\ngit-rebase.sh:  if      left=${onto_name%...*} right=${onto_name#*...} &&\ngit-stash.sh:           branch=${branch#refs/heads/}\ngit-submodule.sh:                       url=\"${url#../}\"\ngit-submodule.sh:                       url=\"${url#./}\"\n"},{"id":"137094","messageId":"7vwrx9vg6w.fsf@alter.siamese.dyndns.org","threadId":"23061","inReplyTo":"4BA22AEE.8000606@gmail.com","subject":"Re: [PATCH] pull: replace unnecessary sed invocation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-03-18T14:48:39Z","receivedAt":"2010-03-18T14:48:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gabriel Filion <lelutin@gmail.com> writes:\n\n>> +curr_branch_short=\"${curr_branch#refs/heads/}\"\n>\n> This modification is a bashism. This syntax is not compatible with other\n> shells.\n\nTo me, the above looks like \"${parameter#word}\", which is a plain vanilla\nPOSIX shell construct that we adopted to use in our scripts.\n\nThere are bash-only constructs we decided never to use in our scripts;\namong them are \"${parameter/pattern/string}\" and \"${parameter:offset}\",\nboth are not in POSIX.\n"}]}