Skip to content

Commit

Permalink
completion: handle path completion and colon for tcsh script
Browse files Browse the repository at this point in the history
Recent enhancements to git-completion.bash provide intelligent path
completion for git commands.  Such completions do not provide the
'/' at the end of directories for recent versions of bash; instead,
bash itself will add the trailing slash to directories to the result
provided by git-completion.bash.  However, the completion for tcsh
uses the result of the bash completion script directly, so it either
needs to add the necessary slash itself, or needs to ask the bash
script to keep the trailing slash.

Adding the slash itself is difficult because we have to check the
each path in the output of the bash script to see if it is meant to
be a directory or something else.  For example, assuming there is a
directory named 'commit' in the current directory, then, when
completing

  git add commit<tab>

we would need to add a slash, but for

  git help commit<tab>

we should not.

Figuring out such differences would require adding much intelligence
to the tcsh completion script.  Instead, it is simpler to ask the
bash script to keep the trailing slash.  This patch does this.

Also, tcsh does not handle the colon as a completion separator so we
remove it from the list of separators.

Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
  • Loading branch information
Marc Khouzam authored and Junio C Hamano committed Feb 4, 2013
1 parent fea16b4 commit c6929ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions contrib/completion/git-completion.tcsh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ cat << EOF > ${__git_tcsh_completion_script}
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)
Expand Down

0 comments on commit c6929ff

Please sign in to comment.