{"thread":{"id":"43732","subject":"[PATCH 4/4] Teach bash about git-am/git-apply and their whitespace options.","startedAt":"2006-11-27T20:11:10Z","lastAt":"2006-11-27T20:12:03Z","messageCount":3,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"298057","messageId":"20061127201110.GB7308@spearce.org","threadId":"43732","inReplyTo":"139669072795537547ec26b69115509100dcd7ec.1164658223.git.spearce@spearce.org","subject":"[PATCH 2/4] Teach bash about git-commit's options.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-27T20:11:10Z","receivedAt":"2006-11-27T20:11:10Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Not only can we complete the long options for git-commit, but now we\ncan also complete author strings by looking up all prior author names\nin all branches and offering them up as possible completions.  This\nis similiar to the support used by the --author= option to git-log.\n\nUnfortunately this changes names which use ' within their string.\nIt seems to be bash's fault here, the ' is being passed out by sed\nbut is getting removed during the completion generation.  Fortunately\n' appears in only one name in git.git so the damage is likely to be\nrather low.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |   28 ++++++++++++++++++++++++++++\n 1 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e53f040..d4eb138 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -332,6 +332,32 @@ _git_cherry_pick ()\n \tesac\n }\n \n+_git_commit ()\n+{\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--author=*)\n+\t\tlocal IFS=$'\\n'\n+\t\tcur=\"${cur##--author=}\"\n+\t\tCOMPREPLY=($(compgen -P \\' -S \\' \\\n+\t\t\t-W \"$(git log --pretty=raw --all \\\n+\t\t\t| sed -n -e \"/^author /{\n+\t\t\t\ts/^author //\n+\t\t\t\ts/>.*/>/\n+\t\t\t\tp\n+\t\t\t}\")\" -- \"${cur##\\'}\"))\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\tCOMPREPLY=($(compgen -W \"\n+\t\t\t--all --author=\\' --signoff --verify --no-verify\n+\t\t\t--edit --amend --include --only\n+\t\t\t\" -- \"$cur\"))\n+\t\treturn\n+\tesac\n+\tCOMPREPLY=()\n+}\n+\n _git_diff ()\n {\n \t__git_complete_file\n@@ -720,6 +746,7 @@ _git ()\n \tcat-file)    _git_cat_file ;;\n \tcheckout)    _git_checkout ;;\n \tcherry-pick) _git_cherry_pick ;;\n+\tcommit)      _git_commit ;;\n \tdiff)        _git_diff ;;\n \tdiff-tree)   _git_diff_tree ;;\n \tfetch)       _git_fetch ;;\n@@ -754,6 +781,7 @@ complete -o default            -F _git_branch git-branch\n complete -o default -o nospace -F _git_cat_file git-cat-file\n complete -o default            -F _git_checkout git-checkout\n complete -o default            -F _git_cherry_pick git-cherry-pick\n+complete -o default            -F _git_commit git-commit\n complete -o default -o nospace -F _git_diff git-diff\n complete -o default            -F _git_diff_tree git-diff-tree\n complete -o default -o nospace -F _git_fetch git-fetch\n-- \n1.4.4.1.ge3fb\n"},{"id":"298457","messageId":"20061127201152.GC7308@spearce.org","threadId":"43732","inReplyTo":"139669072795537547ec26b69115509100dcd7ec.1164658223.git.spearce@spearce.org","subject":"[PATCH 3/4] Cache the list of merge strategies and available commands during load.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-27T20:11:52Z","receivedAt":"2006-11-27T20:11:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Since the user's git installation is not likely to grow a new command\nor merge strategy in the lifespan of the current shell process we can\nsave time during completion operations by caching these lists during\nsourcing of the completion support.\n\nIf the git executable is not available or we run into errors while\ncaching at load time then we defer these to runtime and generate\nthe list on the fly.  This might happen if the user doesn't put git\ninto their PATH until after the completion script gets sourced.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n This is by request of Junio.  :-)\n\n contrib/completion/git-completion.bash |   20 +++++++++++++++++++-\n 1 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d4eb138..ba3adb6 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -18,7 +18,13 @@\n #    2) Added the following line to your .bashrc:\n #        source ~/.git-completion.sh\n #\n-#    3) Consider changing your PS1 to also show the current branch:\n+#    3) You may want to make sure the git executable is available\n+#       in your PATH before this script is sourced, as some caching\n+#       is performed while the script loads.  If git isn't found\n+#       at source time then all lookups will be done on demand,\n+#       which may be slightly slower.\n+#\n+#    4) Consider changing your PS1 to also show the current branch:\n #        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n #\n #       The argument to __git_ps1 will be displayed only if you\n@@ -150,6 +156,10 @@ __git_remotes ()\n \n __git_merge_strategies ()\n {\n+\tif [ -n \"$__git_merge_strategylist\" ]; then\n+\t\techo \"$__git_merge_strategylist\"\n+\t\treturn\n+\tfi\n \tsed -n \"/^all_strategies='/{\n \t\ts/^all_strategies='//\n \t\ts/'//\n@@ -157,6 +167,8 @@ __git_merge_strategies ()\n \t\tq\n \t\t}\" \"$(git --exec-path)/git-merge\"\n }\n+__git_merge_strategylist=\n+__git_merge_strategylist=\"$(__git_merge_strategies 2>/dev/null)\"\n \n __git_complete_file ()\n {\n@@ -214,6 +226,10 @@ __git_complete_revlist ()\n \n __git_commands ()\n {\n+\tif [ -n \"$__git_commandlist\" ]; then\n+\t\techo \"$__git_commandlist\"\n+\t\treturn\n+\tfi\n \tlocal i IFS=\" \"$'\\n'\n \tfor i in $(git help -a|egrep '^ ')\n \tdo\n@@ -263,6 +279,8 @@ __git_commands ()\n \t\tesac\n \tdone\n }\n+__git_commandlist=\n+__git_commandlist=\"$(__git_commands 2>/dev/null)\"\n \n __git_aliases ()\n {\n-- \n1.4.4.1.ge3fb\n"},{"id":"297487","messageId":"20061127201203.GD7308@spearce.org","threadId":"43732","inReplyTo":"139669072795537547ec26b69115509100dcd7ec.1164658223.git.spearce@spearce.org","subject":"[PATCH 4/4] Teach bash about git-am/git-apply and their whitespace options.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-27T20:12:03Z","receivedAt":"2006-11-27T20:12:03Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Signed-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |   53 ++++++++++++++++++++++++++++++++\n 1 files changed, 53 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ba3adb6..5b7d9d3 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -307,6 +307,54 @@ __git_aliased_command ()\n \tdone\n }\n \n+__git_whitespacelist=\"nowarn warn error error-all strip\"\n+\n+_git_am ()\n+{\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tif [ -d .dotest ]; then\n+\t\tCOMPREPLY=($(compgen -W \"\n+\t\t\t--skip --resolved\n+\t\t\t\" -- \"$cur\"))\n+\t\treturn\n+\tfi\n+\tcase \"$cur\" in\n+\t--whitespace=*)\n+\t\tCOMPREPLY=($(compgen -W \"$__git_whitespacelist\" \\\n+\t\t\t-- \"${cur##--whitespace=}\"))\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\tCOMPREPLY=($(compgen -W \"\n+\t\t\t--signoff --utf8 --binary --3way --interactive\n+\t\t\t--whitespace=\n+\t\t\t\" -- \"$cur\"))\n+\t\treturn\n+\tesac\n+\tCOMPREPLY=()\n+}\n+\n+_git_apply ()\n+{\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--whitespace=*)\n+\t\tCOMPREPLY=($(compgen -W \"$__git_whitespacelist\" \\\n+\t\t\t-- \"${cur##--whitespace=}\"))\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\tCOMPREPLY=($(compgen -W \"\n+\t\t\t--stat --numstat --summary --check --index\n+\t\t\t--cached --index-info --reverse --reject --unidiff-zero\n+\t\t\t--apply --no-add --exclude=\n+\t\t\t--whitespace= --inaccurate-eof --verbose\n+\t\t\t\" -- \"$cur\"))\n+\t\treturn\n+\tesac\n+\tCOMPREPLY=()\n+}\n+\n _git_branch ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n@@ -760,6 +808,8 @@ _git ()\n \t[ \"$expansion\" ] && command=\"$expansion\"\n \n \tcase \"$command\" in\n+\tam)          _git_am ;;\n+\tapply)       _git_apply ;;\n \tbranch)      _git_branch ;;\n \tcat-file)    _git_cat_file ;;\n \tcheckout)    _git_checkout ;;\n@@ -795,6 +845,8 @@ _gitk ()\n \n complete -o default -o nospace -F _git git\n complete -o default            -F _gitk gitk\n+complete -o default            -F _git_am git-am\n+complete -o default            -F _git_apply git-apply\n complete -o default            -F _git_branch git-branch\n complete -o default -o nospace -F _git_cat_file git-cat-file\n complete -o default            -F _git_checkout git-checkout\n@@ -824,6 +876,7 @@ complete -o default -o nospace -F _git_log git-whatchanged\n # included the '.exe' suffix.\n #\n if [ Cygwin = \"$(uname -o 2>/dev/null)\" ]; then\n+complete -o default            -F _git_apply git-apply.exe\n complete -o default -o nospace -F _git git.exe\n complete -o default            -F _git_branch git-branch.exe\n complete -o default -o nospace -F _git_cat_file git-cat-file.exe\n-- \n"}]}