* [PATCH] _git: Complete files after 'reset' when there are no commits, when the 'verbose' style is set.
@ 2017-07-31 0:59 Daniel Shahaf
2017-08-05 22:11 ` Oliver Kiddle
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2017-07-31 0:59 UTC (permalink / raw)
To: zsh-workers
---
Completion/Unix/Command/_git | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index ce8a4049d..032cbad1e 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1462,6 +1462,12 @@ _git-reset () {
case $state in
(file)
local tree=HEAD
+ if zstyle -t :completion:${curcontext}: verbose; then
+ if ! _call_program headed git rev-parse --verify HEAD 2>/dev/null; then
+ # well-known sha1 of the empty tree
+ tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+ fi
+ fi
if [[ -n $line[1] ]] && __git_is_treeish $line[1]; then
tree=$line[1]
fi
That magic value has been used by vcs_info for a while.
I opted for making this conditional upon 'verbose' since this is a bit of an
edge case, and forks aren't free everywhere.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] _git: Complete files after 'reset' when there are no commits, when the 'verbose' style is set.
2017-07-31 0:59 [PATCH] _git: Complete files after 'reset' when there are no commits, when the 'verbose' style is set Daniel Shahaf
@ 2017-08-05 22:11 ` Oliver Kiddle
2017-08-06 17:01 ` Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2017-08-05 22:11 UTC (permalink / raw)
To: zsh-workers
On 31 Jul, Daniel Shahaf wrote:
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index ce8a4049d..032cbad1e 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -1462,6 +1462,12 @@ _git-reset () {
> case $state in
> (file)
> local tree=HEAD
> + if zstyle -t :completion:${curcontext}: verbose; then
> + if ! _call_program headed git rev-parse --verify HEAD 2>/dev/null; then
Was this supposed to assign the output of git rev-parse to $tree
because this is currently spewing the hash into the terminal?
Note _call_program should do the stderr redirection for you.
Patch below does this and adds a few new options for git 2.14.
Oliver
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 032cbad1e..518e6d198 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -628,6 +628,7 @@ _git-clone () {
'*--shallow-exclude=[shallow clone excluding commits reachable from specified remote revision]:revision' \
'(--no-single-branch)--single-branch[clone only history leading up to the main branch or the one specified by -b]' \
'(--single-branch)--no-single-branch[clone history leading up to each branch]' \
+ "--no-tags[don't clone any tags and make later fetches not follow them]" \
'--shallow-submodules[any cloned submodules will be shallow]' \
'--recursive[initialize all contained submodules]' \
'--recurse-submodules=-[initialize submodules in the clone]::file:__git_files' \
@@ -1454,6 +1455,7 @@ _git-reset () {
'(--soft --mixed --merge --keep -p --patch -- *)--hard[match the working tree and index to the given tree]' \
'(--soft --mixed --hard --keep -p --patch -- *)--merge[reset out of a conflicted merge]' \
'(--soft --mixed --hard --merge -p --patch -- *)--keep[like --hard, but keep local working tree changes]' \
+ '--recurse-submodules=-[control recursive updating of submodules]::reset:__git_commits' \
'(-p --patch)'{-p,--patch}'[select diff hunks to remove from the index]' \
'(-q --quiet)'{-q,--quiet}'[suppress all output]' \
'(--soft --mixed --hard --merge --keep):: :__git_commits' \
@@ -1463,7 +1465,7 @@ _git-reset () {
(file)
local tree=HEAD
if zstyle -t :completion:${curcontext}: verbose; then
- if ! _call_program headed git rev-parse --verify HEAD 2>/dev/null; then
+ if ! tree=$(_call_program headed git rev-parse --verify HEAD); then
# well-known sha1 of the empty tree
tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@@ -1721,9 +1723,10 @@ _git-status () {
fi
_arguments -S -s \
- '(-s --short --column --no-column)'{-s,--short}'[output in short format]' \
+ '(-s --short --column --no-column --show-stash)'{-s,--short}'[output in short format]' \
$branch_opts \
'(-s --short)--porcelain=-[produce machine-readable output]:version:(v1)' \
+ '(-s --short)--show-stash[show stash information]' \
'(-u --untracked-files)'{-u-,--untracked-files=-}'[show untracked files]::mode:((no\:"show no untracked files" \
normal\:"show untracked files and directories" \
all\:"also show untracked files in untracked directories (default)"))' \
@@ -3372,6 +3375,7 @@ _git-filter-branch () {
# such.
# TODO: * should be git-rev-arg and git-rev-list arguments.
_arguments -S -A '-*' \
+ '--setup[specify one time setup command]: :_cmdstring' \
'--env-filter[filter for modifying environment in which commit will be performed]: :_cmdstring' \
'--tree-filter[filter for rewriting tree and its contents]: :_cmdstring' \
'--index-filter[filter for rewriting index]: :_cmdstring' \
@@ -3643,6 +3647,7 @@ _git-repack () {
'--window=[number of objects to consider when doing delta compression]:number of objects' \
'--window-memory=[scale window size dynamically to not use more than specified amount of memory]: : __git_guard_bytes' \
'--depth=[maximum delta depth]:maximum delta depth' \
+ '--threads=[limit maximum number of threads]:threads' \
'--max-pack-size=-[maximum size of each output packfile]: : __git_guard_bytes "maximum pack size"' \
'--pack-kept-objects[repack objects in packs marked with .keep]'
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] _git: Complete files after 'reset' when there are no commits, when the 'verbose' style is set.
2017-08-05 22:11 ` Oliver Kiddle
@ 2017-08-06 17:01 ` Daniel Shahaf
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2017-08-06 17:01 UTC (permalink / raw)
To: zsh-workers
Oliver Kiddle wrote on Sun, 06 Aug 2017 00:11 +0200:
> On 31 Jul, Daniel Shahaf wrote:
> > +++ b/Completion/Unix/Command/_git
> > @@ -1462,6 +1462,12 @@ _git-reset () {
> > case $state in
> > (file)
> > local tree=HEAD
> > + if zstyle -t :completion:${curcontext}: verbose; then
> > + if ! _call_program headed git rev-parse --verify HEAD 2>/dev/null; then
>
> Was this supposed to assign the output of git rev-parse to $tree
>
No, it was not. I wanted to check whether HEAD refers to a commit, and
for that, only the command's exit value matters.
> because this is currently spewing the hash into the terminal?
The code would be correct either with the assignment you implemented, or
with additionally redirecting stdout to /dev/null.
> Note _call_program should do the stderr redirection for you.
>
*nod*. I didn't test without the 2>/dev/null redirection.
> Patch below does this and adds a few new options for git 2.14.
Thanks for fixing.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-06 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 0:59 [PATCH] _git: Complete files after 'reset' when there are no commits, when the 'verbose' style is set Daniel Shahaf
2017-08-05 22:11 ` Oliver Kiddle
2017-08-06 17:01 ` Daniel Shahaf
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).