Skip to content

Commit 2f459b0

Browse files
felipecgitster
authored andcommitted
completion: zsh: simplify compadd functions
We don't need to override IFS, zsh has a native way of splitting by new lines: the expansion flag (f). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 94b2901 commit 2f459b0

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

contrib/completion/git-completion.zsh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ __gitcomp_direct ()
100100
{
101101
emulate -L zsh
102102

103-
local IFS=$'\n'
104103
compset -P '*[=:]'
105-
compadd -Q -- ${${=1}% } && _ret=0
104+
compadd -Q -- ${${(f)1}% } && _ret=0
106105
}
107106

108107
__gitcomp_direct_append ()
@@ -114,34 +113,30 @@ __gitcomp_nl ()
114113
{
115114
emulate -L zsh
116115

117-
local IFS=$'\n'
118116
compset -P '*[=:]'
119-
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
117+
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
120118
}
121119

122120
__gitcomp_nl_append ()
123121
{
124122
emulate -L zsh
125123

126-
local IFS=$'\n'
127124
compset -P '*[=:]'
128-
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
125+
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
129126
}
130127

131128
__gitcomp_file_direct ()
132129
{
133130
emulate -L zsh
134131

135-
local IFS=$'\n'
136-
compadd -f -- ${=1} && _ret=0
132+
compadd -f -- ${(f)1} && _ret=0
137133
}
138134

139135
__gitcomp_file ()
140136
{
141137
emulate -L zsh
142138

143-
local IFS=$'\n'
144-
compadd -p "${2-}" -f -- ${=1} && _ret=0
139+
compadd -p "${2-}" -f -- ${(f)1} && _ret=0
145140
}
146141

147142
__git_zsh_bash_func ()

0 commit comments

Comments
 (0)