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

Re: [PATCH] _git-cat-file blob completion fix



Mikael Magnusson wrote on Wed, Aug 19, 2015 at 04:10:42 +0200:
> On Wed, Aug 19, 2015 at 4:05 AM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> > 'git cat-file HEAD:<TAB>', when cwd is a subdirectory of a repository,
> > completes files within that subdirectory, but should complete files
> > relative to the repository root.  The attach patch implements that.
> >
> > Review would be appreciated — I might have missed something while
> > reverse-engineering the semantics of everything.  (I already checked
> > gitrevisions(7) and tested 'git rev-parse HEAD:<TAB>'.)
> >
> > I didn't make --root-relative a zparseopts option because I didn't want
> > to have to name the same as git option it maps to.
> 
> You can say HEAD:./foo to specify foo relative to the current
> directory. However, this doesn't work in the current completer either
> afaict, so it's not a regression to apply this patch :).

To be applied on top of the previous.

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 23113ac..18df09e 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5739,7 +5739,11 @@ __git_tree_ishs () {
 __git_objects () {
   compset -P '*:'
   if [[ -n $IPREFIX ]]; then
-    __git_tree_files --root-relative "$PREFIX" "${IPREFIX%:}"
+    if compset -P ./ ; then
+      __git_tree_files                 "$PREFIX" "${IPREFIX%:./}"
+    else
+      __git_tree_files --root-relative "$PREFIX" "${IPREFIX%:}"
+    fi
   else
     _alternative \
       'revisions::__git_revisions' \



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