zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: git log -1 --...
Date: Thu, 13 Aug 2015 23:13:50 +0000	[thread overview]
Message-ID: <20150813231350.GA1998@tarsus.local2> (raw)
In-Reply-To: <12769.1439466043@thecus.kiddle.eu>

Oliver Kiddle wrote on Thu, Aug 13, 2015 at 13:40:43 +0200:
> Peter wrote:
> > I haven't looked, but this could well be because _arguments hasn't been
> > told -<num> is a valid completion because there's no point actually
> > completing it, so it assumes it's a regular argument.
> 
> Same problem for git log HEAD --... so it is not quite that.
> It's an effect of the *:: form with _arguments.
> 
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index a5e4464..fb8ba6a 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -1087,33 +1087,31 @@ _git-log () {
>      $revision_options \
>      '-L+[trace the evolution of a line range or regex within a file]:range' \
>      '(-)--[start file arguments]' \
> +    '1: :->first-commit-ranges-or-files' \
> +    '*: :->commit-ranges-or-files' && ret=0
>  
>    case $state in
> +    (first-commit-ranges-or-files)
> +      if [[ -n ${opt_args[(I)--]} ]]; then
> +	__git_cached_files && ret=0
> +      else
> +	_alternative \
> +	  'commit-ranges::__git_commit_ranges' \
> +	  'cached-files::__git_cached_files' && ret=0
> +      fi
> +    ;;
> +    (commit-ranges-or-files)
> +      # TODO: Write a wrapper function that checks whether we have a
> +      # committish range or comittish and calls __git_tree_files
> +      # appropriately.
> +      if __git_is_committish_range $line[1]; then
> +	__git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0
> +      elif __git_is_committish $line[1]; then
> +	__git_tree_files ${PREFIX:-.} $line[1] && ret=0
> +      else
> +	__git_cached_files && ret=0
> +      fi
> +    ;;
>    esac
>  

There are two additional problems in this code, besides the one you are
fixing:

1. The second-word-or-later should complete commit ranges or revspecs
too (as in 'git log origin/master origin/foobar').

2. Using __git_cached_files is wrong since it wouldn't complete files
that are in HEAD but not in the index (i.e., any uncommitted 'git rm').

These are preexisting issues: they weren't caused by your patch and
can be fixed independently of it.

Cheers,

Daniel

P.S. There is an asymmetry between __git_tree_files
/ __git_cached_files: the former does 'ls-tree' one directory-tree-level
at a time, the latter gets the 'ls -R' output and lets _multi_parts
handle the one-directory-tree-level-at-a-time part.  I'm not sure
which approach is better.

>    return ret


  reply	other threads:[~2015-08-13 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 11:07 Peter Stephenson
2015-08-13 11:40 ` Oliver Kiddle
2015-08-13 23:13   ` Daniel Shahaf [this message]
2015-08-19  2:01     ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150813231350.GA1998@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).