From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Daniel Hahler <genml+zsh-workers@thequod.de>
Cc: zsh-workers@zsh.org
Subject: Re: Improved completion for git commit objects (__git_commit_objects)
Date: Wed, 4 Mar 2015 02:40:00 +0000 [thread overview]
Message-ID: <20150304024000.GF2057@tarsus.local2> (raw)
In-Reply-To: <54F647E2.5020400@thequod.de>
Daniel Hahler wrote on Wed, Mar 04, 2015 at 00:46:42 +0100:
> First, I've also added __git_commits to _git-commit where relevant:
>
> diff --git i/Completion/Unix/Command/_git w/Completion/Unix/Command/_git
> index 9552780..0bfa057 100644
> --- i/Completion/Unix/Command/_git
> +++ w/Completion/Unix/Command/_git
> @@ -647,8 +647,8 @@ _git-commit () {
> # TODO: --interactive isn't explicitly listed in the documentation.
> _arguments -w -S -s \
> '(-a --all --interactive -o --only -i --include *)'{-a,--all}'[stage all modified and deleted paths]' \
> - '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:' \
> - '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:' \
> + '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_commits' \
> + '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_commits' \
> $reset_author_opt \
> '( --porcelain --dry-run)--short[output dry run in short format]' \
> '(--short --dry-run)--porcelain[output dry run in porcelain-ready format]' \
>
Looks like we could apply this part immediately, it isn't WIP like the
rest of your change.
> + : ${(AA)commits::=${(f)"$(_call_program commits git --no-pager log --oneline -2 --format='%h%n%s')"}}
You can remove '--oneline': it has no effect since you use '--format' later.
> _guard '[[:xdigit:]](#c,40)' 'commit object name'
> +
> + : ${(AA)commits::=${(f)"$(_call_program commits git --no-pager log --oneline -2 --format='%h%n%s')"}}
> + __git_command_successful $pipestatus || return 1
> +
> + _wanted commits expl 'commit object name' compadd "$@" -k - commits && ret=0
> }
>
> I do not fully understand how "_guard" is meant to be used - I need to comment/remove it.
> Should this get chained, e.g. with "_wanted", instead?
What's the desired behaviour? Suppose that ${(k)commits} is [0123abc,
4567def] and the user types '--fixup=fedbca<TAB>'. In this case, you'd
still want the second argument to _guard to be displayed, right?
In this case, I think you should retain _guard in the "the 'commits' tag
is wanted, but none of ${(k)commits} matches the input so far" codepath.
Makes sense?
> As for using the commit objects in the completion, I would not like to have then for
> "git checkout <tab>" by default, but with "git commit --fixup=".
> With "git checkout", any partial matching commit objects should be completed though,
> and the list would be useful to have on second "<tab>".
>
> What do you think?
Haven't tried the patch, but I like the idea of offering recent commits
as completions for --fixup. I use --fixup regularly, and that's exactly
the completion offers I'd want.
Cheers,
Daniel
next prev parent reply other threads:[~2015-03-04 2:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 23:46 Daniel Hahler
2015-03-04 2:40 ` Daniel Shahaf [this message]
2015-03-04 2:57 ` Daniel Shahaf
[not found] ` <54F7AF66.1010608@thequod.de>
2015-03-07 3:46 ` Daniel Shahaf
2015-03-07 4:01 ` Daniel Shahaf
2015-03-07 12:59 ` Mikael Magnusson
2015-03-09 19:54 ` 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=20150304024000.GF2057@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--cc=genml+zsh-workers@thequod.de \
--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).