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

Re: [PATCH] git-completion.bash: add support for path completion

From
Manlio Perillo <manlio.perillo@gmail.com>
Date
Dec 19, 2012, 23:50 UTC
Message-ID
<50D252BE.1070808@gmail.com>
In-Reply-To
<7vy5gt7j3c.fsf@alter.siamese.dyndns.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 19/12/2012 23:49, Junio C Hamano ha scritto:
Show 14 quoted lines
> Manlio Perillo <manlio.perillo@gmail.com> writes:
> 
>>> 	git mv COPYING README X
>>
>> Assuming X is a new untracked directory, do you think it is an usability
>> problem if an user try to do:
>>
>> 	git mv COPYING README <TAB>
>>
>> and X does not appear in the completion list?
> 
> It is hard to say.  Will it show "Documentation/" in the list?  Will
> it show "git.c" in the list?
> 
Currently all cached files will be showed.
Show 7 quoted lines
> Your "git mv git.<TAB>" completing to "git mv git.c" would be an
> improvement compared to the stock "less git.<TAB>" that offers
> "git.c" and "git.o" as choices.  For things like "mv" and "rm", this
> may not make too much of a difference, "git add <TAB>" would be a
> vast improvement from the stock one.  The users will notice that the
> completion knows what it is doing, and will come to depend on it.
> 
Yes, this is precisely the reason why I'm implementing it ;-).

I also use Mercurial (I discovered Git just a few weeks ago, after reading Pro Git), and Mercurial do have path completion (completion list does not stop at directory boundary, however).

When I started to use Git, one of the first thing I noticed was the lack of path completion for git add.

Show 8 quoted lines
> [...]
> In the ideal world (read: I am *not* saying "you should implement it
> this way, or we won't look at your patch"), I think you would want
> to show tracked files (because it may be the third path that the
> user wants to move with the command, not the destination directory)
> and any directory on the filesystem (it could be the third path that
> is being moved if it has tracked files, or it could be the final
> destination directory argument).
What about this?
* show all and only cached files for the first argument
* show all cached + untracked directories and files for all other
  arguments

This should solve most of the problem, and will still not show ignored files. And, most important, it is very easy to implement.

The only issue is that "git ls-files -o" does not show empty directories, and "git ls-files --directory -o" will add a trailing slash.

Thanks   Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlDSUr4ACgkQscQJ24LbaURf0gCeJVZviwfKHgHNZ8vYBjnjwP8+ WF4AnAn3/KPJciJg9r387qIzCajx4j0s =/10k -----END PGP SIGNATURE-----

Previous: Junio C Hamano
Message 8 of 8 in “git-completion.bash: add support for path completion”
  1. git-completion.bash: add support for path completionManlio Perillo, Dec 16, 2012
  2. Junio C HamanoDec 17, 2012
  3. Manlio PerilloDec 17, 2012
  4. Junio C HamanoDec 17, 2012
  5. Manlio PerilloDec 18, 2012
  6. Manlio PerilloDec 19, 2012
  7. Junio C HamanoDec 19, 2012
  8. Manlio PerilloDec 19, 2012

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.