git add completion should exclude staged content
Dear Git Hackers,
I have a feature request for git add auto completion:
git add auto completion suggests all files / directories, filtered by nothing. I guess it would be much nicer (as in increasing productivity) if it would only suggest unstaged content, as reported by git status, because that would be the only content one would be able to add.
Example:
$ git status
# On branch develop
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: src/main/scala/XYChart.scala
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# notes/0.2.0.markdown $ git add <auto-complete>
build.sbt .ensime .git/ project/ scalastyle-config.xml todo
COPYING .ensime_lucene/ notes/ README.md src/
$ git addWhere it should be:
$ git add <auto-complete>
$ git add notes/0.2.0.markdown... because notes/0.2.0.markdown is the only thing I can add.
Signature · 6 lines
Beste Grüße / Best Regards Christian Krause aka wookietreiber ----------------------------------------------------------------------- EGAL WIE DICHT DU BIST, GOETHE WAR DICHTER.
Quoted 7 lines · wookietreiber
I have a feature request for
git addauto completion:
git addauto completion suggests all files / directories, filtered by nothing. I guess it would be much nicer (as in increasing productivity) if it would only suggest unstaged content, as reported bygit status, because that would be the only content one would be able to add.
I think that is what Manlio Perillo tried to do with the stalled mp/complete-paths topic that is queued in 'pu'.
Manlio, any progress?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 28/01/2013 00:00, Junio C Hamano ha scritto:
Quoted 10 lines
Quoted 7 lines · wookietreiber
I have a feature request for
git addauto completion:
git addauto completion suggests all files / directories, filtered by nothing. I guess it would be much nicer (as in increasing productivity) if it would only suggest unstaged content, as reported bygit status, because that would be the only content one would be able to add.
Quoted 4 lines
I think that is what Manlio Perillo tried to do with the stalled mp/complete-paths topic that is queued in 'pu'.
Manlio, any progress?
Well, I assumed that the patch was stalled due to missing review from git completion experts...
For this reason I have not updated it with your latest suggestions, waiting for the review (also, because now I'm busy with other projects).
For the OP: the last patch can be found in the mailing list archive, with the subject:
[PATCH v5] git-completion.bash: add support for path completion
and date:
Fri, 11 Jan 2013 19:48:43 +0100
Can you please test it?
Regards Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEGRE8ACgkQscQJ24LbaUSX9ACfUMBH/X6lVH4V7FUaB2wlqj8C eYQAnAzuYwhYhDvkW3d29IeqHsDFyWBT
=BpRi
-----END PGP SIGNATURE-----
Manlio Perillo venit, vidit, dixit 28.01.2013 10:26:
Quoted 26 lines
Il 28/01/2013 00:00, Junio C Hamano ha scritto:
Quoted 10 lines
Quoted 7 lines · wookietreiber
I have a feature request for
git addauto completion:
git addauto completion suggests all files / directories, filtered by nothing. I guess it would be much nicer (as in increasing productivity) if it would only suggest unstaged content, as reported bygit status, because that would be the only content one would be able to add.Quoted 4 lines
I think that is what Manlio Perillo tried to do with the stalled mp/complete-paths topic that is queued in 'pu'.
Manlio, any progress?
Well, I assumed that the patch was stalled due to missing review from git completion experts...
For this reason I have not updated it with your latest suggestions, waiting for the review (also, because now I'm busy with other projects).
For the OP: the last patch can be found in the mailing list archive, with the subject:
[PATCH v5] git-completion.bash: add support for path completion
and date:
Quoted 9 lines
Fri, 11 Jan 2013 19:48:43 +0100Can you please test it?
Regards Manlio
I haven't looked at the patch, but in the example above, untracked files) could be added as well (unless you use -u), so maybe the scope should depend on the option? If the new completion code kept me from adding untracked files easily it wouldn't be an improvement.
Michael
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 28/01/2013 13:52, Michael J Gruber ha scritto:
Quoted 13 lines
Manlio Perillo venit, vidit, dixit 28.01.2013 10:26:
Quoted 5 lines
Il 28/01/2013 00:00, Junio C Hamano ha scritto:
Quoted 4 lines
Quoted 2 lines · wookietreiber
I have a feature request for
git addauto completion:[...]
Quoted 6 lines
For the OP: the last patch can be found in the mailing list archive, with the subject:
[PATCH v5] git-completion.bash: add support for path completion
and date:Fri, 11 Jan 2013 19:48:43 +0100
Quoted 8 lines
Quoted 2 lines
Can you please test it?
I haven't looked at the patch, but in the example above, untracked files) could be added as well (unless you use -u), so maybe the scope should depend on the option? If the new completion code kept me from adding untracked files easily it wouldn't be an improvement.
The patch will suggest (for git add command), all the files that are candidate to be added to the index file.
Please, test it and report any behaviour you think is incorrect.
Regards Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEGhPsACgkQscQJ24LbaUTYOwCdFagTRkHzUHoFwy3U+Vz6tAzE tVIAnj8fAbyGrlNUoUgI4ZshwOtlEH8v
=jy8R
-----END PGP SIGNATURE-----
Manlio Perillo venit, vidit, dixit 28.01.2013 15:02:
Quoted 23 lines
Il 28/01/2013 13:52, Michael J Gruber ha scritto:
Quoted 13 lines
Manlio Perillo venit, vidit, dixit 28.01.2013 10:26:
Quoted 5 lines
Il 28/01/2013 00:00, Junio C Hamano ha scritto:
Quoted 4 lines
Quoted 2 lines · wookietreiber
I have a feature request for
git addauto completion:[...]
Quoted 6 lines
For the OP: the last patch can be found in the mailing list archive, with the subject:
[PATCH v5] git-completion.bash: add support for path completion
and date:Fri, 11 Jan 2013 19:48:43 +0100Quoted 7 lines
Quoted 2 lines
Can you please test it?
I haven't looked at the patch, but in the example above, untracked files) could be added as well (unless you use -u), so maybe the scope should depend on the option? If the new completion code kept me from adding untracked files easily it wouldn't be an improvement.
Quoted 4 lines
The patch will suggest (for git add command), all the files that are candidate to be added to the index file.
Please, test it and report any behaviour you think is incorrect.
OK, that seems to work and to be quite helpful.
Minor nit: "git add -u" could use the same fileset as "git commit". But I don't know whether completion can act upon the presence of options. Currently, it also includes untracked files (just like without -u) but omits unmodified and ignored ones, which is already quite an improvement.
I won't be able to review the completion code but may contribute a few lines to t/t9902-completion.sh, possibly.
Michael
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 28/01/2013 17:22, Michael J Gruber ha scritto:
Quoted 10 lines
[...]
Quoted 4 lines
The patch will suggest (for git add command), all the files that are candidate to be added to the index file.
Please, test it and report any behaviour you think is incorrect.
OK, that seems to work and to be quite helpful.
Minor nit: "git add -u" could use the same fileset as "git commit". But I don't know whether completion can act upon the presence of options.
It is possible, but I have not implemented since I was not sure about it and I wanted to avoid to make the patch more hard to review.
I will work on it after the patch is approved.
Quoted 6 lines
Currently, it also includes untracked files (just like without -u) but omits unmodified and ignored ones, which is already quite an improvement.
I won't be able to review the completion code but may contribute a few lines to
t/t9902-completion.sh, possibly.
Ah, I missed this test; thanks.
The proposed patch must update it.
Regards Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEG2+UACgkQscQJ24LbaURstACfdNxuFvaokBSTls20bSQ7jPHA 8I0An3fX6oRKuc2lzAgPVBLjsbjbw91V
=igwr
-----END PGP SIGNATURE-----
Quoted 5 lines · Michael J Gruber
Manlio Perillo venit, vidit, dixit 28.01.2013 15:02:
Quoted 1 line
Please, test it and report any behaviour you think is incorrect.
OK, that seems to work and to be quite helpful.
Quoted 7 lines
Minor nit: "git add -u" could use the same fileset as "git commit". But I don't know whether completion can act upon the presence of options. Currently, it also includes untracked files (just like without -u) but omits unmodified and ignored ones, which is already quite an improvement.
I won't be able to review the completion code but may contribute a few lines to
t/t9902-completion.sh, possibly.
Thanks both for commenting. I'll find time to read it over again and perhaps we can merge it to 'next' and advertise it in the next issue of "What's cooking" report to ask for wider testing to move it forward.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 28/01/2013 18:52, Junio C Hamano ha scritto:
Quoted 6 lines
[...]
Thanks both for commenting. I'll find time to read it over again and perhaps we can merge it to 'next' and advertise it in the next issue of "What's cooking" report to ask for wider testing to move it forward.
Thanks.
I will try to update the patch, with your latest suggestions (avoid tricky POSIX shell syntax, and CDPATH issue - if I remember correctly), and with an update for the t/t9902-completion.sh test (that I completely missed).
Regards Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEG3IcACgkQscQJ24LbaUTR/wCfSC/kHxseKAQ9rnK2ba/WwND1 cmsAn2CuHpRs2VjippTwkT5O3ul9cQKb
=5Way
-----END PGP SIGNATURE-----
Quoted 21 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Manlio Perillo
Sent: Monday, January 28, 2013 3:16 PM
To: Junio C Hamano
Cc: Michael J Gruber; wookietreiber; [email protected]
Subject: Re: [feature request] git add completion should exclude staged content-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Il 28/01/2013 18:52, Junio C Hamano ha scritto:
Quoted 6 lines
[...]
Thanks both for commenting. I'll find time to read it over again and perhaps we can merge it to 'next' and advertise it in the next issue of "What's cooking" report to ask for wider testing to move it forward.
Quoted 8 lines
Thanks.
I will try to update the patch, with your latest suggestions (avoid tricky POSIX shell syntax, and CDPATH issue - if I remember correctly),
and with an update for thet/t9902-completion.shtest (that I completely
missed).
Hi Manlio,
I'm trying to update git-completion.tcsh to work properly with your nice new completion feature. But I'm having trouble with the missing '/' at the end of directories.
The new logic in git-completion.bash tells bash that 'filenames' completion is ongoing so bash will add a '/' after directories. Sadly, tcsh won't do that, so it would be simpler if git-completion.bash added the '/' itself. I looked at the git-completion.bash script changes and I noticed that for bash version < 4, you have to add the '/' yourself.
I also noticed the following comment:
# XXX if we append a slash to directory names when using # compopt -o filenames, Bash will append another slash. # This is pretty stupid, and this the reason why we have to
# define a compatible version for this function.
So I gather you would rather add a '/' all the time to deal with older bash version transparently. This would be great for tcsh also. I'm trying to figure out
when bash mis-behaves when you add the '/' all the time? When I try it (I have bash 4.1.5(1)-release) I didn't run into the double slash problem you mention in the comment.
I'm hoping we can straighten this out and have
git-completion.bash add the '/' all the time.
Could you explain when the problem happens?
Thanks
Marc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 30/01/2013 15:06, Marc Khouzam ha scritto:
Quoted 10 lines
[...]
Quoted 6 lines
I will try to update the patch, with your latest suggestions (avoid tricky POSIX shell syntax, and CDPATH issue - if I remember correctly),
and with an update for thet/t9902-completion.shtest (that I completely
missed).Hi Manlio,
Hi.
Quoted 10 lines
I'm trying to update git-completion.tcsh to work properly with your nice new completion feature. But I'm having trouble with the missing '/' at the end of directories.
The new logic in git-completion.bash tells bash that 'filenames' completion is ongoing so bash will add a '/' after directories. Sadly, tcsh won't do that, so it would be simpler if git-completion.bash added the '/' itself. I looked at the git-completion.bash script changes and I noticed that for bash version < 4, you have to add the '/' yourself.
The compatible version is not only required for Bash; you can use it for other shells.
Try to redefine the __git_index_file_list_filter function to use the version that adds a slash to directory names.
Quoted 5 lines
I also noticed the following comment:
# XXX if we append a slash to directory names when using #
compopt -o filenames, Bash will append another slash. # This is pretty stupid, and this the reason why we have to
Quoted 9 lines
# define a compatible version for this function.So I gather you would rather add a '/' all the time to deal with older bash version transparently. This would be great for tcsh also. I'm trying to figure out
when bash mis-behaves when you add the '/' all the time? When I try it (I have bash 4.1.5(1)-release) I didn't run into the double slash problem you mention in the comment.
I'm using the same version: 4.1.5(1), on Debian stable.
Quoted 5 lines
I'm hoping we can straighten this out and have
git-completion.bash add the '/' all the time.Could you explain when the problem happens?
Bash 4.1.5(1) always adds an additional slash for directories. I have tested it right now: change the filter function to use the compatible version:
__git_index_file_list_filter ()
{
# Default to Bash >= 4.x
__git_index_file_list_filter_compat
}
Then running git add <TAB> inside the git repository, I get this file completion list:
$ git add <TAB> contrib//
Quoted 2 lines
Thanks
Thanks to you
Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEJZUMACgkQscQJ24LbaUQUGACgkMG/bZrJKBzlZ8toEQwmggQX m9kAn2ATJbSp87kOkoCCc00eHmh71r3y
=D9iu
-----END PGP SIGNATURE-----
Quoted 39 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Manlio Perillo
Sent: Wednesday, January 30, 2013 1:24 PM
To: Marc Khouzam
Cc: 'Junio C Hamano'; 'Michael J Gruber'; 'wookietreiber'; '[email protected]'
Subject: Re: [feature request] git add completion should exclude staged content-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Il 30/01/2013 15:06, Marc Khouzam ha scritto:
Quoted 10 lines
[...]
Quoted 6 lines
I will try to update the patch, with your latest suggestions (avoid tricky POSIX shell syntax, and CDPATH issue - if I remember correctly),
and with an update for thet/t9902-completion.shtest (that I completely
missed).Hi Manlio,
Hi.
Quoted 10 lines
I'm trying to update git-completion.tcsh to work properly with your nice new completion feature. But I'm having trouble with the missing '/' at the end of directories.
The new logic in git-completion.bash tells bash that 'filenames' completion is ongoing so bash will add a '/' after directories. Sadly, tcsh won't do that, so it would be simpler if git-completion.bash added the '/' itself. I looked at the git-completion.bash script changes and I noticed that for bash version < 4, you have to add the '/' yourself.
Quoted 6 lines
The compatible version is not only required for Bash; you can use it for
other shells.Try to redefine the
__git_index_file_list_filterfunction to use the version that adds a slash to directory names.
I hadn't thought of that!
Although I would prefer not to have special cases like that, it does work well.
Thanks!
Quoted 34 lines
Quoted 5 lines
I also noticed the following comment:
# XXX if we append a slash to directory names when using #
compopt -o filenames, Bash will append another slash. # This is pretty stupid, and this the reason why we have toQuoted 9 lines
# define a compatible version for this function.So I gather you would rather add a '/' all the time to deal with older bash version transparently. This would be great for tcsh also. I'm trying to figure out
when bash mis-behaves when you add the '/' all the time? When I try it (I have bash 4.1.5(1)-release) I didn't run into the double slash problem you mention in the comment.I'm using the same version: 4.1.5(1), on Debian stable.
Quoted 5 lines
I'm hoping we can straighten this out and have
git-completion.bash add the '/' all the time.Could you explain when the problem happens?
Bash 4.1.5(1) always adds an additional slash for directories. I have tested it right now: change the filter function to use the compatible version:
__git_index_file_list_filter()
{
# Default to Bash >= 4.x
__git_index_file_list_filter_compat
}
Quoted 6 lines
Then running
git add <TAB>inside the git repository, I get this file
completion list:$ git add <TAB> contrib//
Ok, I see. The double-slash is visible in the completion list but it does not appear on the command-line when bash automatically adds it. So if you typed
git add contri<tab>
you will properly get
git add contrib/
That is the case I was looking at.
I understand why you cannot put that second slash in the code now.
Thanks
Quoted 22 lines
Quoted 4 lines
Thanks
Thanks to you
Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iEYEARECAAYFAlEJZUMACgkQscQJ24LbaUQUGACgkMG/bZrJKBzlZ8toEQwmggQX m9kAn2ATJbSp87kOkoCCc00eHmh71r3y
=D9iu
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 30/01/2013 19:55, Marc Khouzam ha scritto:
Quoted 8 lines
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The new logic in git-completion.bash tells bash that 'filenames' completion is ongoing so bash will add a '/' after directories. Sadly, tcsh won't do that, so it would be simpler if git-completion.bash added the '/' itself. I looked at the git-completion.bash script changes and I noticed that for bash version < 4, you have to add the '/' yourself.
Quoted 10 lines
The compatible version is not only required for Bash; you can use it for
other shells.Try to redefine the
__git_index_file_list_filterfunction to use the version that adds a slash to directory names.Quoted 3 lines
I hadn't thought of that!
Although I would prefer not to have special cases like that, it does work well.
The zsh compatible code does something like this; this is the reason I tried to do the same thing, in order to keep coding consistent.
Quoted 13 lines
[...]
Bash 4.1.5(1) always adds an additional slash for directories. I have tested it right now: change the filter function to use the compatible version:
__git_index_file_list_filter()
{
# Default to Bash >= 4.x
__git_index_file_list_filter_compat
}
Quoted 10 lines
Then running
git add <TAB>inside the git repository, I get this file
completion list:$ git add <TAB> contrib//Quoted 3 lines
Ok, I see. The double-slash is visible in the completion list but it does not appear on the command-line when bash automatically adds it.
Right; that's why I wrote in the comment that Bash behaviour "seems" stupid. But probably that comment should be remove or changed for the final version of the patch; I'll leave that to a Bash expert.
Quoted 1 line
[...]
Regards Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAlEJe0kACgkQscQJ24LbaUScGgCeMDDdprJMgnYtFzqnFQamhfvU BikAniMkwbOEVkkomOd9G0m3KY44f/9O
=c8rC
-----END PGP SIGNATURE-----