Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: git log -1 --...



Daniel Shahaf wrote on Thu, Aug 13, 2015 at 23:13:50 +0000:
> 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').
> 

Patches for these issues two attached.  They are to be applied on top of
Oliver's patch from this thread.  (They conflict textually but should be
independent semantically.)

> These are preexisting issues: they weren't caused by your patch and
> can be fixed independently of it.
...
> 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
From 3af6437ee181fbcb4d1d764d6a7b2e5e098d1dd8 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Aug 2015 04:19:27 +0000
Subject: [PATCH 2/3] _git-log: complete 'git rm'd files

---
 Completion/Unix/Command/_git | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 25af4fc..90969bd 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1093,11 +1093,11 @@ _git-log () {
   case $state in
     (first-commit-ranges-or-files)
       if [[ -n ${opt_args[(I)--]} ]]; then
-	__git_cached_files && ret=0
+	__git_tree_files ${PREFIX:-.} HEAD && ret=0
       else
 	_alternative \
 	  'commit-ranges::__git_commit_ranges' \
-	  'cached-files::__git_cached_files' && ret=0
+	  'cached-files::__git_tree_files ${PREFIX:-.} HEAD' && ret=0
       fi
     ;;
     (commit-ranges-or-files)
@@ -1109,7 +1109,7 @@ _git-log () {
       elif __git_is_committish $line[1]; then
 	__git_tree_files ${PREFIX:-.} $line[1] && ret=0
       else
-	__git_cached_files && ret=0
+	__git_tree_files ${PREFIX:-.} HEAD && ret=0
       fi
     ;;
   esac
-- 
2.1.4

From ff8b9df282efbec19319719f67b99cf7d259087a Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Aug 2015 04:26:48 +0000
Subject: [PATCH 3/3] _git-log: Complete multiple revspecs

e.g., git log origin/master origin/foo origin/bar
---
 Completion/Unix/Command/_git | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 90969bd..6922393 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1101,6 +1101,11 @@ _git-log () {
       fi
     ;;
     (commit-ranges-or-files)
+      # Multiple revspecs are permitted.
+      if [[ -z ${opt_args[(I)--]} ]]; then
+        __git_commit_ranges "$@" && ret=0
+      fi
+
       # TODO: Write a wrapper function that checks whether we have a
       # committish range or comittish and calls __git_tree_files
       # appropriately.
-- 
2.1.4



Messages sorted by: Reverse Date, Date, Thread, Author