{"thread":{"id":"34267","subject":"[PATCH] completion: add completer for status","startedAt":"2013-06-24T17:22:55Z","lastAt":"2013-06-30T11:00:36Z","messageCount":9,"participants":["Ramkumar Ramachandra","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"221862","messageId":"1372094575-20799-1-git-send-email-artagnon@gmail.com","threadId":"34267","inReplyTo":null,"subject":"[PATCH] completion: add completer for status","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-24T17:22:55Z","receivedAt":"2013-06-24T17:22:55Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n contrib/completion/git-completion.bash | 26 ++++++++++++++++++++++++++\n 1 file changed, 26 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6c3bafe..912fb98 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1695,6 +1695,32 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tcase \"$cur\" in\n+\t--untracked-files=*)\n+\t\t__gitcomp \"no normal all\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"always never auto column row plain dense nodense\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --long --porcelain\n+\t\t\t--untracked-files= --ignore-submodules= --ignored --column=\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\t__git_complete_index_file\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n-- \n1.8.3.1.550.gd96f26e.dirty\n"},{"id":"221863","messageId":"CALkWK0ncEVJLQE7ZVL+0-pNF+kS9hz5QwmreYHdoFuCoTTDA5A@mail.gmail.com","threadId":"34267","inReplyTo":"1372094575-20799-1-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH] completion: add completer for status","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-24T17:28:56Z","receivedAt":"2013-06-24T17:28:56Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n> +       __git_complete_index_file\n\nUm, that should be __git_complete_index_file \"--cached\", I think.\n"},{"id":"222161","messageId":"20130628102936.GA16562@goldbirke","threadId":"34267","inReplyTo":"1372094575-20799-1-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH] completion: add completer for status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-28T10:29:36Z","receivedAt":"2013-06-28T10:29:36Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nOn Mon, Jun 24, 2013 at 10:52:55PM +0530, Ramkumar Ramachandra wrote:\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash | 26 ++++++++++++++++++++++++++\n>  1 file changed, 26 insertions(+)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 6c3bafe..912fb98 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1695,6 +1695,32 @@ _git_stage ()\n>  \t_git_add\n>  }\n>  \n> +_git_status ()\n> +{\n> +\tcase \"$cur\" in\n> +\t--untracked-files=*)\n> +\t\t__gitcomp \"no normal all\" \"\" \"${cur##--untracked-files=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--ignore-submodules=*)\n> +\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--column=*)\n> +\t\t__gitcomp \"always never auto column row plain dense nodense\" \"\" \"${cur##--column=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--*)\n> +\t\t__gitcomp \"\n> +\t\t\t--short --branch --long --porcelain\n> +\t\t\t--untracked-files= --ignore-submodules= --ignored --column=\n\nThe parameter for '--untracked-files' '--ignore-submodules' and\n'--column' is optional.  In such cases we usually list the option both\nwith and without the '=' as a reminder, e.g. look at 'git log's\n'--decorate' and '--dirstat'.\n\n> +\t\t\t\"\n> +\t\treturn\n> +\t\t;;\n> +\tesac\n> +\t__git_complete_index_file\n\nWith or without this change we can't ask for the status of a certain\ndeleted file:\n\n$ git rm version.h\nrm 'version.h'\n$ git status \n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       deleted:    version.h\n#\n$ git status v<TAB>\nvarint.c   varint.h   vcs-svn/   version.c  \n\nI wonder whether there is some clever combination of options that\nwould make that possible?  I didn't find it.\n\n\nGábor\n"},{"id":"222163","messageId":"20130628105601.GB16562@goldbirke","threadId":"34267","inReplyTo":"20130628102936.GA16562@goldbirke","subject":"Re: [PATCH] completion: add completer for status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-28T10:56:01Z","receivedAt":"2013-06-28T10:56:01Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Jun 28, 2013 at 12:29:36PM +0200, SZEDER Gábor wrote:\n> On Mon, Jun 24, 2013 at 10:52:55PM +0530, Ramkumar Ramachandra wrote:\n> > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> > +\t__git_complete_index_file\n> \n> With or without this change we can't ask for the status of a certain\n> deleted file:\n> \n> $ git rm version.h\n> rm 'version.h'\n> $ git status \n> # On branch master\n> # Changes to be committed:\n> #   (use \"git reset HEAD <file>...\" to unstage)\n> #\n> #       deleted:    version.h\n> #\n> $ git status v<TAB>\n> varint.c   varint.h   vcs-svn/   version.c  \n\nWell, at least the deleted is there if I only remove it from the work\ntree (i.e. use 'rm' instead of 'git rm'):\n\n$ rm version.h\n$ git status\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working\n#   directory)\n#\n#       deleted:    version.h\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n$ git status v<TAB>\nvarint.c   varint.h   vcs-svn/   version.c  version.h  \n\n\nGábor\n"},{"id":"222164","messageId":"20130628112631.GC16562@goldbirke","threadId":"34267","inReplyTo":"20130628105601.GB16562@goldbirke","subject":"Re: [PATCH] completion: add completer for status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-28T11:26:31Z","receivedAt":"2013-06-28T11:26:31Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Jun 28, 2013 at 12:56:01PM +0200, SZEDER Gábor wrote:\n> On Fri, Jun 28, 2013 at 12:29:36PM +0200, SZEDER Gábor wrote:\n> > On Mon, Jun 24, 2013 at 10:52:55PM +0530, Ramkumar Ramachandra wrote:\n> > > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> > > +\t__git_complete_index_file\n> > \n> > With or without this change we can't ask for the status of a certain\n> > deleted file:\n> > \n> > $ git rm version.h\n> > rm 'version.h'\n> > $ git status \n> > # On branch master\n> > # Changes to be committed:\n> > #   (use \"git reset HEAD <file>...\" to unstage)\n> > #\n> > #       deleted:    version.h\n> > #\n> > $ git status v<TAB>\n> > varint.c   varint.h   vcs-svn/   version.c  \n> \n> Well, at least the deleted is there if I only remove it from the work\n> tree (i.e. use 'rm' instead of 'git rm'):\n> \n> $ rm version.h\n> $ git status\n> # On branch master\n> # Changes not staged for commit:\n> #   (use \"git add/rm <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working\n> #   directory)\n> #\n> #       deleted:    version.h\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> $ git status v<TAB>\n> varint.c   varint.h   vcs-svn/   version.c  version.h  \n\nOk, how about this on top?\n\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 912fb988..b68024c6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1697,6 +1697,8 @@ _git_stage ()\n \n _git_status ()\n {\n+\t__git_has_doubledash && return\n+\n \tcase \"$cur\" in\n \t--untracked-files=*)\n \t\t__gitcomp \"no normal all\" \"\" \"${cur##--untracked-files=}\"\n@@ -1718,7 +1720,7 @@ _git_status ()\n \t\treturn\n \t\t;;\n \tesac\n-\t__git_complete_index_file\n+\t__git_complete_index_file \"--with-tree=HEAD --cached --deleted\"\n }\n \n __git_config_get_set_variables ()\n\n\nIn my cursory testing it seemed to do the right thing for deleted and\ntracked files:\n\n$ rm version.h\n$ git rm version.c\nrm 'version.c'\n$ echo >varint.h\n$ echo >v-added\n$ git add v-added \n$ echo >v-untracked\n$ git status \n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       new file:   v-added\n#       deleted:    version.c\n#\n# Changes not staged for commit:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working\n#   directory)\n#\n#       modified:   varint.h\n#       deleted:    version.h\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       v-untracked\n$ git status v\nv-added    varint.c   varint.h   vcs-svn/   version.c  version.h\n\nNote, however, that this doesn't offer untracked files (Ram's original\ndidn't do that either), but in case somebody really needs that he can\nhave it by using '--':\n\n$ git status -- v\nv-added      varint.c     varint.h     vcs-svn/     v-untracked\n\n\nBest,\nGábor\n"},{"id":"222171","messageId":"CALkWK0=pyzcx-rB9gjRecoD1MFkHrSdYwLurD8y805O3FwT4Cg@mail.gmail.com","threadId":"34267","inReplyTo":"20130628112631.GC16562@goldbirke","subject":"Re: [PATCH] completion: add completer for status","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-28T13:20:02Z","receivedAt":"2013-06-28T13:20:02Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"SZEDER Gábor wrote:\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 912fb988..b68024c6 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1697,6 +1697,8 @@ _git_stage ()\n>\n>  _git_status ()\n>  {\n> +       __git_has_doubledash && return\n> +\n\nThis line makes absolutely no sense to me.  When the case statement\nfails to match anything (which it will, when a double-dash is\npresent), we'll use the __git_complete_index_file which is superior to\nreturning and falling back to the dumb zsh file listing, no?  As a\nresult, without that line,\n\n  $ git status -- foo<TAB>\n\nwill complete fine when foo* isn't necessarily a file in the\nfilesystem, but something that our ls-files returns, no?\n\n>         case \"$cur\" in\n>         --untracked-files=*)\n>                 __gitcomp \"no normal all\" \"\" \"${cur##--untracked-files=}\"\n> @@ -1718,7 +1720,7 @@ _git_status ()\n>                 return\n>                 ;;\n>         esac\n> -       __git_complete_index_file\n> +       __git_complete_index_file \"--with-tree=HEAD --cached --deleted\"\n\nMight as well go all the way with  \"--cached --deleted --unmerged\n--others\" no?  What is the point of --with-tree=HEAD?\n\nThanks.\n"},{"id":"222175","messageId":"CALkWK0=RZbZxSzCFNAPqzcpnnC_Tak+isESmFiEyLMgcu3vV1Q@mail.gmail.com","threadId":"34267","inReplyTo":"CALkWK0=pyzcx-rB9gjRecoD1MFkHrSdYwLurD8y805O3FwT4Cg@mail.gmail.com","subject":"Re: [PATCH] completion: add completer for status","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-28T14:03:21Z","receivedAt":"2013-06-28T14:03:21Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n>> +       __git_complete_index_file \"--with-tree=HEAD --cached --deleted\"\n>\n> Might as well go all the way with  \"--cached --deleted --unmerged\n> --others\" no?  What is the point of --with-tree=HEAD?\n\nUgh, --deleted doesn't work as advertised (terrible documentation).\nThe minimally correct combination we need seems to be\n\"--with-tree=HEAD --cached --others\".\n"},{"id":"222176","messageId":"20130628140434.GA12404@goldbirke","threadId":"34267","inReplyTo":"CALkWK0=pyzcx-rB9gjRecoD1MFkHrSdYwLurD8y805O3FwT4Cg@mail.gmail.com","subject":"Re: [PATCH] completion: add completer for status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-28T14:04:34Z","receivedAt":"2013-06-28T14:04:34Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Jun 28, 2013 at 06:50:02PM +0530, Ramkumar Ramachandra wrote:\n> SZEDER Gábor wrote:\n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index 912fb988..b68024c6 100644\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -1697,6 +1697,8 @@ _git_stage ()\n> >\n> >  _git_status ()\n> >  {\n> > +       __git_has_doubledash && return\n> > +\n> \n> This line makes absolutely no sense to me.\n\nThat was my quick attempt to provide a way to complete untracked\nfiles, but M-/ or '--others' will do as well.\n\n> When the case statement\n> fails to match anything (which it will, when a double-dash is\n> present), we'll use the __git_complete_index_file which is superior to\n\nAnd slower, too.\n\n> returning and falling back to the dumb zsh file listing, no?  As a\n> result, without that line,\n> \n>   $ git status -- foo<TAB>\n> \n> will complete fine when foo* isn't necessarily a file in the\n> filesystem, but something that our ls-files returns, no?\n\nIf you want fancy completion replies, then you won't type the\ndoubledash.\n\n> >         case \"$cur\" in\n> >         --untracked-files=*)\n> >                 __gitcomp \"no normal all\" \"\" \"${cur##--untracked-files=}\"\n> > @@ -1718,7 +1720,7 @@ _git_status ()\n> >                 return\n> >                 ;;\n> >         esac\n> > -       __git_complete_index_file\n> > +       __git_complete_index_file \"--with-tree=HEAD --cached --deleted\"\n> \n> Might as well go all the way with  \"--cached --deleted --unmerged\n> --others\" no?\n\n'--unmerged' is definitely not good, it implies '--stage', which\nchanges the output format.\n\n> What is the point of --with-tree=HEAD?\n\nTo list files that are deleted from the index:\n\n$ rm version.h\n$ git rm version.c\nrm 'version.c'\n$ git ls-files --deleted\nversion.h\n$ git ls-files --deleted --with-tree=HEAD\nversion.c\nversion.h\n\n\nGábor\n"},{"id":"222240","messageId":"20130630110036.GA2294@goldbirke","threadId":"34267","inReplyTo":"CALkWK0=RZbZxSzCFNAPqzcpnnC_Tak+isESmFiEyLMgcu3vV1Q@mail.gmail.com","subject":"Re: [PATCH] completion: add completer for status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-30T11:00:36Z","receivedAt":"2013-06-30T11:00:36Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Jun 28, 2013 at 07:33:21PM +0530, Ramkumar Ramachandra wrote:\n> Ramkumar Ramachandra wrote:\n> >> +       __git_complete_index_file \"--with-tree=HEAD --cached --deleted\"\n> >\n> > Might as well go all the way with  \"--cached --deleted --unmerged\n> > --others\" no?  What is the point of --with-tree=HEAD?\n> \n> Ugh, --deleted doesn't work as advertised (terrible documentation).\n\nWhy not?  In my experiments it worked well, as you can see in my\nprevious emails.  What behavior did you observe which differs from the\nadvertised?\n\n> The minimally correct combination we need seems to be\n> \"--with-tree=HEAD --cached --others\".\n\nYeah, once we use '--with-tree=HEAD' we don't need '--deleted'\nanymore.\n\n\nGábor\n"}]}