zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 0/4] A few patches to _git
@ 2016-03-13 22:01 m0viefreak
  2016-03-13 22:01 ` [PATCH 1/4] _git: reflog: complete references next to commands m0viefreak
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: m0viefreak @ 2016-03-13 22:01 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

m0viefreak (4):
  _git: reflog: complete references next to commands
  _git: fix tag name of remote branches
  _git: log: ignore numeric options
  completion: _git: diff: add --no-index

 Completion/Unix/Command/_git | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

-- 
2.5.0.234.gefc8a62


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] _git: reflog: complete references next to commands
  2016-03-13 22:01 [PATCH 0/4] A few patches to _git m0viefreak
@ 2016-03-13 22:01 ` m0viefreak
  2016-03-15  0:08   ` Daniel Shahaf
  2016-03-13 22:01 ` [PATCH 2/4] _git: fix tag name of remote branches m0viefreak
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: m0viefreak @ 2016-03-13 22:01 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

'git reflog show' is the default subcommand, so

  git reflog <tab>

should complete subcommands and references.
---
 Completion/Unix/Command/_git | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index e3d7231..ea2d485 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -3069,7 +3069,9 @@ _git-reflog () {
           'delete:delete entries from reflog'
           'show:show log of ref')
 
-        _describe -t commands command commands && ret=0
+        _alternative \
+          'commands:: _describe -t commands command commands' \
+          'references:: __git_references' && ret=0
         ;;
       (option-or-argument)
         curcontext=${curcontext%:*}-$line[1]:
-- 
2.5.0.234.gefc8a62


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/4] _git: fix tag name of remote branches
  2016-03-13 22:01 [PATCH 0/4] A few patches to _git m0viefreak
  2016-03-13 22:01 ` [PATCH 1/4] _git: reflog: complete references next to commands m0viefreak
@ 2016-03-13 22:01 ` m0viefreak
  2016-03-15  0:08   ` Daniel Shahaf
  2016-03-13 22:01 ` [PATCH 3/4] _git: log: ignore numeric options m0viefreak
  2016-03-13 22:02 ` [PATCH 4/4] completion: _git: diff: add --no-index m0viefreak
  3 siblings, 1 reply; 11+ messages in thread
From: m0viefreak @ 2016-03-13 22:01 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

---
 Completion/Unix/Command/_git | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index ea2d485..1241058 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -457,7 +457,7 @@ _git-checkout () {
       if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then
         # TODO: Allow A...B
         local branch_arg='' \
-              remote_branch_noprefix_arg='remote branches::__git_remote_branch_names_noprefix' \
+              remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \
               tree_ish_arg='tree-ishs::__git_tree_ishs' \
               file_arg='modified-files::__git_modified_files'
 
-- 
2.5.0.234.gefc8a62


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/4] _git: log: ignore numeric options
  2016-03-13 22:01 [PATCH 0/4] A few patches to _git m0viefreak
  2016-03-13 22:01 ` [PATCH 1/4] _git: reflog: complete references next to commands m0viefreak
  2016-03-13 22:01 ` [PATCH 2/4] _git: fix tag name of remote branches m0viefreak
@ 2016-03-13 22:01 ` m0viefreak
  2016-03-15  0:08   ` Daniel Shahaf
  2016-03-13 22:02 ` [PATCH 4/4] completion: _git: diff: add --no-index m0viefreak
  3 siblings, 1 reply; 11+ messages in thread
From: m0viefreak @ 2016-03-13 22:01 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

git log allows -<number> arguments as a synonym for -n <number>,
This however broke completion of further option arguments.

Simply ignore all numeric options to make it work.
---
 Completion/Unix/Command/_git | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 1241058..023740e 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1087,7 +1087,7 @@ _git-log () {
   __git_setup_log_options
   __git_setup_revision_options
 
-  _arguments -w -C -s \
+  _arguments -w -C -s -A "-[0-9]#" \
     $log_options \
     $revision_options \
     '-L+[trace the evolution of a line range or regex within a file]:range' \
-- 
2.5.0.234.gefc8a62


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/4] completion: _git: diff: add --no-index
  2016-03-13 22:01 [PATCH 0/4] A few patches to _git m0viefreak
                   ` (2 preceding siblings ...)
  2016-03-13 22:01 ` [PATCH 3/4] _git: log: ignore numeric options m0viefreak
@ 2016-03-13 22:02 ` m0viefreak
  3 siblings, 0 replies; 11+ messages in thread
From: m0viefreak @ 2016-03-13 22:02 UTC (permalink / raw)
  To: zsh-workers; +Cc: m0viefreak

---
 Completion/Unix/Command/_git | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 023740e..c989a2c 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -725,12 +725,28 @@ _git-diff () {
     $* \
     $diff_options \
     $diff_stage_options \
-    '(--cached --staged)'{--cached,--staged}'[show diff between index and named commit]' \
+    '(--no-index --cached --staged)--no-index[diff files outside of git repo]' \
+    '(--no-index --cached --staged)'{--cached,--staged}'[show diff between index and named commit]' \
     '(-)--[start file arguments]' \
     '*:: :->from-to-file' && ret=0
 
   case $state in
     (from-to-file)
+      # If "--no-index" was given simply complete arbitrary files
+      if (( opt_args[(I)--no-index] )); then
+        local expl descr
+        if (( CURRENT == 1 )); then
+          descr="original file"
+        elif (( CURRENT == 2 )); then
+          descr="new file"
+        else
+          return ret
+        fi
+        _description all-files expl "$descr"
+        _files "$expl[@]"
+        return
+      fi
+
       # If "--" is part of $opt_args, this means it was specified before any
       # $words arguments. This means that no heads are specified in front, so
       # we need to complete *changed* files only.
-- 
2.5.0.234.gefc8a62


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] _git: reflog: complete references next to commands
  2016-03-13 22:01 ` [PATCH 1/4] _git: reflog: complete references next to commands m0viefreak
@ 2016-03-15  0:08   ` Daniel Shahaf
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Shahaf @ 2016-03-15  0:08 UTC (permalink / raw)
  To: m0viefreak; +Cc: zsh-workers

m0viefreak wrote on Sun, Mar 13, 2016 at 23:01:57 +0100:
> 'git reflog show' is the default subcommand, so
> 
>   git reflog <tab>
> 
> should complete subcommands and references.

Thanks, applied.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] _git: fix tag name of remote branches
  2016-03-13 22:01 ` [PATCH 2/4] _git: fix tag name of remote branches m0viefreak
@ 2016-03-15  0:08   ` Daniel Shahaf
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Shahaf @ 2016-03-15  0:08 UTC (permalink / raw)
  To: m0viefreak; +Cc: zsh-workers

m0viefreak wrote on Sun, Mar 13, 2016 at 23:01:58 +0100:
> -              remote_branch_noprefix_arg='remote branches::__git_remote_branch_names_noprefix' \
> +              remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \

Thanks, applied.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] _git: log: ignore numeric options
  2016-03-13 22:01 ` [PATCH 3/4] _git: log: ignore numeric options m0viefreak
@ 2016-03-15  0:08   ` Daniel Shahaf
  2016-03-16 20:43     ` m0viefreak
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Shahaf @ 2016-03-15  0:08 UTC (permalink / raw)
  To: m0viefreak; +Cc: zsh-workers

m0viefreak wrote on Sun, Mar 13, 2016 at 23:01:59 +0100:
> git log allows -<number> arguments as a synonym for -n <number>,
> This however broke completion of further option arguments.
> 

m0viefreak reported on IRC the breakage does not occur since
workers/36236 (a4c41fff1261), but suggested the patch was still needed
to avoid numeric options being parsed by _git-log as the first
positional argument.

I couldn't reproduce that: with current master, none of «git log
-<TAB>», «git log -9<TAB>», or «git log -9 -<TAB>» go through the
'first-commit-ranges-or-files' code branch.

m0viefreak, if there is still a (possibly latent) bug in current master,
could you please explain/show it?

Thanks,

Daniel

P.S. The two case branches should probably be combined now: 36236 made
them very similar.

> Simply ignore all numeric options to make it work.
> ---
>  Completion/Unix/Command/_git | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index 1241058..023740e 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -1087,7 +1087,7 @@ _git-log () {
>    __git_setup_log_options
>    __git_setup_revision_options
>  
> -  _arguments -w -C -s \
> +  _arguments -w -C -s -A "-[0-9]#" \
>      $log_options \
>      $revision_options \
>      '-L+[trace the evolution of a line range or regex within a file]:range' \
> -- 
> 2.5.0.234.gefc8a62
> 
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] _git: log: ignore numeric options
  2016-03-15  0:08   ` Daniel Shahaf
@ 2016-03-16 20:43     ` m0viefreak
  2016-03-16 22:39       ` Daniel Shahaf
  0 siblings, 1 reply; 11+ messages in thread
From: m0viefreak @ 2016-03-16 20:43 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers



On 15.03.2016 01:08, Daniel Shahaf wrote:
> I couldn't reproduce that: with current master, none of «git log
> -<TAB>», «git log -9<TAB>», or «git log -9 -<TAB>» go through the
> 'first-commit-ranges-or-files' code branch.
> 
> m0viefreak, if there is still a (possibly latent) bug in current master,
> could you please explain/show it?

git log -9 <TAB>

should go through the 'first-commit-ranges-or-files' branch because at
that position the first argument is expected.

Without this patch it goes through the 'commit-ranges-or-files' branch,
because '-9' is wrongly treated as the first non-option argument:


functions -T _git-log; git log -9 <TAB>

without this patch:
+_git-log:16> case commit-ranges-or-files (first-commit-ranges-or-files)
+_git-log:16> case commit-ranges-or-files (commit-ranges-or-files)
+_git-log:28> [[ -z '' ]]
+_git-log:29> __git_commit_ranges
+_git-log:29> ret=0
+_git-log:35> __git_is_committish_range -9
+_git-log:37> __git_is_committish -9
+_git-log:40> __git_tree_files . HEAD
+_git-log:40> ret=0
+_git-log:45> return ret

with this patch:
+_git-log:16> case first-commit-ranges-or-files (first-commit-ranges-or-files)
+_git-log:18> [[ -n '' ]]
+_git-log:21> _alternative commit-ranges::__git_commit_ranges 'cached-files::__git_tree_files ${PREFIX:-.} HEAD'
+_git-log:23> ret=0
+_git-log:45> return ret


This patch makes _arguments ignore any words of the form '-[0-9]#' to
work around that.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] _git: log: ignore numeric options
  2016-03-16 20:43     ` m0viefreak
@ 2016-03-16 22:39       ` Daniel Shahaf
  2016-03-16 23:00         ` m0viefreak
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Shahaf @ 2016-03-16 22:39 UTC (permalink / raw)
  To: m0viefreak; +Cc: zsh-workers

m0viefreak wrote on Wed, Mar 16, 2016 at 21:43:37 +0100:
> 
> 
> On 15.03.2016 01:08, Daniel Shahaf wrote:
> > I couldn't reproduce that: with current master, none of «git log
> > -<TAB>», «git log -9<TAB>», or «git log -9 -<TAB>» go through the
> > 'first-commit-ranges-or-files' code branch.
> > 
> > m0viefreak, if there is still a (possibly latent) bug in current master,
> > could you please explain/show it?
> 
> git log -9 <TAB>
> 
> should go through the 'first-commit-ranges-or-files' branch because at
> that position the first argument is expected.
> 
> Without this patch it goes through the 'commit-ranges-or-files' branch,
> because '-9' is wrongly treated as the first non-option argument:

I see that.

> This patch makes _arguments ignore any words of the form '-[0-9]#' to
> work around that.

Using '_arguments -A' breaks «git log origin -<TAB>», which is a valid
syntax.

How about adding 10 options, -0 through -9, which each take an optional
argument that must be in the same word?  That is:
.
    _arguments : '-'{0..9}'-[lorem ipsum]: :_guard "[0-9]#" "numeric value"'
.
?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] _git: log: ignore numeric options
  2016-03-16 22:39       ` Daniel Shahaf
@ 2016-03-16 23:00         ` m0viefreak
  0 siblings, 0 replies; 11+ messages in thread
From: m0viefreak @ 2016-03-16 23:00 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: zsh-workers

> Using '_arguments -A' breaks «git log origin -<TAB>», which is a valid
> syntax.

Oh. Thats's not good.

> How about adding 10 options, -0 through -9, which each take an optional
> argument that must be in the same word?  That is:
> .
>     _arguments : '-'{0..9}'-[lorem ipsum]: :_guard "[0-9]#" "numeric value"'
> .
> ?

That is probably the "correct" solution. I wanted to do something like that
initially, but I noticed that it pollutes verbose menu completion a lot:


Completing: option
--                                                                          -- start file arguments
-9                        -8                -7  -6  -5  -4  -3  -2  -1  -0  -- lorem ipsum
--abbrev                                                                    -- set minimum SHA1 display-length (for use with --abbrev-commit)
--abbrev                                                                    -- set minimum SHA1 display-length
--abbrev-commit                                                             -- show only partial prefixes of commit object names
--after                   --since                                           -- show commits more recent than given date
--all                                                                       -- show all commits from refs
...


So instead I went with -A. But I didn't notice that side effect above.

Using no description at least puts them at the end, but it's still ugly:

...
--topo-order                                    -- display commits in topological order
--unified                 -U                    -- generate diff with given lines of context
--use-mailmap                                   -- use mailmap file to map author and committer names and email
--walk-reflogs            -g                    -- walk reflog entries from most recent to oldest
--word-diff                                     -- show word diff
--word-diff-regex                               -- specify what constitutes a word
-z                                              -- use NUL termination on output
-0             -1             -2             -3             -4             -5             -6             -7             -8             -9


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-03-16 23:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-13 22:01 [PATCH 0/4] A few patches to _git m0viefreak
2016-03-13 22:01 ` [PATCH 1/4] _git: reflog: complete references next to commands m0viefreak
2016-03-15  0:08   ` Daniel Shahaf
2016-03-13 22:01 ` [PATCH 2/4] _git: fix tag name of remote branches m0viefreak
2016-03-15  0:08   ` Daniel Shahaf
2016-03-13 22:01 ` [PATCH 3/4] _git: log: ignore numeric options m0viefreak
2016-03-15  0:08   ` Daniel Shahaf
2016-03-16 20:43     ` m0viefreak
2016-03-16 22:39       ` Daniel Shahaf
2016-03-16 23:00         ` m0viefreak
2016-03-13 22:02 ` [PATCH 4/4] completion: _git: diff: add --no-index m0viefreak

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).