git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Completion: Cleanup tcsh script and add debug flag
@ 2015-04-24  1:07 Marc Khouzam
  2015-05-29 19:37 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Khouzam @ 2015-04-24  1:07 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor

Remove overriding of __git_index_file_list_filter
since that method is no longer used in git-completion.bash.
Overriding that method was needed before to get
git-completion.bash to append a '/' to the end
of directories; this does not seem to be needed anymore since
that script no longer provides completions of directories/files.

Also add -d/--debug flag support to help troubleshoot
the script.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
---

I thought this would help when for people that experience issues with
the script.

Thanks!

Marc

 contrib/completion/git-completion.tcsh |   50 +++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/contrib/completion/git-completion.tcsh
b/contrib/completion/git-completion.tcsh
index 6104a42..fd0b906 100644
--- a/contrib/completion/git-completion.tcsh
+++ b/contrib/completion/git-completion.tcsh
@@ -1,6 +1,6 @@
 # tcsh completion support for core Git.
 #
-# Copyright (C) 2012 Marc Khouzam <marc.khouzam@gmail.com>
+# Copyright (C) 2012, 2015 Marc Khouzam <marc.khouzam@gmail.com>
 # Distributed under the GNU General Public License, version 2.0.
 #
 # When sourced, this script will generate a new script that uses
@@ -22,6 +22,25 @@
 #       add the following line to your .tcshrc/.cshrc:
 #        set autolist=ambiguous
 #       It will tell tcsh to list the possible completion choices.
+#
+# To debug this script one can use the -d flag by running the
+# generated final script directly.  For example, to see the completions
+# generated when pressing <tab> for the command line:
+#     git co
+# one should run:
+#     bash ~/.git-completion.tcsh.bash -d git 'git co'
+# and will obtain:
+#     =====================================
+#     git-completion.bash returned:
+#     commit  config
+#     =====================================
+#     Completions including tcsh additions:
+#     commit  config
+#     =====================================
+#     Final completions returned:
+#     commit
+#     config
+#

 set __git_tcsh_completion_version = `\echo ${tcsh} | \sed 's/\./ /g'`
 if ( ${__git_tcsh_completion_version[1]} < 6 || \
@@ -48,20 +67,17 @@ cat << EOF > ${__git_tcsh_completion_script}
 # Do not modify it directly.  Instead, modify git-completion.tcsh
 # and source it again.

+# Allow for debug printouts when running the script by hand
+if [ "\$1" == "-d" ] || [ "\$1" == "--debug" ]; then
+       __git_tcsh_debug=true
+       shift
+fi
+
 source ${__git_tcsh_completion_original_script}

 # Remove the colon as a completion separator because tcsh cannot handle it
 COMP_WORDBREAKS=\${COMP_WORDBREAKS//:}

-# For file completion, tcsh needs the '/' to be appended to directories.
-# By default, the bash script does not do that.
-# We can achieve this by using the below compatibility
-# method of the git-completion.bash script.
-__git_index_file_list_filter ()
-{
-       __git_index_file_list_filter_compat
-}
-
 # Set COMP_WORDS in a way that can be handled by the bash script.
 COMP_WORDS=(\$2)

@@ -83,6 +99,12 @@ fi
 # Call _git() or _gitk() of the bash script, based on the first argument
 _\${1}

+if [ "\$__git_tcsh_debug" == "true" ]; then
+       echo =====================================
+       echo git-completion.bash returned:
+       echo "\${COMPREPLY[@]}"
+fi
+
 IFS=\$'\n'
 if [ \${#COMPREPLY[*]} -eq 0 ]; then
        # No completions suggested.  In this case, we want tcsh to perform
@@ -108,6 +130,14 @@ if [ \${#COMPREPLY[*]} -eq 0 ]; then
        fi
 fi

+if [ "\$__git_tcsh_debug" == "true" ]; then
+       echo =====================================
+       echo Completions including tcsh additions:
+       echo "\${COMPREPLY[@]}"
+       echo =====================================
+       echo Final completions returned:
+fi
+
 # tcsh does not automatically remove duplicates, so we do it ourselves
 echo "\${COMPREPLY[*]}" | sort | uniq

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Completion: Cleanup tcsh script and add debug flag
  2015-04-24  1:07 [PATCH] Completion: Cleanup tcsh script and add debug flag Marc Khouzam
@ 2015-05-29 19:37 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2015-05-29 19:37 UTC (permalink / raw)
  To: Marc Khouzam; +Cc: git, SZEDER Gábor

Marc Khouzam <marc.khouzam@gmail.com> writes:

> Remove overriding of __git_index_file_list_filter
> since that method is no longer used in git-completion.bash.
> Overriding that method was needed before to get
> git-completion.bash to append a '/' to the end
> of directories; this does not seem to be needed anymore since
> that script no longer provides completions of directories/files.
>
> Also add -d/--debug flag support to help troubleshoot
> the script.
>
> Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
> ---
>
> I thought this would help when for people that experience issues with
> the script.

Thanks; unfortunately what I received suffers from serious
whitespace damages.  All the tabs in preimage seem to have been
corrupted into runs of whitespaces, and I suspect the same for tabs
in the new lines, too.

>
> Thanks!
>
> Marc
>
>  contrib/completion/git-completion.tcsh |   50 +++++++++++++++++++++++++-------
>  1 file changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/contrib/completion/git-completion.tcsh
> b/contrib/completion/git-completion.tcsh
> index 6104a42..fd0b906 100644
> --- a/contrib/completion/git-completion.tcsh
> +++ b/contrib/completion/git-completion.tcsh
> @@ -1,6 +1,6 @@
>  # tcsh completion support for core Git.
>  #
> -# Copyright (C) 2012 Marc Khouzam <marc.khouzam@gmail.com>
> +# Copyright (C) 2012, 2015 Marc Khouzam <marc.khouzam@gmail.com>
>  # Distributed under the GNU General Public License, version 2.0.
>  #
>  # When sourced, this script will generate a new script that uses
> @@ -22,6 +22,25 @@
>  #       add the following line to your .tcshrc/.cshrc:
>  #        set autolist=ambiguous
>  #       It will tell tcsh to list the possible completion choices.
> +#
> +# To debug this script one can use the -d flag by running the
> +# generated final script directly.  For example, to see the completions
> +# generated when pressing <tab> for the command line:
> +#     git co
> +# one should run:
> +#     bash ~/.git-completion.tcsh.bash -d git 'git co'
> +# and will obtain:
> +#     =====================================
> +#     git-completion.bash returned:
> +#     commit  config
> +#     =====================================
> +#     Completions including tcsh additions:
> +#     commit  config
> +#     =====================================
> +#     Final completions returned:
> +#     commit
> +#     config
> +#
>
>  set __git_tcsh_completion_version = `\echo ${tcsh} | \sed 's/\./ /g'`
>  if ( ${__git_tcsh_completion_version[1]} < 6 || \
> @@ -48,20 +67,17 @@ cat << EOF > ${__git_tcsh_completion_script}
>  # Do not modify it directly.  Instead, modify git-completion.tcsh
>  # and source it again.
>
> +# Allow for debug printouts when running the script by hand
> +if [ "\$1" == "-d" ] || [ "\$1" == "--debug" ]; then
> +       __git_tcsh_debug=true
> +       shift
> +fi
> +
>  source ${__git_tcsh_completion_original_script}
>
>  # Remove the colon as a completion separator because tcsh cannot handle it
>  COMP_WORDBREAKS=\${COMP_WORDBREAKS//:}
>
> -# For file completion, tcsh needs the '/' to be appended to directories.
> -# By default, the bash script does not do that.
> -# We can achieve this by using the below compatibility
> -# method of the git-completion.bash script.
> -__git_index_file_list_filter ()
> -{
> -       __git_index_file_list_filter_compat
> -}
> -
>  # Set COMP_WORDS in a way that can be handled by the bash script.
>  COMP_WORDS=(\$2)
>
> @@ -83,6 +99,12 @@ fi
>  # Call _git() or _gitk() of the bash script, based on the first argument
>  _\${1}
>
> +if [ "\$__git_tcsh_debug" == "true" ]; then
> +       echo =====================================
> +       echo git-completion.bash returned:
> +       echo "\${COMPREPLY[@]}"
> +fi
> +
>  IFS=\$'\n'
>  if [ \${#COMPREPLY[*]} -eq 0 ]; then
>         # No completions suggested.  In this case, we want tcsh to perform
> @@ -108,6 +130,14 @@ if [ \${#COMPREPLY[*]} -eq 0 ]; then
>         fi
>  fi
>
> +if [ "\$__git_tcsh_debug" == "true" ]; then
> +       echo =====================================
> +       echo Completions including tcsh additions:
> +       echo "\${COMPREPLY[@]}"
> +       echo =====================================
> +       echo Final completions returned:
> +fi
> +
>  # tcsh does not automatically remove duplicates, so we do it ourselves
>  echo "\${COMPREPLY[*]}" | sort | uniq

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-29 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24  1:07 [PATCH] Completion: Cleanup tcsh script and add debug flag Marc Khouzam
2015-05-29 19:37 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).