{"thread":{"id":"12619","subject":"[PATCH] bash: add 'git svn' subcommands and options","startedAt":"2008-03-10T15:02:22Z","lastAt":"2008-03-10T23:54:32Z","messageCount":5,"participants":["SZEDER Gábor","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"71591","messageId":"1205161345-21120-1-git-send-email-szeder@ira.uka.de","threadId":"12619","inReplyTo":null,"subject":"[PATCH 1/2] bash: remove unnecessary conditions when checking for subcommands","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-03-10T15:02:22Z","receivedAt":"2008-03-10T15:02:22Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Checking emptyness of $command is sufficient.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 86b7ebe..39b2186 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -505,7 +505,7 @@ _git_bisect ()\n \t\tc=$((++c))\n \tdone\n \n-\tif [ $c -eq $COMP_CWORD -a -z \"$command\" ]; then\n+\tif [ -z \"$command\" ]; then\n \t\t__gitcomp \"start bad good reset visualize replay log\"\n \t\treturn\n \tfi\n@@ -1050,7 +1050,7 @@ _git_remote ()\n \t\tc=$((++c))\n \tdone\n \n-\tif [ $c -eq $COMP_CWORD -a -z \"$command\" ]; then\n+\tif [ -z \"$command\" ]; then\n \t\t__gitcomp \"add rm show prune update\"\n \t\treturn\n \tfi\n@@ -1143,7 +1143,7 @@ _git_submodule ()\n \t\tc=$((++c))\n \tdone\n \n-\tif [ $c -eq $COMP_CWORD -a -z \"$command\" ]; then\n+\tif [ -z \"$command\" ]; then\n \t\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \t\tcase \"$cur\" in\n \t\t--*)\n@@ -1206,7 +1206,7 @@ _git ()\n \t\tc=$((++c))\n \tdone\n \n-\tif [ $c -eq $COMP_CWORD -a -z \"$command\" ]; then\n+\tif [ -z \"$command\" ]; then\n \t\tcase \"${COMP_WORDS[COMP_CWORD]}\" in\n \t\t--*=*) COMPREPLY=() ;;\n \t\t--*)   __gitcomp \"\n-- \n1.5.4.4.481.g5075\n"},{"id":"71592","messageId":"1205161345-21120-2-git-send-email-szeder@ira.uka.de","threadId":"12619","inReplyTo":"1205161345-21120-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 2/2] bash: refactor searching for subcommands on the command line","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-03-10T15:02:23Z","receivedAt":"2008-03-10T15:02:23Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"This patch adds the __git_find_subcommand function, which takes one\nargument: a string containing all subcommands separated by spaces.  The\nfunction searches through the command line whether a subcommand is\nalready present.  The first found subcommand will be printed to standard\noutput.\n\nThis enables us to remove code duplications from completion functions\nfor commands having subcommands.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |   71 ++++++++++++++-----------------\n 1 files changed, 32 insertions(+), 39 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 39b2186..0feed97 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -436,6 +436,22 @@ __git_aliased_command ()\n \tdone\n }\n \n+__git_find_subcommand ()\n+{\n+\tlocal word subcommand c=1\n+\n+\twhile [ $c -lt $COMP_CWORD ]; do\n+\t\tword=\"${COMP_WORDS[c]}\"\n+\t\tfor subcommand in $1; do\n+\t\t\tif [ \"$subcommand\" = \"$word\" ]; then\n+\t\t\t\techo \"$subcommand\"\n+\t\t\t\treturn\n+\t\t\tfi\n+\t\tdone\n+\t\tc=$((++c))\n+\tdone\n+}\n+\n __git_whitespacelist=\"nowarn warn error error-all strip\"\n \n _git_am ()\n@@ -493,24 +509,14 @@ _git_add ()\n \n _git_bisect ()\n {\n-\tlocal i c=1 command\n-\twhile [ $c -lt $COMP_CWORD ]; do\n-\t\ti=\"${COMP_WORDS[c]}\"\n-\t\tcase \"$i\" in\n-\t\tstart|bad|good|reset|visualize|replay|log)\n-\t\t\tcommand=\"$i\"\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\t\tc=$((++c))\n-\tdone\n-\n-\tif [ -z \"$command\" ]; then\n-\t\t__gitcomp \"start bad good reset visualize replay log\"\n+\tlocal subcommands=\"start bad good reset visualize replay log\"\n+\tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n \t\treturn\n \tfi\n \n-\tcase \"$command\" in\n+\tcase \"$subcommand\" in\n \tbad|good|reset)\n \t\t__gitcomp \"$(__git_refs)\"\n \t\t;;\n@@ -1041,21 +1047,13 @@ _git_config ()\n \n _git_remote ()\n {\n-\tlocal i c=1 command\n-\twhile [ $c -lt $COMP_CWORD ]; do\n-\t\ti=\"${COMP_WORDS[c]}\"\n-\t\tcase \"$i\" in\n-\t\tadd|rm|show|prune|update) command=\"$i\"; break ;;\n-\t\tesac\n-\t\tc=$((++c))\n-\tdone\n-\n-\tif [ -z \"$command\" ]; then\n-\t\t__gitcomp \"add rm show prune update\"\n+\tlocal subcommands=\"add rm show prune update\"\n+\tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n+\tif [ -z \"$subcommand\" ]; then\n \t\treturn\n \tfi\n \n-\tcase \"$command\" in\n+\tcase \"$subcommand\" in\n \trm|show|prune)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n@@ -1129,28 +1127,23 @@ _git_show ()\n \n _git_stash ()\n {\n-\t__gitcomp 'list show apply clear'\n+\tlocal subcommands='list show apply clear'\n+\tif [ -z \"$(__git_find_subcommand \"$subcommands\")\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\tfi\n }\n \n _git_submodule ()\n {\n-\tlocal i c=1 command\n-\twhile [ $c -lt $COMP_CWORD ]; do\n-\t\ti=\"${COMP_WORDS[c]}\"\n-\t\tcase \"$i\" in\n-\t\tadd|status|init|update) command=\"$i\"; break ;;\n-\t\tesac\n-\t\tc=$((++c))\n-\tdone\n-\n-\tif [ -z \"$command\" ]; then\n+\tlocal subcommands=\"add status init update\"\n+\tif [ -z \"$(__git_find_subcommand \"$subcommands\")\" ]; then\n \t\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \t\tcase \"$cur\" in\n \t\t--*)\n \t\t\t__gitcomp \"--quiet --cached\"\n \t\t\t;;\n \t\t*)\n-\t\t\t__gitcomp \"add status init update\"\n+\t\t\t__gitcomp \"$subcommands\"\n \t\t\t;;\n \t\tesac\n \t\treturn\n-- \n1.5.4.4.481.g5075\n"},{"id":"71593","messageId":"1205161345-21120-3-git-send-email-szeder@ira.uka.de","threadId":"12619","inReplyTo":"1205161345-21120-2-git-send-email-szeder@ira.uka.de","subject":"[PATCH] bash: add new 'git stash' subcommands","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-03-10T15:02:24Z","receivedAt":"2008-03-10T15:02:24Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Namely 'save', 'drop', 'pop' and 'create'\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0feed97..c194972 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1127,7 +1127,7 @@ _git_show ()\n \n _git_stash ()\n {\n-\tlocal subcommands='list show apply clear'\n+\tlocal subcommands='save list show apply clear drop pop create'\n \tif [ -z \"$(__git_find_subcommand \"$subcommands\")\" ]; then\n \t\t__gitcomp \"$subcommands\"\n \tfi\n-- \n1.5.4.4.481.g5075\n"},{"id":"71590","messageId":"1205161345-21120-4-git-send-email-szeder@ira.uka.de","threadId":"12619","inReplyTo":"1205161345-21120-3-git-send-email-szeder@ira.uka.de","subject":"[PATCH] bash: add 'git svn' subcommands and options","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-03-10T15:02:25Z","receivedAt":"2008-03-10T15:02:25Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |   81 +++++++++++++++++++++++++++++++-\n 1 files changed, 80 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c194972..5a844f5 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -392,7 +392,6 @@ __git_commands ()\n \t\tshow-index)       : plumbing;;\n \t\tssh-*)            : transport;;\n \t\tstripspace)       : plumbing;;\n-\t\tsvn)              : import export;;\n \t\tsymbolic-ref)     : plumbing;;\n \t\ttar-tree)         : deprecated;;\n \t\tunpack-file)      : plumbing;;\n@@ -1150,6 +1149,84 @@ _git_submodule ()\n \tfi\n }\n \n+_git_svn ()\n+{\n+\tlocal subcommands=\"\n+\t\tinit fetch clone rebase dcommit log find-rev\n+\t\tset-tree commit-diff info create-ignore propget\n+\t\tproplist show-ignore show-externals\n+\t\t\"\n+\tlocal subcommand=\"$(__git_find_subcommand \"$subcommands\")\"\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\telse\n+\t\tlocal remote_opts=\"--username= --config-dir= --no-auth-cache\"\n+\t\tlocal fc_opts=\"\n+\t\t\t--follow-parent --authors-file= --repack=\n+\t\t\t--no-metadata --use-svm-props --use-svnsync-props\n+\t\t\t--log-window-size= --no-checkout --quiet\n+\t\t\t--repack-flags --user-log-author $remote_opts\n+\t\t\t\"\n+\t\tlocal init_opts=\"\n+\t\t\t--template= --shared= --trunk= --tags=\n+\t\t\t--branches= --stdlayout --minimize-url\n+\t\t\t--no-metadata --use-svm-props --use-svnsync-props\n+\t\t\t--rewrite-root= $remote_opts\n+\t\t\t\"\n+\t\tlocal cmt_opts=\"\n+\t\t\t--edit --rmdir --find-copies-harder --copy-similarity=\n+\t\t\t\"\n+\n+\t\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\t\tcase \"$subcommand,$cur\" in\n+\t\tfetch,--*)\n+\t\t\t__gitcomp \"--revision= --fetch-all $fc_opts\"\n+\t\t\t;;\n+\t\tclone,--*)\n+\t\t\t__gitcomp \"--revision= $fc_opts $init_opts\"\n+\t\t\t;;\n+\t\tinit,--*)\n+\t\t\t__gitcomp \"$init_opts\"\n+\t\t\t;;\n+\t\tdcommit,--*)\n+\t\t\t__gitcomp \"\n+\t\t\t\t--merge --strategy= --verbose --dry-run\n+\t\t\t\t--fetch-all --no-rebase $cmt_opts $fc_opts\n+\t\t\t\t\"\n+\t\t\t;;\n+\t\tset-tree,--*)\n+\t\t\t__gitcomp \"--stdin $cmt_opts $fc_opts\"\n+\t\t\t;;\n+\t\tcreate-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\\\n+\t\tshow-externals,--*)\n+\t\t\t__gitcomp \"--revision=\"\n+\t\t\t;;\n+\t\tlog,--*)\n+\t\t\t__gitcomp \"\n+\t\t\t\t--limit= --revision= --verbose --incremental\n+\t\t\t\t--oneline --show-commit --non-recursive\n+\t\t\t\t--authors-file=\n+\t\t\t\t\"\n+\t\t\t;;\n+\t\trebase,--*)\n+\t\t\t__gitcomp \"\n+\t\t\t\t--merge --verbose --strategy= --local\n+\t\t\t\t--fetch-all $fc_opts\n+\t\t\t\t\"\n+\t\t\t;;\n+\t\tcommit-diff,--*)\n+\t\t\t__gitcomp \"--message= --file= --revision= $cmt_opts\"\n+\t\t\t;;\n+\t\tinfo,--*)\n+\t\t\t__gitcomp \"--url\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\tCOMPREPLY=()\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+}\n+\n _git_tag ()\n {\n \tlocal i c=1 f=0\n@@ -1251,6 +1328,7 @@ _git ()\n \tshow-branch) _git_log ;;\n \tstash)       _git_stash ;;\n \tsubmodule)   _git_submodule ;;\n+\tsvn)         _git_svn ;;\n \ttag)         _git_tag ;;\n \twhatchanged) _git_log ;;\n \t*)           COMPREPLY=() ;;\n@@ -1301,6 +1379,7 @@ complete -o default -o nospace -F _git_shortlog git-shortlog\n complete -o default -o nospace -F _git_show git-show\n complete -o default -o nospace -F _git_stash git-stash\n complete -o default -o nospace -F _git_submodule git-submodule\n+complete -o default -o nospace -F _git_svn git-svn\n complete -o default -o nospace -F _git_log git-show-branch\n complete -o default -o nospace -F _git_tag git-tag\n complete -o default -o nospace -F _git_log git-whatchanged\n-- \n1.5.4.4.481.g5075\n"},{"id":"71628","messageId":"20080310235432.GJ8410@spearce.org","threadId":"12619","inReplyTo":"1205161345-21120-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH 1/2] bash: remove unnecessary conditions when checking for subcommands","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-03-10T23:54:32Z","receivedAt":"2008-03-10T23:54:32Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"SZEDER Gbor <szeder@ira.uka.de> wrote:\n> Checking emptyness of $command is sufficient.\n> \n> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n\nThanks.  I have your entire series in a branch that I will\nbe asking Junio to merge.\n\n-- \nShawn.\n"}]}