{"thread":{"id":"19218","subject":"[PATCH 1/3] completion: complete config variables for --get/getall/unset/unset-all","startedAt":"2009-05-07T06:15:04Z","lastAt":"2009-05-09T01:00:25Z","messageCount":7,"participants":["Stephen Boyd","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"113169","messageId":"1241676906-29783-1-git-send-email-bebarino@gmail.com","threadId":"19218","inReplyTo":null,"subject":"[PATCH 1/3] completion: complete config variables for --get/getall/unset/unset-all","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-07T06:15:04Z","receivedAt":"2009-05-07T06:15:04Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"This should make it easier for users to get and unset their\nconfiguration variables without having to open documentation or dig\nthrough their configuration file.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n contrib/completion/git-completion.bash |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1683e6d..72a16a1 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1322,6 +1322,17 @@ _git_send_email ()\n \tCOMPREPLY=()\n }\n \n+__git_config_get_set_variables ()\n+{\n+\tfor i in $(git --git-dir=\"$(__gitdir)\" config --list); do\n+\t\tcase \"$i\" in\n+\t\t*.*)\n+\t\t\techo \"${i/=*/}\"\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+}\n+\n _git_config ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n@@ -1388,6 +1399,10 @@ _git_config ()\n \t\t__gitcomp \"$__git_send_email_suppresscc_options\"\n \t\treturn\n \t\t;;\n+\t--get|--get-all|--unset|--unset-all)\n+\t\t__gitcomp \"$(__git_config_get_set_variables)\"\n+\t\treturn\n+\t\t;;\n \t*.*)\n \t\tCOMPREPLY=()\n \t\treturn\n-- \n1.6.3.rc4.29.g8146\n"},{"id":"113170","messageId":"1241676906-29783-2-git-send-email-bebarino@gmail.com","threadId":"19218","inReplyTo":"1241676906-29783-1-git-send-email-bebarino@gmail.com","subject":"[PATCH 2/3] completion: add find_argument_and_value() function","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-07T06:15:05Z","receivedAt":"2009-05-07T06:15:05Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Add a function to get arguments and their associated value. This is used\nby the config completion to find config file arguments.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nI'm not sure if this is correct. It works for the case I have, but\nothers I'm not so sure. Let's just say I'm no bash expert.\n\n contrib/completion/git-completion.bash |   25 +++++++++++++++++++++++++\n 1 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 72a16a1..f179cc8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -618,6 +618,31 @@ __git_find_subcommand ()\n \tdone\n }\n \n+# __git_find_argument_and_value requires 1 argument\n+__git_find_argument_and_value ()\n+{\n+\tlocal word nextword argument c=1\n+\n+\twhile [ $c -lt $COMP_CWORD ]; do\n+\t\tword=\"${COMP_WORDS[c]}\"\n+\t\tfor argument in $1; do\n+\t\t\tif [ \"${argument##--}\" = \"${word##--}\" ]; then\n+\t\t\t\tnextword=${COMP_WORDS[$((c+1))]}\n+\t\t\t\tif [ \"${nextword#-}\" != \"$nextword\" ]; then\n+\t\t\t\t\tnextword=\n+\t\t\t\tfi\n+\t\t\t\techo \"$argument $nextword\"\n+\t\t\t\treturn\n+\t\t\tfi\n+\t\t\tif [ \"${argument/=*/}\" = \"${word/=*/}\" ]; then\n+\t\t\t\techo \"$word\"\n+\t\t\t\treturn\n+\t\t\tfi\n+\t\tdone\n+\t\tc=$((++c))\n+\tdone\n+}\n+\n __git_has_doubledash ()\n {\n \tlocal c=1\n-- \n1.6.3.rc4.29.g8146\n"},{"id":"113171","messageId":"1241677093-29937-1-git-send-email-bebarino@gmail.com","threadId":"19218","inReplyTo":"1241676906-29783-1-git-send-email-bebarino@gmail.com","subject":"[PATCH 2/3] completion: add find_argument_and_value() function","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-07T06:18:12Z","receivedAt":"2009-05-07T06:18:12Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Add a function to get arguments and their associated value. This is used\nby the config completion to find config file arguments.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nI'm not sure if this is correct. It works for the case I have, but\nothers I'm not so sure. Let's just say I'm no bash expert.\n\n contrib/completion/git-completion.bash |   25 +++++++++++++++++++++++++\n 1 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 72a16a1..f179cc8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -618,6 +618,31 @@ __git_find_subcommand ()\n \tdone\n }\n \n+# __git_find_argument_and_value requires 1 argument\n+__git_find_argument_and_value ()\n+{\n+\tlocal word nextword argument c=1\n+\n+\twhile [ $c -lt $COMP_CWORD ]; do\n+\t\tword=\"${COMP_WORDS[c]}\"\n+\t\tfor argument in $1; do\n+\t\t\tif [ \"${argument##--}\" = \"${word##--}\" ]; then\n+\t\t\t\tnextword=${COMP_WORDS[$((c+1))]}\n+\t\t\t\tif [ \"${nextword#-}\" != \"$nextword\" ]; then\n+\t\t\t\t\tnextword=\n+\t\t\t\tfi\n+\t\t\t\techo \"$argument $nextword\"\n+\t\t\t\treturn\n+\t\t\tfi\n+\t\t\tif [ \"${argument/=*/}\" = \"${word/=*/}\" ]; then\n+\t\t\t\techo \"$word\"\n+\t\t\t\treturn\n+\t\t\tfi\n+\t\tdone\n+\t\tc=$((++c))\n+\tdone\n+}\n+\n __git_has_doubledash ()\n {\n \tlocal c=1\n-- \n1.6.3.rc4.29.g8146\n"},{"id":"113172","messageId":"1241677093-29937-2-git-send-email-bebarino@gmail.com","threadId":"19218","inReplyTo":"1241677093-29937-1-git-send-email-bebarino@gmail.com","subject":"[PATCH 3/3] completion: use specified file (if any) when completing config vars","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-07T06:18:13Z","receivedAt":"2009-05-07T06:18:13Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Only list the variables that can actually be affected by the command by\nsearching the arguments for a config file setting.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n contrib/completion/git-completion.bash |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex f179cc8..8a9863b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1349,7 +1349,10 @@ _git_send_email ()\n \n __git_config_get_set_variables ()\n {\n-\tfor i in $(git --git-dir=\"$(__gitdir)\" config --list); do\n+\tlocal args=\"--global --system --file= -f\"\n+\tlocal config_file=\"$(__git_find_argument_and_value \"$args\")\"\n+\tfor i in $(git --git-dir=\"$(__gitdir)\" config $config_file --list \\\n+\t\t\t2>/dev/null); do\n \t\tcase \"$i\" in\n \t\t*.*)\n \t\t\techo \"${i/=*/}\"\n-- \n1.6.3.rc4.29.g8146\n"},{"id":"113227","messageId":"20090507151207.GQ30527@spearce.org","threadId":"19218","inReplyTo":"1241677093-29937-2-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH 3/3] completion: use specified file (if any) when completing config vars","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-05-07T15:12:07Z","receivedAt":"2009-05-07T15:12:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> wrote:\n> Only list the variables that can actually be affected by the command by\n> searching the arguments for a config file setting.\n\nWow, this is a lot of magic.\n\nTry:\n\n  git config --global remote.gitster.url $(git config remote.o<TAB>\n\nYou'll complete against --global, not the local repository.\n\n \n>  __git_config_get_set_variables ()\n>  {\n> -\tfor i in $(git --git-dir=\"$(__gitdir)\" config --list); do\n> +\tlocal args=\"--global --system --file= -f\"\n> +\tlocal config_file=\"$(__git_find_argument_and_value \"$args\")\"\n> +\tfor i in $(git --git-dir=\"$(__gitdir)\" config $config_file --list \\\n> +\t\t\t2>/dev/null); do\n\n-- \nShawn.\n"},{"id":"113258","messageId":"780e0a6b0905071255g4ade6316oace6a2be6a6d2@mail.gmail.com","threadId":"19218","inReplyTo":"20090507151207.GQ30527@spearce.org","subject":"Re: [PATCH 3/3] completion: use specified file (if any) when completing config vars","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-07T19:55:11Z","receivedAt":"2009-05-07T19:55:11Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"On Thu, May 7, 2009 at 8:12 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Stephen Boyd <bebarino@gmail.com> wrote:\n>> Only list the variables that can actually be affected by the command by\n>> searching the arguments for a config file setting.\n>\n> Wow, this is a lot of magic.\n>\n> Try:\n>\n>  git config --global remote.gitster.url $(git config remote.o<TAB>\n>\n> You'll complete against --global, not the local repository.\n>\n\nYeah, I didn't think it would be very robust. Is it a good idea to\nkeep going down this path, or is it too magical? This example could be\nfixed by searching the words backwards, but I imagine there is some\nother case where that will fail. Also, --global and --system don't\nhave values, so right now it's all wrong (i.e. config_file is\n\"--global remote.gitster.url\" for this example).\n"},{"id":"113382","messageId":"4A04D5A9.1090901@gmail.com","threadId":"19218","inReplyTo":"780e0a6b0905071255g4ade6316oace6a2be6a6d2@mail.gmail.com","subject":"Re: [PATCH 3/3] completion: use specified file (if any) when completing config vars","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-05-09T01:00:25Z","receivedAt":"2009-05-09T01:00:25Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Stephen Boyd wrote:\n> On Thu, May 7, 2009 at 8:12 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> Wow, this is a lot of magic.\n>>\n>> Try:\n>>\n>> Â git config --global remote.gitster.url $(git config remote.o<TAB>\n>>\n>> You'll complete against --global, not the local repository\n>\n> Yeah, I didn't think it would be very robust. Is it a good idea to\n> keep going down this path, or is it too magical? This example could be\n> fixed by searching the words backwards, but I imagine there is some\n> other case where that will fail. Also, --global and --system don't\n> have values, so right now it's all wrong (i.e. config_file is\n> \"--global remote.gitster.url\" for this example).\n\nAfter further investigation, I can't get the tab completion you talk\nabout here to work at all. Should it work?\n\nI've reworked this into two patches which I'll send as a follow up soon.\n"}]}