* _git: Update __git_merge_strategies to work with new git.
@ 2008-08-21 11:43 Mikael Magnusson
2008-08-21 12:29 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-21 11:43 UTC (permalink / raw)
To: zsh-workers
This is the corresponding code from the bundled bash-completion:
git merge -s help 2>&1 |
sed -n -e '/[Aa]vailable strategies are: /,/^$/{
s/\.$//
s/.*://
s/^[ ]*//
s/[ ]*$//
p
}'
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 7e48c19..c799a40 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -4046,7 +4046,7 @@ __git_gpg_secret_keys () {
__git_merge_strategies () {
declare -a merge_strategies_cache
- merge_strategies_cache=(${${=${${(M)${(f)"$(<$(git
--exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'}:#recur})
+ merge_strategies_cache=(${(s: :)${${${${(ps:\n:)"$(git merge -s ''
2>&1)"}[(r)Available strategies are: *,(r)]}%%.}##*: }})
local expl
_wanted merge-strategies expl 'merge strategy' compadd -
$merge_strategies_cache
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-21 11:43 _git: Update __git_merge_strategies to work with new git Mikael Magnusson
@ 2008-08-21 12:29 ` Clint Adams
2008-08-21 20:19 ` Mikael Magnusson
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2008-08-21 12:29 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh-workers
On Thu, Aug 21, 2008 at 01:43:15PM +0200, Mikael Magnusson wrote:
> - merge_strategies_cache=(${${=${${(M)${(f)"$(<$(git
> --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'}:#recur})
> + merge_strategies_cache=(${(s: :)${${${${(ps:\n:)"$(git merge -s ''
> 2>&1)"}[(r)Available strategies are: *,(r)]}%%.}##*: }})
With 1.5.6.3 I get no capital A:
% git merge -s ''
available strategies are: recur recursive octopus resolve stupid ours subtree
Also (ps:\n:) can be written as (f), but is the output ever more than
one line?
See if
merge_strategies_cache=(${=${${"$(git merge -s '' 2>&1)"}#[Aa]vailable strategies are: }})
does the right thing for you.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-21 12:29 ` Clint Adams
@ 2008-08-21 20:19 ` Mikael Magnusson
2008-08-22 10:36 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-21 20:19 UTC (permalink / raw)
To: zsh-workers
2008/8/21 Clint Adams <clint@zsh.org>:
> On Thu, Aug 21, 2008 at 01:43:15PM +0200, Mikael Magnusson wrote:
>> - merge_strategies_cache=(${${=${${(M)${(f)"$(<$(git
>> --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'}:#recur})
>> + merge_strategies_cache=(${(s: :)${${${${(ps:\n:)"$(git merge -s ''
>> 2>&1)"}[(r)Available strategies are: *,(r)]}%%.}##*: }})
>
> With 1.5.6.3 I get no capital A:
Ah, I knew i forgot something. It changed a bit in 1.6.0. The a -> A and
the trailing dot after the strategies.
> % git merge -s ''
> available strategies are: recur recursive octopus resolve stupid ours subtree
>
> Also (ps:\n:) can be written as (f), but is the output ever more than
> one line?
Yes, touch /usr/local/bin/git-merge-clint and +x it:
% git merge -s ''
Could not find merge strategy ''.
Available strategies are: file octopus ours recursive resolve subtree.
Available custom strategies are: mikachu.
%
It is also "future-proofed" against something like this, same as the sed
script:
% git merge -s ''
Could not find merge strategy ''.
Available strategies are: file octopus ours recursive resolve subtree.
Available custom strategies are: mikachu.
Make sure you spell strategy names correctly.
%
> See if
>
> merge_strategies_cache=(${=${${"$(git merge -s '' 2>&1)"}#[Aa]vailable strategies are: }})
>
> does the right thing for you.
So it should be
merge_strategies_cache=(${(s: :)${${${${(f)"$(git merge -s ''
2>&1)"}[(r)[Aa]vailable strategies are: *,(r)]}%%.}##*: }})
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-21 20:19 ` Mikael Magnusson
@ 2008-08-22 10:36 ` Clint Adams
2008-08-22 15:41 ` Mikael Magnusson
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2008-08-22 10:36 UTC (permalink / raw)
To: zsh-workers
On Thu, Aug 21, 2008 at 10:19:18PM +0200, Mikael Magnusson wrote:
> Yes, touch /usr/local/bin/git-merge-clint and +x it:
> % git merge -s ''
> Could not find merge strategy ''.
> Available strategies are: file octopus ours recursive resolve subtree.
> Available custom strategies are: mikachu.
Doesn't do anything with my version.
> So it should be
> merge_strategies_cache=(${(s: :)${${${${(f)"$(git merge -s ''
> 2>&1)"}[(r)[Aa]vailable strategies are: *,(r)]}%%.}##*: }})
Gives me a blank array.
Maybe this:
${(s: :)${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable strategies are: *}#[Aa]vailable strategies are: }%.}
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-22 10:36 ` Clint Adams
@ 2008-08-22 15:41 ` Mikael Magnusson
2008-08-24 16:36 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-22 15:41 UTC (permalink / raw)
To: zsh-workers
2008/8/22 Clint Adams <clint@zsh.org>:
> On Thu, Aug 21, 2008 at 10:19:18PM +0200, Mikael Magnusson wrote:
>> Yes, touch /usr/local/bin/git-merge-clint and +x it:
>> % git merge -s ''
>> Could not find merge strategy ''.
>> Available strategies are: file octopus ours recursive resolve subtree.
>> Available custom strategies are: mikachu.
>
> Doesn't do anything with my version.
>
>> So it should be
>> merge_strategies_cache=(${(s: :)${${${${(f)"$(git merge -s ''
>> 2>&1)"}[(r)[Aa]vailable strategies are: *,(r)]}%%.}##*: }})
>
> Gives me a blank array.
>
> Maybe this:
>
> ${(s: :)${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable strategies are: *}#[Aa]vailable strategies are: }%.}
That doesn't grab the custom strategies line... How about this? Sort
of a hack though... :)
${(s: :)${${${${(f)"$(echo; git merge -s '' 2>&1)"}[(r)[Aa]vailable
strategies are: *,(r)]}%%.}##*: }}
::Some minutes later::
Aha, my first version didn't work for you because it's only one line, so the
(f) doesn't give you an array:
% echo ${${(f)"$(echo available strategies are: recur recursive
octopus resolve stupid ours subtree)"}[(r)[Aa]vailable strategies are:
*]}
a
I've no idea if you can force an array in a better way than with the echo
though.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-22 15:41 ` Mikael Magnusson
@ 2008-08-24 16:36 ` Clint Adams
2008-08-24 18:40 ` Mikael Magnusson
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2008-08-24 16:36 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh-workers
On Fri, Aug 22, 2008 at 05:41:39PM +0200, Mikael Magnusson wrote:
> That doesn't grab the custom strategies line... How about this? Sort
> of a hack though... :)
>
> ${(s: :)${${${${(f)"$(echo; git merge -s '' 2>&1)"}[(r)[Aa]vailable
> strategies are: *,(r)]}%%.}##*: }}
${=${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 16:36 ` Clint Adams
@ 2008-08-24 18:40 ` Mikael Magnusson
2008-08-24 19:12 ` Clint Adams
0 siblings, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-24 18:40 UTC (permalink / raw)
To: zsh-workers
2008/8/24 Clint Adams <clint@zsh.org>:
> On Fri, Aug 22, 2008 at 05:41:39PM +0200, Mikael Magnusson wrote:
>> That doesn't grab the custom strategies line... How about this? Sort
>> of a hack though... :)
>>
>> ${(s: :)${${${${(f)"$(echo; git merge -s '' 2>&1)"}[(r)[Aa]vailable
>> strategies are: *,(r)]}%%.}##*: }}
>
> ${=${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}
That works for me too.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 18:40 ` Mikael Magnusson
@ 2008-08-24 19:12 ` Clint Adams
2008-08-24 19:16 ` Mikael Magnusson
2008-08-24 23:37 ` Nikolai Weibull
0 siblings, 2 replies; 12+ messages in thread
From: Clint Adams @ 2008-08-24 19:12 UTC (permalink / raw)
To: zsh-workers
On Sun, Aug 24, 2008 at 08:40:46PM +0200, Mikael Magnusson wrote:
> > ${=${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}
>
> That works for me too.
Do we know why the current function excludes "recur"? Should that be
retained?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 19:12 ` Clint Adams
@ 2008-08-24 19:16 ` Mikael Magnusson
2008-08-24 19:42 ` Clint Adams
2008-08-24 23:37 ` Nikolai Weibull
1 sibling, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-24 19:16 UTC (permalink / raw)
To: zsh-workers
2008/8/24 Clint Adams <clint@zsh.org>:
> On Sun, Aug 24, 2008 at 08:40:46PM +0200, Mikael Magnusson wrote:
>> > ${=${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}
>>
>> That works for me too.
>
> Do we know why the current function excludes "recur"? Should that be
> retained?
The git-bundled bash completion doesn't exclude it at any rate.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 19:16 ` Mikael Magnusson
@ 2008-08-24 19:42 ` Clint Adams
2008-08-24 19:52 ` Mikael Magnusson
0 siblings, 1 reply; 12+ messages in thread
From: Clint Adams @ 2008-08-24 19:42 UTC (permalink / raw)
To: zsh-workers
On Sun, Aug 24, 2008 at 09:16:13PM +0200, Mikael Magnusson wrote:
> The git-bundled bash completion doesn't exclude it at any rate.
The other issue is that the git merge -s '' trick doesn't work outside
of git directories.
So maybe this is the way to go.
Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.88
diff -u -r1.88 _git
--- Completion/Unix/Command/_git 21 Aug 2008 12:25:26 -0000 1.88
+++ Completion/Unix/Command/_git 24 Aug 2008 19:40:39 -0000
@@ -4039,12 +4039,14 @@
(( $+functions[__git_merge_strategies] )) ||
__git_merge_strategies () {
- declare -a merge_strategies_cache
+ local expl
+ local -a merge_strategies
- merge_strategies_cache=(${${=${${(M)${(f)"$(<$(git --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'}:#recur})
+ if ! merge_strategies=(${=${${(M)${(f)"$(_call_program strategies git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}); then
+ merge_strategies=(${=${${(M)${(f)"$(<$(git --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'})
+ fi
- local expl
- _wanted merge-strategies expl 'merge strategy' compadd - $merge_strategies_cache
+ _wanted merge-strategies expl 'merge strategy' compadd -a merge_strategies "$@"
}
# TODO: Use this in more places.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 19:42 ` Clint Adams
@ 2008-08-24 19:52 ` Mikael Magnusson
0 siblings, 0 replies; 12+ messages in thread
From: Mikael Magnusson @ 2008-08-24 19:52 UTC (permalink / raw)
To: zsh-workers
2008/8/24 Clint Adams <clint@zsh.org>:
> On Sun, Aug 24, 2008 at 09:16:13PM +0200, Mikael Magnusson wrote:
>> The git-bundled bash completion doesn't exclude it at any rate.
>
> The other issue is that the git merge -s '' trick doesn't work outside
> of git directories.
>
> So maybe this is the way to go.
>
> Index: Completion/Unix/Command/_git
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
> retrieving revision 1.88
> diff -u -r1.88 _git
> --- Completion/Unix/Command/_git 21 Aug 2008 12:25:26 -0000 1.88
> +++ Completion/Unix/Command/_git 24 Aug 2008 19:40:39 -0000
> @@ -4039,12 +4039,14 @@
>
> (( $+functions[__git_merge_strategies] )) ||
> __git_merge_strategies () {
> - declare -a merge_strategies_cache
> + local expl
> + local -a merge_strategies
>
> - merge_strategies_cache=(${${=${${(M)${(f)"$(<$(git --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'}:#recur})
> + if ! merge_strategies=(${=${${(M)${(f)"$(_call_program strategies git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}); then
> + merge_strategies=(${=${${(M)${(f)"$(<$(git --exec-path)/git-merge)"}:#all_strategies*}##all_strategies=\'}%%\'})
> + fi
>
> - local expl
> - _wanted merge-strategies expl 'merge strategy' compadd - $merge_strategies_cache
> + _wanted merge-strategies expl 'merge strategy' compadd -a merge_strategies "$@"
> }
>
> # TODO: Use this in more places.
git-merge is a binary in newer versions of git.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: _git: Update __git_merge_strategies to work with new git.
2008-08-24 19:12 ` Clint Adams
2008-08-24 19:16 ` Mikael Magnusson
@ 2008-08-24 23:37 ` Nikolai Weibull
1 sibling, 0 replies; 12+ messages in thread
From: Nikolai Weibull @ 2008-08-24 23:37 UTC (permalink / raw)
To: zsh-workers
On Sun, Aug 24, 2008 at 21:12, Clint Adams <clint@zsh.org> wrote:
> On Sun, Aug 24, 2008 at 08:40:46PM +0200, Mikael Magnusson wrote:
>> > ${=${${(M)${(f)"$(git merge -s '' 2>&1)"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}
>> That works for me too.
> Do we know why the current function excludes "recur"? Should that be
> retained?
There must have been a reason, but I can't remember why I excluded it.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-08-24 23:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 11:43 _git: Update __git_merge_strategies to work with new git Mikael Magnusson
2008-08-21 12:29 ` Clint Adams
2008-08-21 20:19 ` Mikael Magnusson
2008-08-22 10:36 ` Clint Adams
2008-08-22 15:41 ` Mikael Magnusson
2008-08-24 16:36 ` Clint Adams
2008-08-24 18:40 ` Mikael Magnusson
2008-08-24 19:12 ` Clint Adams
2008-08-24 19:16 ` Mikael Magnusson
2008-08-24 19:42 ` Clint Adams
2008-08-24 19:52 ` Mikael Magnusson
2008-08-24 23:37 ` Nikolai Weibull
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).