{"thread":{"id":"32207","subject":"[PATCH] Support for git aliasing for tcsh completion","startedAt":"2012-11-27T04:13:41Z","lastAt":"2012-11-28T01:56:49Z","messageCount":4,"participants":["Marc Khouzam","Junio C Hamano","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"203964","messageId":"CAFj1UpE5V5fKtt0fFOXLPrsQdOL8xpvzT=66Qi3=cMHit092Rg@mail.gmail.com","threadId":"32207","inReplyTo":"1353989472-4142-1-git-send-email-marc.khouzam@gmail.com","subject":"[PATCH] Support for git aliasing for tcsh completion","fromName":"Marc Khouzam","fromEmail":"marc.khouzam@gmail.com","sentAt":"2012-11-27T04:13:41Z","receivedAt":"2012-11-27T04:13:41Z","isPatch":true,"sender":{"key":"marc.khouzam@ericsson.com","avatar":"https://gravatar.com/avatar/de564e23ad14e2945f9f1cdb4d0227c935b5b54c39576a304d47caa3e23dcd33?d=mp&s=160"},"body":"tcsh users sometimes alias the 'git' command to another name.  In\nthis case, the user expects to only have to issue a new 'complete'\ncommand using the alias name.\n\nHowever, the tcsh script currently uses the command typed by the\nuser to call the appropriate function in git-completion.bash, either\n_git() or _gitk().  When using an alias, this technique no longer\nworks.\n\nThis change specifies the real name of the command (either 'git' or\n'gitk') as a parameter to the script handling tcsh completion.  This\nallows the user to use any alias for the 'git' or 'gitk' commands,\nwhile still getting completion to work.\n\nA check for the presence of ${HOME}/.git-completion.bash is also\nadded to help the user make use of the script properly.\n\nSigned-off-by: Marc Khouzam <marc.khouzam@gmail.com>\n---\n\nThis issue was reported by someone already making use of the tcsh\ncompletion script.\n\nThanks for considering this fix.\n\nMarc\n\n contrib/completion/git-completion.tcsh | 19 ++++++++++++-------\n 1 file changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.tcsh\nb/contrib/completion/git-completion.tcsh\nindex dc5678c..44bd544 100644\n--- a/contrib/completion/git-completion.tcsh\n+++ b/contrib/completion/git-completion.tcsh\n@@ -23,6 +23,12 @@\n set __git_tcsh_completion_original_script = ${HOME}/.git-completion.bash\n set __git_tcsh_completion_script = ${HOME}/.git-completion.tcsh.bash\n\n+# Check that the user put the script in the right place\n+if ( ! -e ${__git_tcsh_completion_original_script} ) then\n+       echo \"git-completion.tcsh: Cannot find:\n${__git_tcsh_completion_original_script}.  Git completion will not work.\"\n+       exit\n+endif\n+\n cat << EOF > ${__git_tcsh_completion_script}\n #!bash\n #\n@@ -34,13 +40,13 @@ cat << EOF > ${__git_tcsh_completion_script}\n source ${__git_tcsh_completion_original_script}\n\n # Set COMP_WORDS in a way that can be handled by the bash script.\n-COMP_WORDS=(\\$1)\n+COMP_WORDS=(\\$2)\n\n # The cursor is at the end of parameter #1.\n # We must check for a space as the last character which will\n # tell us that the previous word is complete and the cursor\n # is on the next word.\n-if [ \"\\${1: -1}\" == \" \" ]; then\n+if [ \"\\${2: -1}\" == \" \" ]; then\n        # The last character is a space, so our location is at the end\n        # of the command-line array\n        COMP_CWORD=\\${#COMP_WORDS[@]}\n@@ -51,13 +57,12 @@ else\n        COMP_CWORD=\\$((\\${#COMP_WORDS[@]}-1))\n fi\n\n-# Call _git() or _gitk() of the bash script, based on the first\n-# element of the command-line\n-_\\${COMP_WORDS[0]}\n+# Call _git() or _gitk() of the bash script, based on the first argument\n+_\\${1}\n\n IFS=\\$'\\n'\n echo \"\\${COMPREPLY[*]}\" | sort | uniq\n EOF\n\n-complete git  'p/*/`bash ${__git_tcsh_completion_script}\n\"${COMMAND_LINE}\"`/'\n-complete gitk 'p/*/`bash ${__git_tcsh_completion_script}\n\"${COMMAND_LINE}\"`/'\n+complete git  'p/*/`bash ${__git_tcsh_completion_script} git\n\"${COMMAND_LINE}\"`/'\n+complete gitk 'p/*/`bash ${__git_tcsh_completion_script} gitk\n\"${COMMAND_LINE}\"`/'\n--\n1.8.0.1.g9fe2839\n"},{"id":"203997","messageId":"7v38zvnez8.fsf@alter.siamese.dyndns.org","threadId":"32207","inReplyTo":"CAFj1UpE5V5fKtt0fFOXLPrsQdOL8xpvzT=66Qi3=cMHit092Rg@mail.gmail.com","subject":"Re: [PATCH] Support for git aliasing for tcsh completion","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-27T17:16:27Z","receivedAt":"2012-11-27T17:16:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The patch was linewrapped so I had to fix it up; please double check\nwhat will be queued on 'pu' to make sure that I did not miss\nnecessary whitespaces or added unnecessary ones when I rejoined long\nlines.\n\nThanks.\n"},{"id":"204088","messageId":"CAFj1UpGipsewPRiumtuit5FKU2-CGMp3zgh48E3wdj=g4FWAOQ@mail.gmail.com","threadId":"32207","inReplyTo":"7v38zvnez8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Support for git aliasing for tcsh completion","fromName":"Marc Khouzam","fromEmail":"marc.khouzam@gmail.com","sentAt":"2012-11-28T01:39:43Z","receivedAt":"2012-11-28T01:39:43Z","isPatch":true,"sender":{"key":"marc.khouzam@ericsson.com","avatar":"https://gravatar.com/avatar/de564e23ad14e2945f9f1cdb4d0227c935b5b54c39576a304d47caa3e23dcd33?d=mp&s=160"},"body":"On Tue, Nov 27, 2012 at 12:16 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> The patch was linewrapped so I had to fix it up;\n\nSorry about that.  I don't know if it is gmail, or the fact that I use\nits web interface\nthat causes these problems.\n\n> please double check\n> what will be queued on 'pu' to make sure that I did not miss\n> necessary whitespaces or added unnecessary ones when I rejoined long\n> lines.\n\nI just checked it and it looks great.\n\nI'm working on another improvement to the script but I don't have it working\nyet.  But I should not bother you much after that.\n\nThanks again!\n\nMarc\n"},{"id":"204093","messageId":"CAMP44s1FTn==aK9i9G_N=DOv-F6CmrQ6KJEYvuRijSsByMb8wQ@mail.gmail.com","threadId":"32207","inReplyTo":"CAFj1UpGipsewPRiumtuit5FKU2-CGMp3zgh48E3wdj=g4FWAOQ@mail.gmail.com","subject":"Re: [PATCH] Support for git aliasing for tcsh completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-28T01:56:49Z","receivedAt":"2012-11-28T01:56:49Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Nov 28, 2012 at 2:39 AM, Marc Khouzam <marc.khouzam@gmail.com> wrote:\n> On Tue, Nov 27, 2012 at 12:16 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> The patch was linewrapped so I had to fix it up;\n>\n> Sorry about that.  I don't know if it is gmail, or the fact that I use\n> its web interface\n> that causes these problems.\n>\n>> please double check\n>> what will be queued on 'pu' to make sure that I did not miss\n>> necessary whitespaces or added unnecessary ones when I rejoined long\n>> lines.\n>\n> I just checked it and it looks great.\n>\n> I'm working on another improvement to the script but I don't have it working\n> yet.  But I should not bother you much after that.\n\nYou might want to use msmtp to send mails with Gmail, that's what I do:\nhttps://git.wiki.kernel.org/index.php/GitTips#Using_msmtp_to_send_your_patches\n\n-- \nFelipe Contreras\n"}]}