Skip to content

git for-each-ref fails in zsh #23

@joews

Description

@joews

Hello,

The execution of for-each-ref fails when the target machine uses zsh (or csh) as its default shell.

deploy.conf

[production]
user joe
host localhost
repo git@github.com:jwhitfieldseed/deploy-test.git
path /tmp/deploy-test/production

Output from deploy where the target machine uses zsh:

~/code/deploy-test develop  
❯ deploy production
  ○ deploying
  ○ hook pre-deploy
  ○ fetching updates
Fetching origin
From github.com:jwhitfieldseed/deploy-test
   c8a0d31..88cb561  master     -> origin/master
   b7a1fb2..f404710  develop    -> origin/develop
 * [new tag]         moose4     -> moose4
From github.com:jwhitfieldseed/deploy-test
 * [new tag]         moose      -> moose
 * [new tag]         moose2     -> moose2
 * [new tag]         moose3     -> moose3
  ○ fetching latest tag
zsh:1: no matches found: --sort=-*authordate
  ○ resetting HEAD to
HEAD is now at c8a0d31 Merge branches 'develop' and 'master' of github.com:jwhitfieldseed/deploy-test
  ○ hook post-deploy
  ○ hook test
  ○ successfully deployed

Output of running that command in isolation on each of the shells on my machine (running Mavericks):

❯ zsh

~/code/deploy-test develop  
❯ git for-each-ref refs/tags \ 
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3
zsh: no matches found: --sort=-*authordate

~/code/deploy-test develop  

❯ bash
joe deploy-test $ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
joe deploy-test $ exit

~/code/deploy-test develop  
❯ sh
sh-3.2$ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
sh-3.2$ exit

~/code/deploy-test develop  
❯ ksh
$ 
me)' \
      --count=1 | cut -d '/' -f 3> 
me)' \
      --count=1 | cut -d '/' -f 3>       --format='%(refna
>       --count=1 | cut -d '/' -f 3
moose4
$ 

~/code/deploy-test develop  
❯ csh
[Joes-MacBook-Pro:~/code/deploy-test] joe% git for-each-ref refs/tags \
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3?       --sort=-*authordate \
?       --format='%(refname)' \
?       --count=1 | cut -d '/' -f 3
git: No match.

I don't know enough about the way each shell escapes newlines to have a quick fix (besides forcing bash on the target machine, which may not be so bad given that the deploy script itself is bash). Does anybody else have one? If not I am happy to look into it for a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions