{"thread":{"id":"42504","subject":"[PATCH 1/2] completion: create variable for untracked file modes","startedAt":"2016-05-31T23:42:33Z","lastAt":"2016-06-25T16:13:11Z","messageCount":33,"participants":["Thomas Braun","Jeff King","Junio C Hamano","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"287960","messageId":"5a3d279f-d3cc-90ec-a0e7-90b7ef438966@virtuell-zuhause.de","threadId":"42504","inReplyTo":null,"subject":"[PATCH 1/2] completion: create variable for untracked file modes","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-05-31T23:42:33Z","receivedAt":"2016-05-31T23:42:33Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..57a0acc 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n +__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$(__git_untracked_file_modes)\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n-- \n2.8.3.windows.1\n"},{"id":"287970","messageId":"20160601040542.GA18978@sigill.intra.peff.net","threadId":"42504","inReplyTo":"5a3d279f-d3cc-90ec-a0e7-90b7ef438966@virtuell-zuhause.de","subject":"Re: [PATCH 1/2] completion: create variable for untracked file modes","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-01T04:05:42Z","receivedAt":"2016-06-01T04:05:42Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jun 01, 2016 at 01:42:33AM +0200, Thomas Braun wrote:\n\n> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n> ---\n>  contrib/completion/git-completion.bash | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 3402475..57a0acc 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1098,6 +1098,8 @@ _git_clone ()\n>  \tesac\n>  }\n>  +__git_untracked_file_modes=\"all no normal\"\n> +\n>  _git_commit ()\n>  {\n>  \tcase \"$prev\" in\n\nThere's something funny about the formatting of your patch. The first\n\"+\" line is indented, which it shouldn't be. As it is, it looks like\ncontext (but it's not actually part of the preimage). But if it's not\ncontext, then you are missing a context line.\n\nIt kind of looks like you put a literal \"+__git_untracked...\" line in\nthe file and then committed, then added the next line, and committed\nthat. Or you edited the patch by hand.\n\nAnyway, I couldn't actually apply it.\n\n> @@ -1119,7 +1121,7 @@ _git_commit ()\n>  \t\treturn\n>  \t\t;;\n>  \t--untracked-files=*)\n> -\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n> +\t\t__gitcomp \"$(__git_untracked_file_modes)\" \"\" \"${cur##--untracked-files=}\"\n\nYour __git_untracked_file_modes is a variable, but \"$()\" will run it as\na command. You want just \"$__git_untracked_file_modes\", or to make it\ninto a function.\n\n-Peff\n"},{"id":"287980","messageId":"xmqqk2i91jf5.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"20160601040542.GA18978@sigill.intra.peff.net","subject":"Re: [PATCH 1/2] completion: create variable for untracked file modes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-01T07:02:06Z","receivedAt":"2016-06-01T07:02:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index 3402475..57a0acc 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -1098,6 +1098,8 @@ _git_clone ()\n>>  \tesac\n>>  }\n>>  +__git_untracked_file_modes=\"all no normal\"\n>> +\n>>  _git_commit ()\n>>  {\n>>  \tcase \"$prev\" in\n>\n> There's something funny about the formatting of your patch. The first\n> \"+\" line is indented, which it shouldn't be. As it is, it looks like\n> context (but it's not actually part of the preimage). But if it's not\n> context, then you are missing a context line.\n\nNot just that.  Count the context lines and notice that this appears\nto have only 2 lines of precontext.\n\nI think the MUA is somehow eating a blank line context (i.e. a\nsingle SP on a line by itself) immediately after the closing brace\nof the function before _git_commit and the next new line that began\nwith '+' in the original and made them into a single line.  I've\nseen this exact breakage before, I think.\n"},{"id":"287991","messageId":"569545b0-a5cb-c722-601e-2654d4c6e5e1@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqqk2i91jf5.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/2] completion: create variable for untracked file modes","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-01T09:14:40Z","receivedAt":"2016-06-01T09:14:40Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"> Junio C Hamano <gitster@pobox.com> hat am 1. Juni 2016 um 09:02 geschrieben:\n> \n> \n> Jeff King <peff@peff.net> writes:\n> \n> >> diff --git a/contrib/completion/git-completion.bash\n> >> b/contrib/completion/git-completion.bash\n> >> index 3402475..57a0acc 100644\n> >> --- a/contrib/completion/git-completion.bash\n> >> +++ b/contrib/completion/git-completion.bash\n> >> @@ -1098,6 +1098,8 @@ _git_clone ()\n> >>  \tesac\n> >>  }\n> >>  +__git_untracked_file_modes=\"all no normal\"\n> >> +\n> >>  _git_commit ()\n> >>  {\n> >>  \tcase \"$prev\" in\n> >\n> > There's something funny about the formatting of your patch. The first\n> > \"+\" line is indented, which it shouldn't be. As it is, it looks like\n> > context (but it's not actually part of the preimage). But if it's not\n> > context, then you are missing a context line.\n> \n> Not just that.  Count the context lines and notice that this appears\n> to have only 2 lines of precontext.\n> \n> I think the MUA is somehow eating a blank line context (i.e. a\n> single SP on a line by itself) immediately after the closing brace\n> of the function before _git_commit and the next new line that began\n> with '+' in the original and made them into a single line.  I've\n> seen this exact breakage before, I think.\n\nThanks both for noticing and sorry for the mess.\n\nI'm using Thunderbird 45.1.1 on Windows and the \"Toggle Word Wrap\" addon\nfor well trying to avoid messing up whitespace. The emails are created\nwith `git format-patch ... | git imap-send` and sent to my drafts\nfolder. There they look good *until* I choose \"Edit as new\" which seems\nto be required to actually send the email.  So I'll\nstick to other solutions for now.\n\nReroll follows.\n"},{"id":"287994","messageId":"1464773846.4315.0.camel@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160601040542.GA18978@sigill.intra.peff.net","subject":"[PATCH v2 1/2] completion: create variable for untracked file modes","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-01T09:37:26Z","receivedAt":"2016-06-01T09:37:26Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..addea89 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n \n+__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n"},{"id":"287993","messageId":"1464773857.4315.1.camel@virtuell-zuhause.de","threadId":"42504","inReplyTo":"6e722a5fb64b73373ac6450ec9600e98745df29d.1464769152.git.thomas.braun@virtuell-zuhause.de","subject":"[PATCH v2 2/2] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-01T09:37:37Z","receivedAt":"2016-06-01T09:37:37Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex addea89..77343da 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1782,6 +1782,35 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tcase \"$cur\" in\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--untracked-files=*)\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"\n+\t\t\talways never auto column row plain dense nodense\n+\t\t\t\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --porcelain --long --verbose\n+\t\t\t--untracked-files= --ignore-submodules= --ignored\n+\t\t\t--column= --no-column\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\t__git_complete_file\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n"},{"id":"288001","messageId":"20160601135938.Horde.2Daxezldve72SBukDSPenPP@webmail.informatik.kit.edu","threadId":"42504","inReplyTo":"1464773846.4315.0.camel@virtuell-zuhause.de","subject":"Re: [PATCH v2 1/2] completion: create variable for untracked file modes","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2016-06-01T11:59:38Z","receivedAt":"2016-06-01T11:59:38Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nThis subject would perhaps read better:\n\n   completion: factor out untracked file modes into a variable\n\n\nQuoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n\n> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n> ---\n>  contrib/completion/git-completion.bash | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git a/contrib/completion/git-completion.bash  \n> b/contrib/completion/git-completion.bash\n> index 3402475..addea89 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1098,6 +1098,8 @@ _git_clone ()\n>  \tesac\n>  }\n>\n> +__git_untracked_file_modes=\"all no normal\"\n> +\n>  _git_commit ()\n>  {\n>  \tcase \"$prev\" in\n> @@ -1119,7 +1121,7 @@ _git_commit ()\n>  \t\treturn\n>  \t\t;;\n>  \t--untracked-files=*)\n> -\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n> +\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n>  \t\treturn\n>  \t\t;;\n>  \t--*)\n"},{"id":"288002","messageId":"20160601141510.Horde.M2zGuJrzBNqf_2zYLo0P2Sx@webmail.informatik.kit.edu","threadId":"42504","inReplyTo":"1464773857.4315.1.camel@virtuell-zuhause.de","subject":"Re: [PATCH v2 2/2] completion: add git status","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2016-06-01T12:15:10Z","receivedAt":"2016-06-01T12:15:10Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nQuoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n\n> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n> ---\n>  contrib/completion/git-completion.bash | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.bash  \n> b/contrib/completion/git-completion.bash\n> index addea89..77343da 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1782,6 +1782,35 @@ _git_stage ()\n>  \t_git_add\n>  }\n>\n> +_git_status ()\n> +{\n> +\tcase \"$cur\" in\n> +\t--ignore-submodules=*)\n> +\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--untracked-files=*)\n> +\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--column=*)\n> +\t\t__gitcomp \"\n> +\t\t\talways never auto column row plain dense nodense\n> +\t\t\t\" \"\" \"${cur##--column=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--*)\n> +\t\t__gitcomp \"\n> +\t\t\t--short --branch --porcelain --long --verbose\n> +\t\t\t--untracked-files= --ignore-submodules= --ignored\n> +\t\t\t--column= --no-column\n> +\t\t\t\"\n> +\t\treturn\n> +\t\t;;\n> +\tesac\n> +\t__git_complete_file\n\n__git_complete_file()'s job is to complete the '<rev>:<path>' notation,\ne.g. 'master:Mak<TAB>',  which is not what we want here, because this\nnotation doesn't make sense for 'git status' and because 'git status\n<TAB>' would then offer refs instead of files.\n\nI think there are two choices what to do instead:\n\n   - Don't do anything :)  Bash will then fall back to filename\n     completion, which is quite close to what we want here (and in this\n     case the return statements from the other case arms can go away as\n     well).  The drawback is that all ignored files in the current\n     working directory will show up after 'git status <TAB>'.\n\n   - use __git_complete_index_file() with appropriate options, perhaps\n     '--cached --others', but I didn't think this through.  For bonus\n     points pass additional options when certain 'git status' options are\n     already present on the command line, e.g. pass '--ignored', too, if\n     it is present.\n\n> +}\n> +\n>  __git_config_get_set_variables ()\n>  {\n>  \tlocal prevword word config_file= c=$cword\n"},{"id":"288126","messageId":"b41a90a6-c679-d148-823c-a94231f3f90c@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160601135938.Horde.2Daxezldve72SBukDSPenPP@webmail.informatik.kit.edu","subject":"Re: [PATCH v2 1/2] completion: create variable for untracked file modes","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-02T12:19:31Z","receivedAt":"2016-06-02T12:19:31Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 01.06.2016 um 13:59 schrieb SZEDER Gábor:\n> \n> This subject would perhaps read better:\n> \n>   completion: factor out untracked file modes into a variable\n\nYes, definitly. Will be included in reroll.\n\n> Quoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n> \n>> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n>> ---\n>>  contrib/completion/git-completion.bash | 4 +++-\n>>  1 file changed, 3 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/contrib/completion/git-completion.bash\n>> b/contrib/completion/git-completion.bash\n>> index 3402475..addea89 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -1098,6 +1098,8 @@ _git_clone ()\n>>      esac\n>>  }\n>>\n>> +__git_untracked_file_modes=\"all no normal\"\n>> +\n>>  _git_commit ()\n>>  {\n>>      case \"$prev\" in\n>> @@ -1119,7 +1121,7 @@ _git_commit ()\n>>          return\n>>          ;;\n>>      --untracked-files=*)\n>> -        __gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n>> +        __gitcomp \"$__git_untracked_file_modes\" \"\"\n>> \"${cur##--untracked-files=}\"\n>>          return\n>>          ;;\n>>      --*)\n> \n> \n> \n"},{"id":"288125","messageId":"025de231-53a3-bc71-1564-aad8f4e096c1@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160601141510.Horde.M2zGuJrzBNqf_2zYLo0P2Sx@webmail.informatik.kit.edu","subject":"Re: [PATCH v2 2/2] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-02T15:04:58Z","receivedAt":"2016-06-02T15:04:58Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 01.06.2016 um 14:15 schrieb SZEDER Gábor:\n> \n> Quoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n> \n>> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n>> ---\n>>  contrib/completion/git-completion.bash | 29\n>> +++++++++++++++++++++++++++++\n>>  1 file changed, 29 insertions(+)\n>>\n>> diff --git a/contrib/completion/git-completion.bash\n>> b/contrib/completion/git-completion.bash\n>> index addea89..77343da 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -1782,6 +1782,35 @@ _git_stage ()\n>>      _git_add\n>>  }\n>>\n>> +_git_status ()\n>> +{\n>> +    case \"$cur\" in\n>> +    --ignore-submodules=*)\n>> +        __gitcomp \"none untracked dirty all\" \"\"\n>> \"${cur##--ignore-submodules=}\"\n>> +        return\n>> +        ;;\n>> +    --untracked-files=*)\n>> +        __gitcomp \"$__git_untracked_file_modes\" \"\"\n>> \"${cur##--untracked-files=}\"\n>> +        return\n>> +        ;;\n>> +    --column=*)\n>> +        __gitcomp \"\n>> +            always never auto column row plain dense nodense\n>> +            \" \"\" \"${cur##--column=}\"\n>> +        return\n>> +        ;;\n>> +    --*)\n>> +        __gitcomp \"\n>> +            --short --branch --porcelain --long --verbose\n>> +            --untracked-files= --ignore-submodules= --ignored\n>> +            --column= --no-column\n>> +            \"\n>> +        return\n>> +        ;;\n>> +    esac\n>> +    __git_complete_file\n> \n> __git_complete_file()'s job is to complete the '<rev>:<path>' notation,\n> e.g. 'master:Mak<TAB>',  which is not what we want here, because this\n> notation doesn't make sense for 'git status' and because 'git status\n> <TAB>' would then offer refs instead of files.\n\nCorrect. I might have been mislead by the name ;)\n\n> I think there are two choices what to do instead:\n> \n>   - Don't do anything :)  Bash will then fall back to filename\n>     completion, which is quite close to what we want here (and in this\n>     case the return statements from the other case arms can go away as\n>     well).  The drawback is that all ignored files in the current\n>     working directory will show up after 'git status <TAB>'.\n> \n>   - use __git_complete_index_file() with appropriate options, perhaps\n>     '--cached --others', but I didn't think this through.  For bonus\n>     points pass additional options when certain 'git status' options are\n>     already present on the command line, e.g. pass '--ignored', too, if\n>     it is present.\n\nI went for the bonus points way. If that is too involved I can also go\nback to \"Don't do anything\".\n"},{"id":"288127","messageId":"1464880296.3720.0.camel@virtuell-zuhause.de","threadId":"42504","inReplyTo":"9ef8cfd8fb89bcacd123ddbebc12f961a292ef8b.1464879648.git.thomas.braun@virtuell-zuhause.de","subject":"[PATCH v3 2/2] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-02T15:11:36Z","receivedAt":"2016-06-02T15:11:36Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 55 ++++++++++++++++++++++++++++++++++\n 1 file changed, 55 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex addea89..fa7a03a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1782,6 +1782,61 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tlocal complete_opt\n+\tlocal untracked_state\n+\n+\tcase \"$cur\" in\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--untracked-files=*)\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"\n+\t\t\talways never auto column row plain dense nodense\n+\t\t\t\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --porcelain --long --verbose\n+\t\t\t--untracked-files= --ignore-submodules= --ignored\n+\t\t\t--column= --no-column\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\n+\tuntracked_state=\"$(__git_find_on_cmdline \"--untracked-files=no\\\n+\t\t--untracked-files=normal --untracked-files=all\")\"\n+\tuntracked_state=${untracked_state##--untracked-files=}\n+\n+\tif [ -z \"$untracked_state\" ]; then\n+\t\tuntracked_state=\"$(git --git-dir=\"$(__gitdir)\" config \"status.showUntrackedFiles\")\"\n+\tfi\n+\n+\tcase \"$untracked_state\" in\n+\t\tno)\n+\t\t\t# --ignored option does not matter\n+\t\t\tcomplete_opt=\n+\t\t\t;;\n+\t\tall|normal|*)\n+\t\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n+\n+\t\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n+\t\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n+\t\t\tfi\n+\t\t\t;;\n+\tesac\n+\n+\t__git_complete_index_file \"$complete_opt\"\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n-- \n2.8.3.windows.1\n"},{"id":"288128","messageId":"1464880591.4080.0.camel@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160601141510.Horde.M2zGuJrzBNqf_2zYLo0P2Sx@webmail.informatik.kit.edu","subject":"[PATCH v3 1/2] completion: factor out untracked file modes into a variable","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-02T15:16:31Z","receivedAt":"2016-06-02T15:16:31Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..addea89 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n \n+__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n"},{"id":"288141","messageId":"xmqqtwhbtq46.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"1464880296.3720.0.camel@virtuell-zuhause.de","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-02T18:14:33Z","receivedAt":"2016-06-02T18:14:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n\n> +\tuntracked_state=\"$(__git_find_on_cmdline \"--untracked-files=no\\\n> +\t\t--untracked-files=normal --untracked-files=all\")\"\n\nJust wondering but does this help my use of the command like\n\n\t$ git status -uno <TAB>\n\nor do I now have to spell it out like\n\n\t$ git status --untracked-files=no <TAB>\n\nto take advantage of it?\n\n> +\tuntracked_state=${untracked_state##--untracked-files=}\n> +\n> +\tif [ -z \"$untracked_state\" ]; then\n> +\t\tuntracked_state=\"$(git --git-dir=\"$(__gitdir)\" config \"status.showUntrackedFiles\")\"\n> +\tfi\n> +\n> +\tcase \"$untracked_state\" in\n> +\t\tno)\n> +\t\t\t# --ignored option does not matter\n\nStyle.  I see existing case/esac statements that use this style, but\nour preference is not to indent case arms like this; rather:\n\n\tcase \"$untracked_state\" in\n        no)\n        \t# --ignored ...\n\nwhich saves the indentation one level overall.\n\n> +\t\t\tcomplete_opt=\n> +\t\t\t;;\n> +\t\tall|normal|*)\n> +\t\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n> +\n> +\t\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n\nSame question as the \"--untracked-files=no vs -uno\" applies here.\n\n> +\t\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n> +\t\t\tfi\n> +\t\t\t;;\n> +\tesac\n> +\n> +\t__git_complete_index_file \"$complete_opt\"\n> +}\n> +\n>  __git_config_get_set_variables ()\n>  {\n>  \tlocal prevword word config_file= c=$cword\n"},{"id":"288260","messageId":"8f5e515b-8efc-0160-820e-d81885fc6c36@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqqtwhbtq46.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T15:41:35Z","receivedAt":"2016-06-03T15:41:35Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 02.06.2016 um 20:14 schrieb Junio C Hamano:\n> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n> \n>> +\tuntracked_state=\"$(__git_find_on_cmdline \"--untracked-files=no\\\n>> +\t\t--untracked-files=normal --untracked-files=all\")\"\n> \n> Just wondering but does this help my use of the command like\n> \n> \t$ git status -uno <TAB>\n> \n> or do I now have to spell it out like\n> \n> \t$ git status --untracked-files=no <TAB>\n> \n> to take advantage of it?\n\nI was unsure if I should support the short option (-u) as well. On\nthinking about it again there is little use of only doing it for the\nlong option.\nWill be handled in a reroll.\n\n>> +\tuntracked_state=${untracked_state##--untracked-files=}\n>> +\n>> +\tif [ -z \"$untracked_state\" ]; then\n>> +\t\tuntracked_state=\"$(git --git-dir=\"$(__gitdir)\" config \"status.showUntrackedFiles\")\"\n>> +\tfi\n>> +\n>> +\tcase \"$untracked_state\" in\n>> +\t\tno)\n>> +\t\t\t# --ignored option does not matter\n> \n> Style.  I see existing case/esac statements that use this style, but\n> our preference is not to indent case arms like this; rather:\n> \n> \tcase \"$untracked_state\" in\n>         no)\n>         \t# --ignored ...\n> \n> which saves the indentation one level overall.\n\nthanks, will be fixed.\n\n>> +\t\t\tcomplete_opt=\n>> +\t\t\t;;\n>> +\t\tall|normal|*)\n>> +\t\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n>> +\n>> +\t\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n> \n> Same question as the \"--untracked-files=no vs -uno\" applies here.\n\nIs there a short version of --ignored? I could not find one in the help,\nand from a look into cmd_status in commit.c I would say there is none.\n"},{"id":"288264","messageId":"xmqqzir2p6yv.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"8f5e515b-8efc-0160-820e-d81885fc6c36@virtuell-zuhause.de","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-03T16:34:00Z","receivedAt":"2016-06-03T16:34:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n\n>>> +\t\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n>> \n>> Same question as the \"--untracked-files=no vs -uno\" applies here.\n>\n> Is there a short version of --ignored? I could not find one in the help,\n> and from a look into cmd_status in commit.c I would say there is none.\n\nI was primarily wondering about the effect of parse-options have.\nIt lets you truncate a long option to its unique prefix (e.g.\n\"--untracked-files=all\" can be spelled as \"--unt=all\").  It seems\nthat \"--ignored\" must be spelled in full, which means the use of\nfind-on-cmdline we see above is OK, but the reason why it is so is a\nbit subtle.  It may deserve a comment there, perhaps.\n\n\n[Footnote]\n\n*1* The reason is because \"--ignored\" happens to be the shortest\ntruncation of \"--ignored\" in order to disambiguate it from\n\"--ignore-submodules\".\n"},{"id":"288275","messageId":"20160603171711.GC3858@sigill.intra.peff.net","threadId":"42504","inReplyTo":"xmqqzir2p6yv.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-03T17:17:11Z","receivedAt":"2016-06-03T17:17:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 03, 2016 at 09:34:00AM -0700, Junio C Hamano wrote:\n\n> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n> \n> >>> +\t\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n> >> \n> >> Same question as the \"--untracked-files=no vs -uno\" applies here.\n> >\n> > Is there a short version of --ignored? I could not find one in the help,\n> > and from a look into cmd_status in commit.c I would say there is none.\n> \n> I was primarily wondering about the effect of parse-options have.\n> It lets you truncate a long option to its unique prefix (e.g.\n> \"--untracked-files=all\" can be spelled as \"--unt=all\").  It seems\n> that \"--ignored\" must be spelled in full, which means the use of\n> find-on-cmdline we see above is OK, but the reason why it is so is a\n> bit subtle.  It may deserve a comment there, perhaps.\n\nI don't think we handle arguments to unique-prefix options throughout\nthe completion. There's lots of:\n\n  case \"${words[c]}\" in\n  --foo) ...\n  --bar) ...\n  --etc) ...\n\nI suspect trying to support them everywhere would be a moderate pain,\nand I doubt it is all that useful. We already know the person is using\ntab-completion, so the natural thing to do after typing \"--unt\" is to\nhit \"<Tab>\" rather than \"=\". That gives you the same effect, with the\nadded feedback that you're using a recognized action.\n\nI know not everybody will the \"natural thing\" I claim, and if it were\neasy to support everywhere, I don't mind doing it. But I suspect\n(without thinking very hard on it) that it would make those case\nstatements a bit harder to read and maintain.\n\n-Peff\n"},{"id":"288279","messageId":"xmqq8tymp385.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"20160603171711.GC3858@sigill.intra.peff.net","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-03T17:54:50Z","receivedAt":"2016-06-03T17:54:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I know not everybody will the \"natural thing\" I claim, and if it were\n> easy to support everywhere, I don't mind doing it. But I suspect\n> (without thinking very hard on it) that it would make those case\n> statements a bit harder to read and maintain.\n\nOh, I agree with that 100%.  I didn't mean to suggest (let alone to\ndemand) to support the possible truncations.\n\nI simply was hoping that Thomas would respond with your \"For a user\nwho uses tab completion, it is natural to use --unt<TAB> so by the\ntime we use find-on-command-line, we can expect the fully-spelled\nform\" when I asked about \"--unt=no\"; that would give us a warm and\nfuzzy confirmation that the patch author has thought things through\nwhen designing the new feature.\n"},{"id":"288283","messageId":"3adf766d-9ae5-dd52-0b2a-5b250aeb566d@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqq8tymp385.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 2/2] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T18:20:05Z","receivedAt":"2016-06-03T18:20:05Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 03.06.2016 um 19:54 schrieb Junio C Hamano:\n> Jeff King <peff@peff.net> writes:\n> \n>> I know not everybody will the \"natural thing\" I claim, and if it were\n>> easy to support everywhere, I don't mind doing it. But I suspect\n>> (without thinking very hard on it) that it would make those case\n>> statements a bit harder to read and maintain.\n> \n> Oh, I agree with that 100%.  I didn't mean to suggest (let alone to\n> demand) to support the possible truncations.\n> \n> I simply was hoping that Thomas would respond with your \"For a user\n> who uses tab completion, it is natural to use --unt<TAB> so by the\n> time we use find-on-command-line, we can expect the fully-spelled\n> form\" when I asked about \"--unt=no\"; that would give us a warm and\n> fuzzy confirmation that the patch author has thought things through\n> when designing the new feature.\n\nI understood from Junio's comment [1]\n\n> $ git status -uno <TAB>\n\nthat the question was about the short option version not about how\npossible truncations are handled.\n\nOn the other side I must confess I did not think about the possibility\nthat the user truncates a long option as in --unt=all. Looking through\nthe completion file I have not found a place where the truncated\nversions are supported.\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/296220\n"},{"id":"288286","messageId":"20160603183426.13140-1-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqq8tymp385.fsf@gitster.mtv.corp.google.com","subject":"[PATCH v4 0/3] support completion for git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T18:34:23Z","receivedAt":"2016-06-03T18:34:23Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"changes since v3:\n* support short version -u of --untracked-files option\n* introduce __git_get_option_value for general usage\n* fix style issues\n* support order dependent statements like\n  git status -uno --untracked-files=all\n  properly\n\nThomas Braun (3):\n  completion: factor out untracked file modes into a variable\n  completion: add __git_get_option_value helper\n  completion: add git status\n\n contrib/completion/git-completion.bash | 98 +++++++++++++++++++++++++++++++++-\n 1 file changed, 97 insertions(+), 1 deletion(-)\n\n-- \n2.8.3.windows.1\n"},{"id":"288285","messageId":"20160603183426.13140-2-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160603183426.13140-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v4 1/3] completion: factor out untracked file modes into a variable","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T18:34:24Z","receivedAt":"2016-06-03T18:34:24Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..addea89 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n \n+__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n-- \n2.8.3.windows.1\n"},{"id":"288284","messageId":"20160603183426.13140-3-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160603183426.13140-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v4 2/3] completion: add __git_get_option_value helper","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T18:34:25Z","receivedAt":"2016-06-03T18:34:25Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"This function allows to search the commmand line and config\nfiles for an option, long and short, with mandatory value.\n\nThe function would return e.g. for the command line\n\"git status -uno --untracked-files=all\" the result\n\"all\" regardless of the config option.\n\nSigned-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 44 ++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex addea89..4bd17aa 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -803,6 +803,50 @@ __git_find_on_cmdline ()\n \tdone\n }\n \n+# Echo the value of an option set on the command line or config\n+#\n+# $1: short option name\n+# $2: long option name including =\n+# $3: list of possible values\n+# $4: config string (optional)\n+#\n+# example:\n+# result=\"$(__git_get_option_value \"-d\" \"--do-something=\"\\\n+#     \"yes no\" \"core.doSomething\")\"\n+#\n+# result is then either empty (no option set) or \"yes\" or \"no\"\n+#\n+# __git_get_option_value requires 3 arguments\n+__git_get_option_value ()\n+{\n+\tlocal c short_opt long_opt val\n+\tlocal result= values config_key word\n+\n+\tshort_opt=\"$1\"\n+\tlong_opt=\"$2\"\n+\tvalues=\"$3\"\n+\tconfig_key=\"$4\"\n+\n+\t((c = $cword - 1))\n+\twhile [ $c -ge 0 ]; do\n+\t\tword=\"${words[c]}\"\n+\t\tfor val in $values; do\n+\t\t\tif [ \"$short_opt$val\" = \"$word\" ]\n+\t\t\t|| [ \"$long_opt$val\"  = \"$word\" ]; then\n+\t\t\t\tresult=\"$val\"\n+\t\t\t\tbreak 2\n+\t\t\tfi\n+\t\tdone\n+\t\t((c--))\n+\tdone\n+\n+\tif [ -n \"$config_key\" ] && [ -z \"$result\" ]; then\n+\t\tresult=\"$(git --git-dir=\"$(__gitdir)\" config \"$config_key\")\"\n+\tfi\n+\n+\techo \"$result\"\n+}\n+\n __git_has_doubledash ()\n {\n \tlocal c=1\n-- \n2.8.3.windows.1\n"},{"id":"288287","messageId":"20160603183426.13140-4-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160603183426.13140-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v4 3/3] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-03T18:34:26Z","receivedAt":"2016-06-03T18:34:26Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 50 ++++++++++++++++++++++++++++++++++\n 1 file changed, 50 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4bd17aa..9eff33c 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1826,6 +1826,56 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tlocal complete_opt\n+\tlocal untracked_state\n+\n+\tcase \"$cur\" in\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--untracked-files=*)\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"\n+\t\t\talways never auto column row plain dense nodense\n+\t\t\t\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --porcelain --long --verbose\n+\t\t\t--untracked-files= --ignore-submodules= --ignored\n+\t\t\t--column= --no-column\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\n+\tuntracked_state=\"$(__git_get_option_value \"-u\" \"--untracked-files=\"\\\n+\t\t\"$__git_untracked_file_modes\" \"status.showUntrackedFiles\")\"\n+\n+\tcase \"$untracked_state\" in\n+\tno)\n+\t\t# --ignored option does not matter\n+\t\tcomplete_opt=\n+\t\t;;\n+\tall|normal|*)\n+\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n+\n+\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n+\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\n+\t__git_complete_index_file \"$complete_opt\"\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n-- \n2.8.3.windows.1\n"},{"id":"288464","messageId":"xmqqmvmyxksj.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"20160603183426.13140-4-thomas.braun@virtuell-zuhause.de","subject":"Re: [PATCH v4 3/3] completion: add git status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-06T17:57:16Z","receivedAt":"2016-06-06T17:57:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n\n> +\tcase \"$cur\" in\n> +\t--ignore-submodules=*)\n> +\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--untracked-files=*)\n> +\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--column=*)\n> +\t\t__gitcomp \"\n> +\t\t\talways never auto column row plain dense nodense\n> +\t\t\t\" \"\" \"${cur##--column=}\"\n> +\t\treturn\n> +\t\t;;\n> +\t--*)\n> +\t\t__gitcomp \"\n> +\t\t\t--short --branch --porcelain --long --verbose\n> +\t\t\t--untracked-files= --ignore-submodules= --ignored\n> +\t\t\t--column= --no-column\n> +\t\t\t\"\n> +\t\treturn\n> +\t\t;;\n> +\tesac\n> +\n> +\tuntracked_state=\"$(__git_get_option_value \"-u\" \"--untracked-files=\"\\\n\nIf you have a SP before that backslash, you can avoid getting\nmisunderstood that you are attempting to extend that string\n\"--untracked-files=\".  The backslash is telling the shell that there\nare more arguments to come, and it is misleading to rely on the fast\nthat the next line happens to begin with a whitespace.\n\n> +\t\t\"$__git_untracked_file_modes\" \"status.showUntrackedFiles\")\"\n\n\n> +\tcase \"$untracked_state\" in\n> +\tno)\n> +\t\t# --ignored option does not matter\n> +\t\tcomplete_opt=\n> +\t\t;;\n> +\tall|normal|*)\n> +\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n> +\n> +\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n> +\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n> +\t\tfi\n> +\t\t;;\n> +\tesac\n> +\n> +\t__git_complete_index_file \"$complete_opt\"\n> +}\n> +\n>  __git_config_get_set_variables ()\n>  {\n>  \tlocal prevword word config_file= c=$cword\n"},{"id":"288466","messageId":"xmqqh9d6xki6.fsf@gitster.mtv.corp.google.com","threadId":"42504","inReplyTo":"20160603183426.13140-1-thomas.braun@virtuell-zuhause.de","subject":"Re: [PATCH v4 0/3] support completion for git status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-06-06T18:03:29Z","receivedAt":"2016-06-06T18:03:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n\n> changes since v3:\n> * support short version -u of --untracked-files option\n> * introduce __git_get_option_value for general usage\n> * fix style issues\n> * support order dependent statements like\n>   git status -uno --untracked-files=all\n>   properly\n>\n> Thomas Braun (3):\n>   completion: factor out untracked file modes into a variable\n>   completion: add __git_get_option_value helper\n>   completion: add git status\n>\n>  contrib/completion/git-completion.bash | 98 +++++++++++++++++++++++++++++++++-\n>  1 file changed, 97 insertions(+), 1 deletion(-)\n\nThanks.\n\nAn ack, suggestions to update, or a veto from SZEDER would carry\nmore weight than what I'd say here, but the three patches looked\nalright.\n"},{"id":"288532","messageId":"7bf0dd4a-ec78-f415-f35c-161f42c3c17d@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqqmvmyxksj.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 3/3] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-07T07:47:13Z","receivedAt":"2016-06-07T07:47:13Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Am 06.06.2016 um 19:57 schrieb Junio C Hamano:\n> Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:\n> \n>> +\tcase \"$cur\" in\n>> +\t--ignore-submodules=*)\n>> +\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n>> +\t\treturn\n>> +\t\t;;\n>> +\t--untracked-files=*)\n>> +\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n>> +\t\treturn\n>> +\t\t;;\n>> +\t--column=*)\n>> +\t\t__gitcomp \"\n>> +\t\t\talways never auto column row plain dense nodense\n>> +\t\t\t\" \"\" \"${cur##--column=}\"\n>> +\t\treturn\n>> +\t\t;;\n>> +\t--*)\n>> +\t\t__gitcomp \"\n>> +\t\t\t--short --branch --porcelain --long --verbose\n>> +\t\t\t--untracked-files= --ignore-submodules= --ignored\n>> +\t\t\t--column= --no-column\n>> +\t\t\t\"\n>> +\t\treturn\n>> +\t\t;;\n>> +\tesac\n>> +\n>> +\tuntracked_state=\"$(__git_get_option_value \"-u\" \"--untracked-files=\"\\\n> \n> If you have a SP before that backslash, you can avoid getting\n> misunderstood that you are attempting to extend that string\n> \"--untracked-files=\".  The backslash is telling the shell that there\n> are more arguments to come, and it is misleading to rely on the fast\n> that the next line happens to begin with a whitespace.\n\nThanks, will be fixed in the reroll.\n\n>> +\t\t\"$__git_untracked_file_modes\" \"status.showUntrackedFiles\")\"\n> \n> \n>> +\tcase \"$untracked_state\" in\n>> +\tno)\n>> +\t\t# --ignored option does not matter\n>> +\t\tcomplete_opt=\n>> +\t\t;;\n>> +\tall|normal|*)\n>> +\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n>> +\n>> +\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n>> +\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n>> +\t\tfi\n>> +\t\t;;\n>> +\tesac\n>> +\n>> +\t__git_complete_index_file \"$complete_opt\"\n>> +}\n>> +\n>>  __git_config_get_set_variables ()\n>>  {\n>>  \tlocal prevword word config_file= c=$cword\n> \n"},{"id":"288882","messageId":"20160610101206.5760-3-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160610101206.5760-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v5 2/3] completion: add __git_get_option_value helper","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:12:05Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"This function allows to search the commmand line and config\nfiles for an option, long and short, with mandatory value.\n\nThe function would return e.g. for the command line\n\"git status -uno --untracked-files=all\" the result\n\"all\" regardless of the config option.\n\nSigned-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 44 ++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex addea89..0bf67c9 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -803,6 +803,50 @@ __git_find_on_cmdline ()\n \tdone\n }\n \n+# Echo the value of an option set on the command line or config\n+#\n+# $1: short option name\n+# $2: long option name including =\n+# $3: list of possible values\n+# $4: config string (optional)\n+#\n+# example:\n+# result=\"$(__git_get_option_value \"-d\" \"--do-something=\" \\\n+#     \"yes no\" \"core.doSomething\")\"\n+#\n+# result is then either empty (no option set) or \"yes\" or \"no\"\n+#\n+# __git_get_option_value requires 3 arguments\n+__git_get_option_value ()\n+{\n+\tlocal c short_opt long_opt val\n+\tlocal result= values config_key word\n+\n+\tshort_opt=\"$1\"\n+\tlong_opt=\"$2\"\n+\tvalues=\"$3\"\n+\tconfig_key=\"$4\"\n+\n+\t((c = $cword - 1))\n+\twhile [ $c -ge 0 ]; do\n+\t\tword=\"${words[c]}\"\n+\t\tfor val in $values; do\n+\t\t\tif [ \"$short_opt$val\" = \"$word\" ] ||\n+\t\t\t   [ \"$long_opt$val\"  = \"$word\" ]; then\n+\t\t\t\tresult=\"$val\"\n+\t\t\t\tbreak 2\n+\t\t\tfi\n+\t\tdone\n+\t\t((c--))\n+\tdone\n+\n+\tif [ -n \"$config_key\" ] && [ -z \"$result\" ]; then\n+\t\tresult=\"$(git --git-dir=\"$(__gitdir)\" config \"$config_key\")\"\n+\tfi\n+\n+\techo \"$result\"\n+}\n+\n __git_has_doubledash ()\n {\n \tlocal c=1\n-- \n2.8.4.windows.1\n"},{"id":"288883","messageId":"20160610101206.5760-1-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqq8tymp385.fsf@gitster.mtv.corp.google.com","subject":"[PATCH v5 0/3] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:12:03Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Changes since v4:\n- Add SP before backslash at EOL\n- Fix line continuation issue in __git_get_option_value,\n  now t9902 passes again\n\nThomas Braun (3):\n  completion: factor out untracked file modes into a variable\n  completion: add __git_get_option_value helper\n  completion: add git status\n\n contrib/completion/git-completion.bash | 98 +++++++++++++++++++++++++++++++++-\n 1 file changed, 97 insertions(+), 1 deletion(-)\n\n-- \n2.8.4.windows.1\n"},{"id":"288884","messageId":"20160610102400.9864-2-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160610102400.9864-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v5 3/3] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:24:00Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 50 ++++++++++++++++++++++++++++++++++\n 1 file changed, 50 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0bf67c9..ddda5e5 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1826,6 +1826,56 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tlocal complete_opt\n+\tlocal untracked_state\n+\n+\tcase \"$cur\" in\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--untracked-files=*)\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"\n+\t\t\talways never auto column row plain dense nodense\n+\t\t\t\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --porcelain --long --verbose\n+\t\t\t--untracked-files= --ignore-submodules= --ignored\n+\t\t\t--column= --no-column\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\n+\tuntracked_state=\"$(__git_get_option_value \"-u\" \"--untracked-files=\" \\\n+\t\t\"$__git_untracked_file_modes\" \"status.showUntrackedFiles\")\"\n+\n+\tcase \"$untracked_state\" in\n+\tno)\n+\t\t# --ignored option does not matter\n+\t\tcomplete_opt=\n+\t\t;;\n+\tall|normal|*)\n+\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n+\n+\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n+\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\n+\t__git_complete_index_file \"$complete_opt\"\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n-- \n2.8.4.windows.1\n"},{"id":"288885","messageId":"20160610102400.9864-1-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"xmqq8tymp385.fsf@gitster.mtv.corp.google.com","subject":"[PATCH v5 1/3] completion: factor out untracked file modes into a variable","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:23:59Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..addea89 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n \n+__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n-- \n2.8.4.windows.1\n"},{"id":"288887","messageId":"20160610101206.5760-2-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160610101206.5760-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v5 1/3] completion: factor out untracked file modes into a variable","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:12:04Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 3402475..addea89 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1098,6 +1098,8 @@ _git_clone ()\n \tesac\n }\n \n+__git_untracked_file_modes=\"all no normal\"\n+\n _git_commit ()\n {\n \tcase \"$prev\" in\n@@ -1119,7 +1121,7 @@ _git_commit ()\n \t\treturn\n \t\t;;\n \t--untracked-files=*)\n-\t\t__gitcomp \"all no normal\" \"\" \"${cur##--untracked-files=}\"\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n \t\treturn\n \t\t;;\n \t--*)\n-- \n2.8.4.windows.1\n"},{"id":"288888","messageId":"20160610101206.5760-4-thomas.braun@virtuell-zuhause.de","threadId":"42504","inReplyTo":"20160610101206.5760-1-thomas.braun@virtuell-zuhause.de","subject":"[PATCH v5 3/3] completion: add git status","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-10T10:12:06Z","receivedAt":"2016-06-16T02:19:50Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n---\n contrib/completion/git-completion.bash | 50 ++++++++++++++++++++++++++++++++++\n 1 file changed, 50 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0bf67c9..ddda5e5 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1826,6 +1826,56 @@ _git_stage ()\n \t_git_add\n }\n \n+_git_status ()\n+{\n+\tlocal complete_opt\n+\tlocal untracked_state\n+\n+\tcase \"$cur\" in\n+\t--ignore-submodules=*)\n+\t\t__gitcomp \"none untracked dirty all\" \"\" \"${cur##--ignore-submodules=}\"\n+\t\treturn\n+\t\t;;\n+\t--untracked-files=*)\n+\t\t__gitcomp \"$__git_untracked_file_modes\" \"\" \"${cur##--untracked-files=}\"\n+\t\treturn\n+\t\t;;\n+\t--column=*)\n+\t\t__gitcomp \"\n+\t\t\talways never auto column row plain dense nodense\n+\t\t\t\" \"\" \"${cur##--column=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"\n+\t\t\t--short --branch --porcelain --long --verbose\n+\t\t\t--untracked-files= --ignore-submodules= --ignored\n+\t\t\t--column= --no-column\n+\t\t\t\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\n+\tuntracked_state=\"$(__git_get_option_value \"-u\" \"--untracked-files=\" \\\n+\t\t\"$__git_untracked_file_modes\" \"status.showUntrackedFiles\")\"\n+\n+\tcase \"$untracked_state\" in\n+\tno)\n+\t\t# --ignored option does not matter\n+\t\tcomplete_opt=\n+\t\t;;\n+\tall|normal|*)\n+\t\tcomplete_opt=\"--cached --directory --no-empty-directory --others\"\n+\n+\t\tif [ -n \"$(__git_find_on_cmdline \"--ignored\")\" ]; then\n+\t\t\tcomplete_opt=\"$complete_opt --ignored --exclude=*\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\n+\t__git_complete_index_file \"$complete_opt\"\n+}\n+\n __git_config_get_set_variables ()\n {\n \tlocal prevword word config_file= c=$cword\n-- \n2.8.4.windows.1\n"},{"id":"288924","messageId":"20160610151020.Horde.AfAwgXgKC_jSSpyr60T85sW@webmail.informatik.kit.edu","threadId":"42504","inReplyTo":"20160603183426.13140-3-thomas.braun@virtuell-zuhause.de","subject":"Re: [PATCH v4 2/3] completion: add __git_get_option_value helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2016-06-10T13:10:20Z","receivedAt":"2016-06-16T02:19:51Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nHallo Thomas,\n\nI saw v5 hit my mailbox while writing this.  I glanced it over and it\nseems my comments here apply to that version as well.\n\nQuoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n\n> This function allows to search the commmand line and config\n> files for an option, long and short, with mandatory value.\n>\n> The function would return e.g. for the command line\n> \"git status -uno --untracked-files=all\" the result\n> \"all\" regardless of the config option.\n\nWow, regarding my earlier remark about bonus points: I didn't realize\nthat there were so many bonus point to give away :)\n\n> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n> ---\n> contrib/completion/git-completion.bash | 44  \n> ++++++++++++++++++++++++++++++++++\n> 1 file changed, 44 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.bash  \n> b/contrib/completion/git-completion.bash\n> index addea89..4bd17aa 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -803,6 +803,50 @@ __git_find_on_cmdline ()\n> \tdone\n> }\n>\n> +# Echo the value of an option set on the command line or config\n> +#\n> +# $1: short option name\n> +# $2: long option name including =\n\nI'm not sure about requiring the '=', the function could just append\nit as necessary.  More on this below.\n\n> +# $3: list of possible values\n> +# $4: config string (optional)\n\nI don't understand why the list of possible values is necessary.\n\nThis function will be called when the caller wants to take different\nactions based on different values, so the caller will process the\nfunction's output with a case statement or an if-else chain, both of\nwhich would be perfectly capable to ignore whatever invalid value the\nuser might have specified.  Therefore, I think this function doesn't\nneed the list of possible values, it should just return whatever value\nit found after the option.\n\n> +# example:\n> +# result=\"$(__git_get_option_value \"-d\" \"--do-something=\"\\\n> +#     \"yes no\" \"core.doSomething\")\"\n> +#\n> +# result is then either empty (no option set) or \"yes\" or \"no\"\n> +#\n> +# __git_get_option_value requires 3 arguments\n> +__git_get_option_value ()\n> +{\n> +\tlocal c short_opt long_opt val\n> +\tlocal result= values config_key word\n> +\n> +\tshort_opt=\"$1\"\n> +\tlong_opt=\"$2\"\n> +\tvalues=\"$3\"\n> +\tconfig_key=\"$4\"\n\nThese can be assigned when the variables are declared, saving a couple\nof lines.\n\n> +\t((c = $cword - 1))\n> +\twhile [ $c -ge 0 ]; do\n\nSearching from the end of the command line, so even if someone were to\ndo a 'git status -uall -unormal -uno <TAB>', this would still do the\nright thing.  Good!\n\nHowever ;)\nJust for fun imagine following:\n\n       $ >-uno\n       $ git status -- -uno <TAB>\n\n'git status' treats that '-uno' after the doubledash as a filename,\nbut this function interprets it as an option, and on the subsequent\nTAB the completion script won't list untracked files.\n\nI'm tempted to say that this is such a pathological corner case that\nit doesn't worth worrying about.\n\n> +\t\tword=\"${words[c]}\"\n> +\t\tfor val in $values; do\n\nWithout the possible values argument this inner loop could go away.\n\n> +\t\t\tif [ \"$short_opt$val\" = \"$word\" ]\n> +\t\t\t|| [ \"$long_opt$val\"  = \"$word\" ]; then\n> +\t\t\t\tresult=\"$val\"\n> +\t\t\t\tbreak 2\n\nYou could just 'echo \"$val\"' or rather ${word#$short_opt} and return\nhere ...\n\n> +\t\t\tfi\n> +\t\tdone\n> +\t\t((c--))\n> +\tdone\n> +\n> +\tif [ -n \"$config_key\" ] && [ -z \"$result\" ]; then\n\n... and that would make the second condition unnecessary here ...\n\n> +\t\tresult=\"$(git --git-dir=\"$(__gitdir)\" config \"$config_key\")\"\n\n... and this could just be a simple 'git config' execution, without\ncommand substitution ...\n\n> +\tfi\n> +\n> +\techo \"$result\"\n\n... and this echo could go away as well.\n\n> +}\n> +\n> __git_has_doubledash ()\n> {\n> \tlocal c=1\n> --\n> 2.8.3.windows.1\n\n\nHowever, I'm not sure we need or want this helper function _at the\nmoment_.  Yes, in general helper functions are good, and in this case\nit makes _git_status() easier to follow, but it has some drawbacks,\ntoo:\n\n   - It has a single callsite: the upcoming _git_status().  No other\n     existing case springs to mind where it could be used, i.e. where\n     different values of an option would require different actions from\n     the completion script.  Maybe we'll have one in the future, maybe\n     not.\n\n   - This function works only with the \"stuck\" form of options, i.e.\n     '--opt=val' or '-oval', which is mostly sufficient in this case,\n     because 'git status' understands only this form.  However, it\n     doesn't work with \"unstuck\" options, i.e. '--opt val' or '-o val'.\n     In many cases git supports only this \"unstuck\" form, and there are\n     many cases where it supports both for a given option.  We can't know\n     which form a future callsite might need, but requiring the '=' as\n     part of the long option seems to paint us into a corner.\n\n   - I wrote \"mostly sufficient\" above, because 'git status' does accept\n     a valueless '-u|--untracked-files' option, too, e.g.:\n\n       $ git config status.showUntrackedFiles no\n       $ git status --untracked-files\n\n     lists untracked files, therefore the completion script should list\n     them as well.  Your function can't cope with this case, and I'm not\n     sure how it and its caller could differentiate between the presence\n     of such a valueless option and no option at all.  Perhaps with an\n     additional optional function parameter holding the default value\n     that should be echo-ed when a valueless option is encountered.\n\nIf this function were not a function but its logic were embedded into\n_git_status(), then we wouldn't have to spend any effort _now_ to come\nup with a proper calling convention that can cope with stuck vs.\nunstuck vs. both forms of options and with valueless options.  We would\ndeal with all that and the necessary refactorization when (or if ever)\nthere's a second potential callsite.  Embedding into _git_status()\nwould give you more freedom to deal with the valueless '-u' option,\ntoo.  If embedded, some of my in-code comments wouldn't apply anymore,\nof course.\n\nI'm in favor of crossing the bridge when we get there.\n\n\nGábor\n"},{"id":"290139","messageId":"1072705888.508793.1466871181310.JavaMail.open-xchange@app03.ox.hosteurope.de","threadId":"42504","inReplyTo":"20160610151020.Horde.AfAwgXgKC_jSSpyr60T85sW@webmail.informatik.kit.edu","subject":"Re: [PATCH v4 2/3] completion: add __git_get_option_value helper","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2016-06-25T16:13:01Z","receivedAt":"2016-06-25T16:13:11Z","isPatch":true,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"> SZEDER Gábor <szeder@ira.uka.de> hat am 10. Juni 2016 um 15:10 geschrieben:\n> \n> Hallo Thomas,\n> \n> I saw v5 hit my mailbox while writing this.  I glanced it over and it\n> seems my comments here apply to that version as well.\n\nHi Gábor,\n\nthanks for your comments.\nI plan to send a reroll in the near future adressing your remarks.\n\nBye,\nThomas\n\n> Quoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:\n> \n> > This function allows to search the commmand line and config\n> > files for an option, long and short, with mandatory value.\n> >\n> > The function would return e.g. for the command line\n> > \"git status -uno --untracked-files=all\" the result\n> > \"all\" regardless of the config option.\n> \n> Wow, regarding my earlier remark about bonus points: I didn't realize\n> that there were so many bonus point to give away :)\n> \n> > Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>\n> > ---\n> > contrib/completion/git-completion.bash | 44  \n> > ++++++++++++++++++++++++++++++++++\n> > 1 file changed, 44 insertions(+)\n> >\n> > diff --git a/contrib/completion/git-completion.bash  \n> > b/contrib/completion/git-completion.bash\n> > index addea89..4bd17aa 100644\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -803,6 +803,50 @@ __git_find_on_cmdline ()\n> > \tdone\n> > }\n> >\n> > +# Echo the value of an option set on the command line or config\n> > +#\n> > +# $1: short option name\n> > +# $2: long option name including =\n> \n> I'm not sure about requiring the '=', the function could just append\n> it as necessary.  More on this below.\n> \n> > +# $3: list of possible values\n> > +# $4: config string (optional)\n> \n> I don't understand why the list of possible values is necessary.\n> \n> This function will be called when the caller wants to take different\n> actions based on different values, so the caller will process the\n> function's output with a case statement or an if-else chain, both of\n> which would be perfectly capable to ignore whatever invalid value the\n> user might have specified.  Therefore, I think this function doesn't\n> need the list of possible values, it should just return whatever value\n> it found after the option.\n> \n> > +# example:\n> > +# result=\"$(__git_get_option_value \"-d\" \"--do-something=\"\\\n> > +#     \"yes no\" \"core.doSomething\")\"\n> > +#\n> > +# result is then either empty (no option set) or \"yes\" or \"no\"\n> > +#\n> > +# __git_get_option_value requires 3 arguments\n> > +__git_get_option_value ()\n> > +{\n> > +\tlocal c short_opt long_opt val\n> > +\tlocal result= values config_key word\n> > +\n> > +\tshort_opt=\"$1\"\n> > +\tlong_opt=\"$2\"\n> > +\tvalues=\"$3\"\n> > +\tconfig_key=\"$4\"\n> \n> These can be assigned when the variables are declared, saving a couple\n> of lines.\n> \n> > +\t((c = $cword - 1))\n> > +\twhile [ $c -ge 0 ]; do\n> \n> Searching from the end of the command line, so even if someone were to\n> do a 'git status -uall -unormal -uno <TAB>', this would still do the\n> right thing.  Good!\n> \n> However ;)\n> Just for fun imagine following:\n> \n>        $ >-uno\n>        $ git status -- -uno <TAB>\n> \n> 'git status' treats that '-uno' after the doubledash as a filename,\n> but this function interprets it as an option, and on the subsequent\n> TAB the completion script won't list untracked files.\n> \n> I'm tempted to say that this is such a pathological corner case that\n> it doesn't worth worrying about.\n> \n> > +\t\tword=\"${words[c]}\"\n> > +\t\tfor val in $values; do\n> \n> Without the possible values argument this inner loop could go away.\n> \n> > +\t\t\tif [ \"$short_opt$val\" = \"$word\" ]\n> > +\t\t\t|| [ \"$long_opt$val\"  = \"$word\" ]; then\n> > +\t\t\t\tresult=\"$val\"\n> > +\t\t\t\tbreak 2\n> \n> You could just 'echo \"$val\"' or rather ${word#$short_opt} and return\n> here ...\n> \n> > +\t\t\tfi\n> > +\t\tdone\n> > +\t\t((c--))\n> > +\tdone\n> > +\n> > +\tif [ -n \"$config_key\" ] && [ -z \"$result\" ]; then\n> \n> ... and that would make the second condition unnecessary here ...\n> \n> > +\t\tresult=\"$(git --git-dir=\"$(__gitdir)\" config \"$config_key\")\"\n> \n> ... and this could just be a simple 'git config' execution, without\n> command substitution ...\n> \n> > +\tfi\n> > +\n> > +\techo \"$result\"\n> \n> ... and this echo could go away as well.\n> \n> > +}\n> > +\n> > __git_has_doubledash ()\n> > {\n> > \tlocal c=1\n> > --\n> > 2.8.3.windows.1\n> \n> \n> However, I'm not sure we need or want this helper function _at the\n> moment_.  Yes, in general helper functions are good, and in this case\n> it makes _git_status() easier to follow, but it has some drawbacks,\n> too:\n> \n>    - It has a single callsite: the upcoming _git_status().  No other\n>      existing case springs to mind where it could be used, i.e. where\n>      different values of an option would require different actions from\n>      the completion script.  Maybe we'll have one in the future, maybe\n>      not.\n> \n>    - This function works only with the \"stuck\" form of options, i.e.\n>      '--opt=val' or '-oval', which is mostly sufficient in this case,\n>      because 'git status' understands only this form.  However, it\n>      doesn't work with \"unstuck\" options, i.e. '--opt val' or '-o val'.\n>      In many cases git supports only this \"unstuck\" form, and there are\n>      many cases where it supports both for a given option.  We can't know\n>      which form a future callsite might need, but requiring the '=' as\n>      part of the long option seems to paint us into a corner.\n> \n>    - I wrote \"mostly sufficient\" above, because 'git status' does accept\n>      a valueless '-u|--untracked-files' option, too, e.g.:\n> \n>        $ git config status.showUntrackedFiles no\n>        $ git status --untracked-files\n> \n>      lists untracked files, therefore the completion script should list\n>      them as well.  Your function can't cope with this case, and I'm not\n>      sure how it and its caller could differentiate between the presence\n>      of such a valueless option and no option at all.  Perhaps with an\n>      additional optional function parameter holding the default value\n>      that should be echo-ed when a valueless option is encountered.\n> \n> If this function were not a function but its logic were embedded into\n> _git_status(), then we wouldn't have to spend any effort _now_ to come\n> up with a proper calling convention that can cope with stuck vs.\n> unstuck vs. both forms of options and with valueless options.  We would\n> deal with all that and the necessary refactorization when (or if ever)\n> there's a second potential callsite.  Embedding into _git_status()\n> would give you more freedom to deal with the valueless '-u' option,\n> too.  If embedded, some of my in-code comments wouldn't apply anymore,\n> of course.\n> \n> I'm in favor of crossing the bridge when we get there.\n> \n> \n> Gábor\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"}]}