Commit a9baccc
help / completion: make "git help" do the hard work
The "help" builtin has been able to emit configuration variables since
e17ca92 (completion: drop the hard coded list of config vars,
2018-05-26), but it hasn't produced exactly the format the completion
script wanted. Let's do that.
We got partway there in 2675ea1 (completion: use 'sort -u' to
deduplicate config variable names, 2019-08-13) and
d943887 (completion: deduplicate configuration sections,
2019-08-13), but after both we still needed some sorting,
de-duplicating and awk post-processing of the list.
We can instead simply do the relevant parsing ourselves (we were doing
most of it already), and call string_list_remove_duplicates() after
already sorting the list, so the caller doesn't need to invoke "sort
-u". The "--config-for-completion" output is the same as before after
being passed through "sort -u".
Then add a new "--config-sections-for-completion" option. Under that
output we'll emit config sections like "alias" (instead of "alias." in
the --config-for-completion output).
We need to be careful to leave the "--config-for-completion" option
compatible with users git, but are still running a shell with an older
git-completion.bash. If we e.g. changed the option name they'd see
messages about git-completion.bash being unable to find the
"--config-for-completion" option.
Such backwards compatibility isn't something we should bend over
backwards for, it's only helping users who:
* Upgrade git
* Are in an old shell
* The git-completion.bash in that shell hasn't cached the old
"--config-for-completion" output already.
But since it's easy in this case to retain compatibility, let's do it,
the older versions of git-completion.bash won't care that the input
they get doesn't change after a "sort -u".
While we're at it let's make "--config-for-completion" die if there's
anything left over in "argc", and do the same in the new
"--config-sections-for-completion" option.
Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 5a5f04d commit a9baccc
File tree
3 files changed
+65
-27
lines changed- builtin
- contrib/completion
- t
3 files changed
+65
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| 48 | + | |
42 | 49 | | |
43 | 50 | | |
44 | 51 | | |
| |||
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| 73 | + | |
| 74 | + | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
| |||
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | | - | |
| 94 | + | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
| |||
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
| 112 | + | |
| 113 | + | |
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
| |||
130 | 141 | | |
131 | 142 | | |
132 | 143 | | |
| 144 | + | |
| 145 | + | |
133 | 146 | | |
134 | | - | |
| 147 | + | |
| 148 | + | |
135 | 149 | | |
136 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
137 | 156 | | |
138 | | - | |
139 | 157 | | |
140 | 158 | | |
141 | 159 | | |
142 | | - | |
143 | | - | |
| 160 | + | |
| 161 | + | |
144 | 162 | | |
145 | 163 | | |
146 | 164 | | |
147 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
148 | 168 | | |
149 | 169 | | |
150 | 170 | | |
151 | 171 | | |
152 | 172 | | |
153 | 173 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
159 | 178 | | |
160 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
161 | 184 | | |
162 | 185 | | |
163 | 186 | | |
| |||
589 | 612 | | |
590 | 613 | | |
591 | 614 | | |
592 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
593 | 621 | | |
594 | 622 | | |
595 | 623 | | |
596 | 624 | | |
597 | | - | |
| 625 | + | |
598 | 626 | | |
599 | 627 | | |
600 | 628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2503 | 2503 | | |
2504 | 2504 | | |
2505 | 2505 | | |
2506 | | - | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
2507 | 2514 | | |
2508 | 2515 | | |
2509 | 2516 | | |
| |||
2717 | 2724 | | |
2718 | 2725 | | |
2719 | 2726 | | |
2720 | | - | |
2721 | | - | |
2722 | | - | |
2723 | | - | |
2724 | | - | |
2725 | | - | |
2726 | | - | |
2727 | | - | |
2728 | | - | |
2729 | | - | |
| 2727 | + | |
| 2728 | + | |
2730 | 2729 | | |
2731 | 2730 | | |
2732 | 2731 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
110 | | - | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
| |||
0 commit comments