{"thread":{"id":"32812","subject":"[PATCH] Handle path completion and colon for tcsh script","startedAt":"2013-02-02T19:43:25Z","lastAt":"2013-02-04T03:02:45Z","messageCount":6,"participants":["Marc Khouzam","Junio C Hamano","Manlio Perillo"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"208525","messageId":"E59706EF8DB1D147B15BECA3322E4BDC09AA38@eusaamb103.ericsson.se","threadId":"32812","inReplyTo":null,"subject":"[PATCH] Handle path completion and colon for tcsh script","fromName":"Marc Khouzam","fromEmail":"marc.khouzam@ericsson.com","sentAt":"2013-02-02T19:43:25Z","receivedAt":"2013-02-02T19:43:25Z","isPatch":true,"sender":{"key":"marc.khouzam@ericsson.com","avatar":"https://gravatar.com/avatar/de564e23ad14e2945f9f1cdb4d0227c935b5b54c39576a304d47caa3e23dcd33?d=mp&s=160"},"body":"Recent enhancements to git-completion.bash provide\nintelligent path completion for git commands.  Such\ncompletions do not add the '/' at the end of directories\nfor recent versions of bash.  However, the '/' is needed\nby tcsh, so we must tell the bash script to append it\nby using a compatibility method available for older\nbash versions.\n\nAlso, tcsh does not handle the colon as a completion\nseparator so we remove it from the list of separators.\n\nSigned-off-by: Marc Khouzam <marc.khouzam@ericsson.com>\n---\nHi,\n\nHere is the update for tcsh completion which is needed to handle\nthe cool new path completion feature just pushed to 'next'.\n\nAlso, Manlio reported that tcsh completion was broken when using\nthe colon, and this patch fixes the issue.\n\nI haven't quite figured out the process to indicate which branch\na patch is meant for.  Do I just mention it in the email?  Or are all \npatches meant for the 'pu' branch?  In this case, 'pu' or 'next'\nwould be appropriate.\n\nThanks!\n\nMarc\n\n contrib/completion/git-completion.tcsh | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.tcsh b/contrib/completion/git-completion.tcsh\nindex 3e3889f..eaacaf0 100644\n--- a/contrib/completion/git-completion.tcsh\n+++ b/contrib/completion/git-completion.tcsh\n@@ -52,6 +52,18 @@ cat << EOF > ${__git_tcsh_completion_script}\n \n source ${__git_tcsh_completion_original_script}\n \n+# Remove the colon as a completion separator because tcsh cannot handle it\n+COMP_WORDBREAKS=\\${COMP_WORDBREAKS//:}\n+\n+# For file completion, tcsh needs the '/' to be appended to directories.\n+# By default, the bash script does not do that.\n+# We can achieve this by using the below compatibility\n+# method of the git-completion.bash script.\n+__git_index_file_list_filter ()\n+{\n+\t__git_index_file_list_filter_compat\n+}\n+\n # Set COMP_WORDS in a way that can be handled by the bash script.\n COMP_WORDS=(\\$2)\n \n-- \n1.8.1.367.g8e14972.dirty\n"},{"id":"208526","messageId":"7vboc2bhpj.fsf@alter.siamese.dyndns.org","threadId":"32812","inReplyTo":"E59706EF8DB1D147B15BECA3322E4BDC09AA38@eusaamb103.ericsson.se","subject":"Re: [PATCH] Handle path completion and colon for tcsh script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-02T20:10:00Z","receivedAt":"2013-02-02T20:10:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marc Khouzam <marc.khouzam@ericsson.com> writes:\n\n> Recent enhancements to git-completion.bash provide\n> intelligent path completion for git commands.  Such\n> completions do not add the '/' at the end of directories\n> for recent versions of bash.\n> ...\n> Here is the update for tcsh completion which is needed to handle\n> the cool new path completion feature just pushed to 'next'.\n>\n> Also, Manlio reported that tcsh completion was broken when using\n> the colon, and this patch fixes the issue.\n>\n> I haven't quite figured out the process to indicate which branch\n> a patch is meant for.  Do I just mention it in the email?\n\nYes, instead of wondering \"Do I mention it here?\", saying \"This\nshould come on top of Manlio's completion update.\" is good.\n\nBut I have to wonder if this is sweeping a problem under the rug.\nShouldn't the completion for bash users end completed directory name\nwith '/', even if we didn't have to worry about tcsh?\n"},{"id":"208561","messageId":"510EC1A4.4000207@gmail.com","threadId":"32812","inReplyTo":"7vboc2bhpj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Handle path completion and colon for tcsh script","fromName":"Manlio Perillo","fromEmail":"manlio.perillo@gmail.com","sentAt":"2013-02-03T19:59:32Z","receivedAt":"2013-02-03T19:59:32Z","isPatch":true,"sender":{"key":"manlio.perillo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6217088?v=4"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nIl 02/02/2013 21:10, Junio C Hamano ha scritto:\n> Marc Khouzam <marc.khouzam@ericsson.com> writes:\n> \n>> Recent enhancements to git-completion.bash provide\n>> intelligent path completion for git commands.  Such\n>> completions do not add the '/' at the end of directories\n>> for recent versions of bash.\n>> ...\n>> Here is the update for tcsh completion which is needed to handle\n>> the cool new path completion feature just pushed to 'next'.\n>>\n> [...]\n> But I have to wonder if this is sweeping a problem under the rug.\n> Shouldn't the completion for bash users end completed directory name\n> with '/', even if we didn't have to worry about tcsh?\n> \n\nThe problem is that when using the \"new\"\n`compopt -o filenames` command, Bash assumes COMPREPLY contains a list\nof filenames, and when it detects a directory name, it adds a slash.\n\nThe problem is, if the directory name *already* has a slash, Bash adds\nanother slash!\n\nI don't know if this can be considered a bug or a feature.\n\n\nRegards  Manlio\n\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\nComment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\n\niEYEARECAAYFAlEOwaQACgkQscQJ24LbaUSjwgCfbgb1id5DcNG0Q75FWwgNPCqb\nqkUAnAmMzCahB745/BWeDJTHbJFXucxs\n=vf+P\n-----END PGP SIGNATURE-----\n"},{"id":"208565","messageId":"7vhalt86wj.fsf@alter.siamese.dyndns.org","threadId":"32812","inReplyTo":"510EC1A4.4000207@gmail.com","subject":"Re: [PATCH] Handle path completion and colon for tcsh script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-03T20:43:56Z","receivedAt":"2013-02-03T20:43:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Manlio Perillo <manlio.perillo@gmail.com> writes:\n\n> The problem is that when using the \"new\"\n> `compopt -o filenames` command, Bash assumes COMPREPLY contains a list\n> of filenames, and when it detects a directory name, it adds a slash.\n>\n> The problem is, if the directory name *already* has a slash, Bash adds\n> another slash!\n\nSo bash users do see the trailing slash because bash adds one to\nwhat we compute and return, which we do strip the trailing slash\nexactly because we know bash will add one.  Because tcsh completion\nuses what we compute directly, without bash massaging our output to\nadd the trailing slash, it needs some magic.\n\nOK, that makes sense.  It was this part from the originally proposed\nlog message:\n\n>> ... Such completions do not add the '/' at the end of directories\n>> for recent versions of bash.  However, the '/' is needed by tcsh,\n>> ...\n\nwith a large gap between the two sentences that fooled me, and the\nexplanation in your message helped to fill the gap to understand the\nsituation better.\n\nPerhaps\n\n\t... for recent versions of bash, which will then add the\n\ttrailing slash for paths that are directory to the result of\n\tour completion.  The completion for tcsh however uses the\n\tresult of our completion directly, so it either needs to add\n\tthe necessary slash itself, or needs to ask us to keep the\n\ttrailiing slash.  This patch does the latter.\n\nor something?\n"},{"id":"208581","messageId":"E59706EF8DB1D147B15BECA3322E4BDC09B5A4@eusaamb103.ericsson.se","threadId":"32812","inReplyTo":"7vhalt86wj.fsf@alter.siamese.dyndns.org","subject":"RE: [PATCH] Handle path completion and colon for tcsh script","fromName":"Marc Khouzam","fromEmail":"marc.khouzam@ericsson.com","sentAt":"2013-02-04T02:50:58Z","receivedAt":"2013-02-04T02:50:58Z","isPatch":true,"sender":{"key":"marc.khouzam@ericsson.com","avatar":"https://gravatar.com/avatar/de564e23ad14e2945f9f1cdb4d0227c935b5b54c39576a304d47caa3e23dcd33?d=mp&s=160"},"body":"> > The problem is, if the directory name *already* has a slash, Bash adds\n> > another slash!\n> \n> So bash users do see the trailing slash because bash adds one to\n> what we compute and return, which we do strip the trailing slash\n> exactly because we know bash will add one.  \n\nThe problem is slightly more obscure than that, and I wonder if it\nshould be documented somewhere in the bash script?\nManlio explained in a previous\nexchange with me, that bash will properly deal with an existing\ntrailing slash when doing the completion on the command-line, but\nwill screw it up by adding a second slash when dealing with multiple\npossible completions and printing those for the user to choose from.\n\nFor example:\n\n$ git status\n# On branch tcsh_next\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       fish/\n#       fishing/\nnothing added to commit but untracked files present (use \"git add\" to track)\n\n$ git add fish<tab>\nfish//    fishing//            <-------- notice the double slashes\n\n$ git add fishi<tab>\n\n# will complete the command line properly to the below, with a single slash.\n\n$ git add fishing/\n\n\n\n> Because tcsh completion\n> uses what we compute directly, without bash massaging our output to\n> add the trailing slash, it needs some magic.\n\nYes, that is right.\n\n> OK, that makes sense.  It was this part from the originally proposed\n> log message:\n> \n> >> ... Such completions do not add the '/' at the end of directories\n> >> for recent versions of bash.  However, the '/' is needed by tcsh,\n> >> ...\n> \n> with a large gap between the two sentences that fooled me, and the\n> explanation in your message helped to fill the gap to understand the\n> situation better.\n\nSorry about the lack of details.\nI'm see more and more the importance of these commit messages :)\n\n> Perhaps\n> \n>         ... for recent versions of bash, which will then add the\n>         trailing slash for paths that are directory to the result of\n>         our completion.  The completion for tcsh however uses the\n>         result of our completion directly, so it either needs to add\n>         the necessary slash itself, or needs to ask us to keep the\n>         trailiing slash.  This patch does the latter.\n> \n> or something?\n\nHow about the following, which gives a little more detail about\nthe solution for tcsh?  I think it is worth putting the below extra\ndetails because I feel a mistake could easily be made about this\ntrailing slash issue, which I had gotten wrong for my own version\nof the script for a couple of weeks, before figuring out the mistake.\n\n\n    Handle path completion and colon for tcsh script\n    \n    Recent enhancements to git-completion.bash provide\n    intelligent path completion for git commands.  Such\n    completions do not provide the '/' at the end of directories\n    for recent versions of bash; instead, bash itself will add the\n    trailing slash to directories to the result provided by \n    git-completion.bash.  However, the completion for tcsh uses\n    the result of the bash completion script directly, so it either \n    needs to add the necessary slash itself, or needs to ask the\n    bash script to keep the trailing slash.  Adding the slash itself\n    is difficult because we cannot easily tell if an entry of the \n    output of the bash script is a directory or something else.\n    For example, assuming there is a directory named 'commit'\n    in the current directory, then, when completing\n      git add commit<tab>\n    we would need to add a slash, but for\n      git help commit<tab>\n    we should not.\n    Figuring out such differences would require adding much\n    intelligence to the tcsh completion script.  Instead, it is \n    simpler to ask the bash script to keep the trailing slash.\n    This patch does this.\n    \n    Also, tcsh does not handle the colon as a completion\n    separator so we remove it from the list of separators.\n    \n    Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>\n\nThanks\n\nMarc\n"},{"id":"208582","messageId":"7vehgw7pd6.fsf@alter.siamese.dyndns.org","threadId":"32812","inReplyTo":"E59706EF8DB1D147B15BECA3322E4BDC09B5A4@eusaamb103.ericsson.se","subject":"Re: [PATCH] Handle path completion and colon for tcsh script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-04T03:02:45Z","receivedAt":"2013-02-04T03:02:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for a detailed explanation.  The two examples illustrating\ndifferent interpretation of the same word were really good.\n\nWill replace and requeue.\n"}]}