summaryrefslogtreecommitdiff
path: root/contrib/completion/git-completion.tcsh
AgeCommit message (Collapse)Author
2015-06-09git-completion.tcsh: fix redirect with noclobberAriel Faigon
tcsh users who happen to have 'set noclobber' elsewhere in their ~/.tcshrc or ~/.cshrc startup files get a 'File exist' error, and the tcsh completion file doesn't get generated/updated. Adding a `!` in the redirect works correctly for both clobber (default) and 'set noclobber' users. Reviewed-by: Christian Couder <christian.couder@gmail.com> Signed-off-by: Ariel Faigon <github.2009@yendor.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-26remove #!interpreter line from shell librariesJonathan Nieder
In a shell snippet meant to be sourced by other shell scripts, an opening #! line does more harm than good. The harm: - When the shell library is sourced, the interpreter and options from the #! line are not used. Specifying a particular shell can confuse the reader into thinking it is safe for the shell library to rely on idiosyncrasies of that shell. - Using #! instead of a plain comment drops a helpful visual clue that this is a shell library and not a self-contained script. - Tools such as lintian can use a #! line to tell when an installation script has failed by forgetting to set a script executable. This check does not work if shell libraries also start with a #! line. The good: - Text editors notice the #! line and use it for syntax highlighting if you try to edit the installed scripts (without ".sh" suffix) in place. The use of the #! for file type detection is not needed because Git's shell libraries are meant to be edited in source form (with ".sh" suffix). Replace the opening #! lines with comments. This involves tweaking the test harness's valgrind support to find shell libraries by looking for "# " in the first line instead of "#!" (see v1.7.6-rc3~7, 2011-06-17). Suggested by Russ Allbery through lintian. Thanks to Jeff King and Clemens Buchacher for further analysis. Tested by searching for non-executable scripts with #! line: find . -name .git -prune -o -type f -not -executable | while read file do read line <"$file" case $line in '#!'*) echo "$file" ;; esac done The only remaining scripts found are templates for shell scripts (unimplemented.sh, wrap-for-bin.sh) and sample input used in tests (t/t4034/perl/{pre,post}). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-08Merge branch 'mk/tcsh-complete-only-known-paths'Junio C Hamano
The "complete with known paths only" update to completion scripts returns directory names without trailing slash to compensate the addition of '/' done by bash that reads from our completion result. tcsh completion code that reads from our internal completion result does not add '/', so let it ask our complletion code to keep the '/' at the end. * mk/tcsh-complete-only-known-paths: completion: handle path completion and colon for tcsh script
2013-02-04completion: handle path completion and colon for tcsh scriptMarc Khouzam
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>
2013-01-07Prevent space after directories in tcsh completionMarc Khouzam
If git-completion.bash returns a single directory as a completion, tcsh will automatically add a space after it, which is not what the user wants. This commit prevents tcsh from doing this. Also, a check is added to make sure the tcsh version used is recent enough to allow completion to work as expected. Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-12Add file completion to tcsh git completion.Marc Khouzam
For bash completion, the option '-o bashdefault' is used to indicate that when no other choices are available, file completion should be performed. Since this option is not available in tcsh, no file completion is ever performed. Therefore, commands like 'git add ', 'git send-email ', etc, require the user to manually type out the file name. This can be quite annoying. To improve the user experience we try to simulate file completion directly in this script (although not perfectly). The known issues with the file completion simulation are: - Possible completions are shown with their directory prefix. - Completions containing shell variables are not handled. - Completions with ~ as the first character are not handled. Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-27Support for git aliasing for tcsh completionMarc Khouzam
tcsh users sometimes alias the 'git' command to another name. In this case, the user expects to only have to issue a new 'complete' command using the alias name. However, the tcsh script currently uses the command typed by the user to call the appropriate function in git-completion.bash, either _git() or _gitk(). When using an alias, this technique no longer works. This change specifies the real name of the command (either 'git' or 'gitk') as a parameter to the script handling tcsh completion. This allows the user to use any alias for the 'git' or 'gitk' commands, while still getting completion to work. A check for the presence of ${HOME}/.git-completion.bash is also added to help the user make use of the script properly. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-16tcsh-completion re-using git-completion.bashMarc Khouzam
The current tcsh-completion support for Git, as can be found on the Internet, takes the approach of defining the possible completions explicitly. This has the obvious draw-back to require constant updating as the Git code base evolves. The approach taken by this commit is to to re-use the advanced bash completion script and use its result for tcsh completion. This is achieved by sourcing the bash script and outputting the completion result for tcsh consumption. Three solutions were looked at to implement this approach with (C) being retained: A) Modifications: git-completion.bash and new git-completion.tcsh Modify the existing git-completion.bash script to support being sourced using bash (as now), but also executed using bash. When being executed, the script will output the result of the computed completion to be re-used elsewhere (e.g., in tcsh). The modification to git-completion.bash is made not to be tcsh-specific, but to allow future users to also re-use its output. Therefore, to be general, git-completion.bash accepts a second optional parameter, which is not used by tcsh, but could prove useful for other users. Pros: 1- allows the git-completion.bash script to easily be re-used 2- tcsh support is mostly isolated in git-completion.tcsh Cons (for tcsh users only): 1- requires the user to copy both git-completion.tcsh and git-completion.bash to ${HOME} 2- requires bash script to have a fixed name and location: ${HOME}/.git-completion.bash B) Modifications: git-completion.bash Modify the existing git-completion.bash script to support being sourced using bash (as now), but also executed using bash, and sourced using tcsh. Pros: 1- only requires the user to deal with a single file 2- maintenance more obvious for tcsh since it is entirely part of the same git-completion.bash script. Cons: 1- tcsh support could affect bash support as they share the same script 2- small tcsh section must use syntax suitable for both tcsh and bash and must be at the beginning of the script 3- requires script to have a fixed name and location: ${HOME}/.git-completion.sh (for tcsh users only) C) Modifications: New git-completion.tcsh Provide a short tcsh script that generates another script which extends git-completion.bash. This new script can be used by tcsh to perform completion. Pros: 1- tcsh support is entirely isolated in git-completion.tcsh 2- new tcsh script can be as complex as needed Cons (for tcsh users only): 1- requires the user to copy both git-completion.tcsh and git-completion.bash to ${HOME} 2- requires bash script to have a fixed name and location: ${HOME}/.git-completion.bash 3- sourcing the new script will generate a third script Approach (C) was selected avoid any modification to git-completion.bash. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com> Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>