{"thread":{"id":"39150","subject":"[PATCH] Completion: Cleanup tcsh script and add debug flag","startedAt":"2015-04-24T01:07:28Z","lastAt":"2015-05-29T19:37:18Z","messageCount":2,"participants":["Marc Khouzam","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"259923","messageId":"CAFj1UpGpGS-C2EWif4sk_ijq8PjpM1UY09+vLwbjX17idZdkfA@mail.gmail.com","threadId":"39150","inReplyTo":null,"subject":"[PATCH] Completion: Cleanup tcsh script and add debug flag","fromName":"Marc Khouzam","fromEmail":"marc.khouzam@gmail.com","sentAt":"2015-04-24T01:07:28Z","receivedAt":"2015-04-24T01:07:28Z","isPatch":true,"sender":{"key":"marc.khouzam@ericsson.com","avatar":"https://gravatar.com/avatar/de564e23ad14e2945f9f1cdb4d0227c935b5b54c39576a304d47caa3e23dcd33?d=mp&s=160"},"body":"Remove overriding of __git_index_file_list_filter\nsince that method is no longer used in git-completion.bash.\nOverriding that method was needed before to get\ngit-completion.bash to append a '/' to the end\nof directories; this does not seem to be needed anymore since\nthat script no longer provides completions of directories/files.\n\nAlso add -d/--debug flag support to help troubleshoot\nthe script.\n\nSigned-off-by: Marc Khouzam <marc.khouzam@gmail.com>\n---\n\nI thought this would help when for people that experience issues with\nthe script.\n\nThanks!\n\nMarc\n\n contrib/completion/git-completion.tcsh |   50 +++++++++++++++++++++++++-------\n 1 file changed, 40 insertions(+), 10 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.tcsh\nb/contrib/completion/git-completion.tcsh\nindex 6104a42..fd0b906 100644\n--- a/contrib/completion/git-completion.tcsh\n+++ b/contrib/completion/git-completion.tcsh\n@@ -1,6 +1,6 @@\n # tcsh completion support for core Git.\n #\n-# Copyright (C) 2012 Marc Khouzam <marc.khouzam@gmail.com>\n+# Copyright (C) 2012, 2015 Marc Khouzam <marc.khouzam@gmail.com>\n # Distributed under the GNU General Public License, version 2.0.\n #\n # When sourced, this script will generate a new script that uses\n@@ -22,6 +22,25 @@\n #       add the following line to your .tcshrc/.cshrc:\n #        set autolist=ambiguous\n #       It will tell tcsh to list the possible completion choices.\n+#\n+# To debug this script one can use the -d flag by running the\n+# generated final script directly.  For example, to see the completions\n+# generated when pressing <tab> for the command line:\n+#     git co\n+# one should run:\n+#     bash ~/.git-completion.tcsh.bash -d git 'git co'\n+# and will obtain:\n+#     =====================================\n+#     git-completion.bash returned:\n+#     commit  config\n+#     =====================================\n+#     Completions including tcsh additions:\n+#     commit  config\n+#     =====================================\n+#     Final completions returned:\n+#     commit\n+#     config\n+#\n\n set __git_tcsh_completion_version = `\\echo ${tcsh} | \\sed 's/\\./ /g'`\n if ( ${__git_tcsh_completion_version[1]} < 6 || \\\n@@ -48,20 +67,17 @@ cat << EOF > ${__git_tcsh_completion_script}\n # Do not modify it directly.  Instead, modify git-completion.tcsh\n # and source it again.\n\n+# Allow for debug printouts when running the script by hand\n+if [ \"\\$1\" == \"-d\" ] || [ \"\\$1\" == \"--debug\" ]; then\n+       __git_tcsh_debug=true\n+       shift\n+fi\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-       __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@@ -83,6 +99,12 @@ fi\n # Call _git() or _gitk() of the bash script, based on the first argument\n _\\${1}\n\n+if [ \"\\$__git_tcsh_debug\" == \"true\" ]; then\n+       echo =====================================\n+       echo git-completion.bash returned:\n+       echo \"\\${COMPREPLY[@]}\"\n+fi\n+\n IFS=\\$'\\n'\n if [ \\${#COMPREPLY[*]} -eq 0 ]; then\n        # No completions suggested.  In this case, we want tcsh to perform\n@@ -108,6 +130,14 @@ if [ \\${#COMPREPLY[*]} -eq 0 ]; then\n        fi\n fi\n\n+if [ \"\\$__git_tcsh_debug\" == \"true\" ]; then\n+       echo =====================================\n+       echo Completions including tcsh additions:\n+       echo \"\\${COMPREPLY[@]}\"\n+       echo =====================================\n+       echo Final completions returned:\n+fi\n+\n # tcsh does not automatically remove duplicates, so we do it ourselves\n echo \"\\${COMPREPLY[*]}\" | sort | uniq\n"},{"id":"262447","messageId":"xmqqd21jch01.fsf@gitster.dls.corp.google.com","threadId":"39150","inReplyTo":"CAFj1UpGpGS-C2EWif4sk_ijq8PjpM1UY09+vLwbjX17idZdkfA@mail.gmail.com","subject":"Re: [PATCH] Completion: Cleanup tcsh script and add debug flag","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-29T19:37:18Z","receivedAt":"2015-05-29T19:37:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marc Khouzam <marc.khouzam@gmail.com> writes:\n\n> Remove overriding of __git_index_file_list_filter\n> since that method is no longer used in git-completion.bash.\n> Overriding that method was needed before to get\n> git-completion.bash to append a '/' to the end\n> of directories; this does not seem to be needed anymore since\n> that script no longer provides completions of directories/files.\n>\n> Also add -d/--debug flag support to help troubleshoot\n> the script.\n>\n> Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>\n> ---\n>\n> I thought this would help when for people that experience issues with\n> the script.\n\nThanks; unfortunately what I received suffers from serious\nwhitespace damages.  All the tabs in preimage seem to have been\ncorrupted into runs of whitespaces, and I suspect the same for tabs\nin the new lines, too.\n\n>\n> Thanks!\n>\n> Marc\n>\n>  contrib/completion/git-completion.tcsh |   50 +++++++++++++++++++++++++-------\n>  1 file changed, 40 insertions(+), 10 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.tcsh\n> b/contrib/completion/git-completion.tcsh\n> index 6104a42..fd0b906 100644\n> --- a/contrib/completion/git-completion.tcsh\n> +++ b/contrib/completion/git-completion.tcsh\n> @@ -1,6 +1,6 @@\n>  # tcsh completion support for core Git.\n>  #\n> -# Copyright (C) 2012 Marc Khouzam <marc.khouzam@gmail.com>\n> +# Copyright (C) 2012, 2015 Marc Khouzam <marc.khouzam@gmail.com>\n>  # Distributed under the GNU General Public License, version 2.0.\n>  #\n>  # When sourced, this script will generate a new script that uses\n> @@ -22,6 +22,25 @@\n>  #       add the following line to your .tcshrc/.cshrc:\n>  #        set autolist=ambiguous\n>  #       It will tell tcsh to list the possible completion choices.\n> +#\n> +# To debug this script one can use the -d flag by running the\n> +# generated final script directly.  For example, to see the completions\n> +# generated when pressing <tab> for the command line:\n> +#     git co\n> +# one should run:\n> +#     bash ~/.git-completion.tcsh.bash -d git 'git co'\n> +# and will obtain:\n> +#     =====================================\n> +#     git-completion.bash returned:\n> +#     commit  config\n> +#     =====================================\n> +#     Completions including tcsh additions:\n> +#     commit  config\n> +#     =====================================\n> +#     Final completions returned:\n> +#     commit\n> +#     config\n> +#\n>\n>  set __git_tcsh_completion_version = `\\echo ${tcsh} | \\sed 's/\\./ /g'`\n>  if ( ${__git_tcsh_completion_version[1]} < 6 || \\\n> @@ -48,20 +67,17 @@ cat << EOF > ${__git_tcsh_completion_script}\n>  # Do not modify it directly.  Instead, modify git-completion.tcsh\n>  # and source it again.\n>\n> +# Allow for debug printouts when running the script by hand\n> +if [ \"\\$1\" == \"-d\" ] || [ \"\\$1\" == \"--debug\" ]; then\n> +       __git_tcsh_debug=true\n> +       shift\n> +fi\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> -       __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> @@ -83,6 +99,12 @@ fi\n>  # Call _git() or _gitk() of the bash script, based on the first argument\n>  _\\${1}\n>\n> +if [ \"\\$__git_tcsh_debug\" == \"true\" ]; then\n> +       echo =====================================\n> +       echo git-completion.bash returned:\n> +       echo \"\\${COMPREPLY[@]}\"\n> +fi\n> +\n>  IFS=\\$'\\n'\n>  if [ \\${#COMPREPLY[*]} -eq 0 ]; then\n>         # No completions suggested.  In this case, we want tcsh to perform\n> @@ -108,6 +130,14 @@ if [ \\${#COMPREPLY[*]} -eq 0 ]; then\n>         fi\n>  fi\n>\n> +if [ \"\\$__git_tcsh_debug\" == \"true\" ]; then\n> +       echo =====================================\n> +       echo Completions including tcsh additions:\n> +       echo \"\\${COMPREPLY[@]}\"\n> +       echo =====================================\n> +       echo Final completions returned:\n> +fi\n> +\n>  # tcsh does not automatically remove duplicates, so we do it ourselves\n>  echo \"\\${COMPREPLY[*]}\" | sort | uniq\n"}]}