{"thread":{"id":"51837","subject":"[PATCH 0/2] completion: teach rebase and archive to use __gitcomp_builtin","startedAt":"2019-09-12T19:43:57Z","lastAt":"2019-09-12T20:44:56Z","messageCount":4,"participants":["Denton Liu","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"382250","messageId":"cover.1568317093.git.liu.denton@gmail.com","threadId":"51837","inReplyTo":null,"subject":"[PATCH 0/2] completion: teach rebase and archive to use __gitcomp_builtin","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-09-12T19:43:52Z","receivedAt":"2019-09-12T19:43:57Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Currently, the completion function for rebase and archive don't take\nadvantage of __gitcomp_builtin(). Teach them to use it so that future\nchanges to options will automatically be included by the completion\nscript with no extra work.\n\nI discovered rebase wasn't using it and fixed that and I started looking\nfor other low-hanging fruit to fix. I deliberately left stuff like diff\nand log alone since that's a whole Pandora's box that I don't really\nwant to open right now.\n\n\nDenton Liu (2):\n  completion: teach rebase to use __gitcomp_builtin\n  completion: teach archive to use __gitcomp_builtin\n\n contrib/completion/git-completion.bash | 27 ++++++++------------------\n 1 file changed, 8 insertions(+), 19 deletions(-)\n\n-- \n2.23.0.37.g745f681289\n\n"},{"id":"382251","messageId":"7c4f2361842f5a9cbaf6130cafe1dd77f75e19e0.1568317093.git.liu.denton@gmail.com","threadId":"51837","inReplyTo":"cover.1568317093.git.liu.denton@gmail.com","subject":"[PATCH 1/2] completion: teach rebase to use __gitcomp_builtin","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-09-12T19:43:55Z","receivedAt":"2019-09-12T19:43:59Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Currently, _git_rebase() uses a hardcoded list of options for its\ncompletion. However, we can use __gitcomp_builtin() to get a dynamically\ngenerated list of completions instead.\n\nTeach _git_rebase() to use __gitcomp_builtin() so that newly implemented\noptions in rebase will be automatically completed without any mucking\naround in git-completion.bash.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n contrib/completion/git-completion.bash | 22 +++++++---------------\n 1 file changed, 7 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e087c4bf00..365edff639 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2004,15 +2004,18 @@ _git_range_diff ()\n \t__git_complete_revlist\n }\n \n+__git_rebase_inprogress_options=\"--continue --skip --abort --quit --show-current-patch\"\n+__git_rebase_interactive_inprogress_options=\"$__git_rebase_inprogress_options --edit-todo\"\n+\n _git_rebase ()\n {\n \t__git_find_repo_path\n \tif [ -f \"$__git_repo_path\"/rebase-merge/interactive ]; then\n-\t\t__gitcomp \"--continue --skip --abort --quit --edit-todo --show-current-patch\"\n+\t\t__gitcomp \"$__git_rebase_interactive_inprogress_options\"\n \t\treturn\n \telif [ -d \"$__git_repo_path\"/rebase-apply ] || \\\n \t     [ -d \"$__git_repo_path\"/rebase-merge ]; then\n-\t\t__gitcomp \"--continue --skip --abort --quit --show-current-patch\"\n+\t\t__gitcomp \"$__git_rebase_inprogress_options\"\n \t\treturn\n \tfi\n \t__git_complete_strategy && return\n@@ -2022,19 +2025,8 @@ _git_rebase ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--onto --merge --strategy --interactive\n-\t\t\t--rebase-merges --preserve-merges --stat --no-stat\n-\t\t\t--committer-date-is-author-date --ignore-date\n-\t\t\t--ignore-whitespace --whitespace=\n-\t\t\t--autosquash --no-autosquash\n-\t\t\t--fork-point --no-fork-point\n-\t\t\t--autostash --no-autostash\n-\t\t\t--verify --no-verify\n-\t\t\t--keep-empty --root --force-rebase --no-ff\n-\t\t\t--rerere-autoupdate\n-\t\t\t--exec\n-\t\t\t\"\n+\t\t__gitcomp_builtin rebase \"\" \\\n+\t\t\t\"$__git_rebase_interactive_inprogress_options\"\n \n \t\treturn\n \tesac\n-- \n2.23.0.37.g745f681289\n\n"},{"id":"382252","messageId":"39d6091ce636b2d732d589b55e7686796694e994.1568317093.git.liu.denton@gmail.com","threadId":"51837","inReplyTo":"cover.1568317093.git.liu.denton@gmail.com","subject":"[PATCH 2/2] completion: teach archive to use __gitcomp_builtin","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-09-12T19:43:57Z","receivedAt":"2019-09-12T19:44:01Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Currently, _git_archive() uses a hardcoded list of options for its\ncompletion. However, we can use __gitcomp_builtin() to get a dynamically\ngenerated list of completions instead.\n\nTeach _git_archive() to use __gitcomp_builtin() so that newly\nimplemented options in archive will be automatically completed without\nany mucking around in git-completion.bash. While we're at it, teach it\nto complete the missing `--worktree-attributes` option as well.\n\nUnfortunately, since some args are passed through from cmd_archive() to\nwrite_archive() (which calls parse_archive_args()), there's no way that a\n`--git-completion-helper` arg can end up reaching parse_archive_args()\nsince the first call to parse_options() will end up calling exit(0). As\na result, we have to carry the options supported by write_archive() in\nthe hardcoded string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n contrib/completion/git-completion.bash | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 365edff639..7b1ab46f0b 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1250,10 +1250,7 @@ _git_archive ()\n \t\treturn\n \t\t;;\n \t--*)\n-\t\t__gitcomp \"\n-\t\t\t--format= --list --verbose\n-\t\t\t--prefix= --remote= --exec= --output\n-\t\t\t\"\n+\t\t__gitcomp_builtin archive \"--format= --list --verbose --prefix= --worktree-attributes\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n2.23.0.37.g745f681289\n\n"},{"id":"382257","messageId":"xmqqa7b9fdmn.fsf@gitster-ct.c.googlers.com","threadId":"51837","inReplyTo":"cover.1568317093.git.liu.denton@gmail.com","subject":"Re: [PATCH 0/2] completion: teach rebase and archive to use __gitcomp_builtin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-09-12T20:44:48Z","receivedAt":"2019-09-12T20:44:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> Currently, the completion function for rebase and archive don't take\n> advantage of __gitcomp_builtin(). Teach them to use it so that future\n> changes to options will automatically be included by the completion\n> script with no extra work.\n\nNice ;-)\n"}]}