git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] completion: add completer for status

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 28, 2013, 11:26 UTC
Message-ID
<20130628112631.GC16562@goldbirke>
In-Reply-To
<20130628105601.GB16562@goldbirke>
On Fri, Jun 28, 2013 at 12:56:01PM +0200, SZEDER Gábor wrote:
Show 36 quoted lines
> On Fri, Jun 28, 2013 at 12:29:36PM +0200, SZEDER Gábor wrote:
> > On Mon, Jun 24, 2013 at 10:52:55PM +0530, Ramkumar Ramachandra wrote:
> > > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> > > +	__git_complete_index_file
> > 
> > With or without this change we can't ask for the status of a certain
> > deleted file:
> > 
> > $ git rm version.h
> > rm 'version.h'
> > $ git status 
> > # On branch master
> > # Changes to be committed:
> > #   (use "git reset HEAD <file>..." to unstage)
> > #
> > #       deleted:    version.h
> > #
> > $ git status v<TAB>
> > varint.c   varint.h   vcs-svn/   version.c  
> 
> Well, at least the deleted is there if I only remove it from the work
> tree (i.e. use 'rm' instead of 'git rm'):
> 
> $ rm version.h
> $ git status
> # On branch master
> # Changes not staged for commit:
> #   (use "git add/rm <file>..." to update what will be committed)
> #   (use "git checkout -- <file>..." to discard changes in working
> #   directory)
> #
> #       deleted:    version.h
> #
> no changes added to commit (use "git add" and/or "git commit -a")
> $ git status v<TAB>
> varint.c   varint.h   vcs-svn/   version.c  version.h  
Ok, how about this on top?
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 912fb988..b68024c6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1697,6 +1697,8 @@ _git_stage ()
 
 _git_status ()
 {
+	__git_has_doubledash && return
+
 	case "$cur" in
 	--untracked-files=*)
 		__gitcomp "no normal all" "" "${cur##--untracked-files=}"
@@ -1718,7 +1720,7 @@ _git_status ()
 		return
 		;;
 	esac
-	__git_complete_index_file
+	__git_complete_index_file "--with-tree=HEAD --cached --deleted"
 }
 
 __git_config_get_set_variables ()


In my cursory testing it seemed to do the right thing for deleted and
tracked files:

$ rm version.h
$ git rm version.c
rm 'version.c'
$ echo >varint.h
$ echo >v-added
$ git add v-added 
$ echo >v-untracked
$ git status 
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   v-added
#       deleted:    version.c
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
#   directory)
#
#       modified:   varint.h
#       deleted:    version.h
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       v-untracked
$ git status v
v-added    varint.c   varint.h   vcs-svn/   version.c  version.h

Note, however, that this doesn't offer untracked files (Ram's original
didn't do that either), but in case somebody really needs that he can
have it by using '--':

$ git status -- v
v-added      varint.c     varint.h     vcs-svn/     v-untracked


Best,
Gábor
Previous: SZEDER GáborNext: Ramkumar Ramachandra
Message 5 of 9 in “completion: add completer for status”
  1. completion: add completer for statusRamkumar Ramachandra, Jun 24, 2013
  2. Ramkumar RamachandraJun 24, 2013
  3. SZEDER GáborJun 28, 2013
  4. SZEDER GáborJun 28, 2013
  5. SZEDER GáborJun 28, 2013
  6. Ramkumar RamachandraJun 28, 2013
  7. Ramkumar RamachandraJun 28, 2013
  8. SZEDER GáborJun 30, 2013
  9. SZEDER GáborJun 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.