Skip to content

Commit b0e7fb2

Browse files
committed
Merge branch 'nd/completion-more-parameters'
The command line completion (in contrib/) has been taught to complete more subcommand parameters. * nd/completion-more-parameters: completion: add more parameter value completion
2 parents 4751a16 + 5a59a23 commit b0e7fb2

File tree

18 files changed

+126
-4
lines changed

18 files changed

+126
-4
lines changed

apply.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static int parse_whitespace_option(struct apply_state *state, const char *option
5656
state->ws_error_action = correct_ws_error;
5757
return 0;
5858
}
59+
/*
60+
* Please update $__git_whitespacelist in git-completion.bash
61+
* when you add new options.
62+
*/
5963
return error(_("unrecognized whitespace option '%s'"), option);
6064
}
6165

builtin/am.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,10 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
21212121
*opt_value = PATCH_FORMAT_HG;
21222122
else if (!strcmp(arg, "mboxrd"))
21232123
*opt_value = PATCH_FORMAT_MBOXRD;
2124+
/*
2125+
* Please update $__git_patchformat in git-completion.bash
2126+
* when you add new options
2127+
*/
21242128
else
21252129
return error(_("Invalid value for --patch-format: %s"), arg);
21262130
return 0;

builtin/commit.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,10 @@ static void handle_untracked_files_arg(struct wt_status *s)
10391039
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
10401040
else if (!strcmp(untracked_files_arg, "all"))
10411041
s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
1042+
/*
1043+
* Please update $__git_untracked_file_modes in
1044+
* git-completion.bash when you add new options
1045+
*/
10421046
else
10431047
die(_("Invalid untracked files mode '%s'"), untracked_files_arg);
10441048
}
@@ -1180,6 +1184,10 @@ static int parse_and_validate_options(int argc, const char *argv[],
11801184
else if (!strcmp(cleanup_arg, "scissors"))
11811185
cleanup_mode = use_editor ? COMMIT_MSG_CLEANUP_SCISSORS :
11821186
COMMIT_MSG_CLEANUP_SPACE;
1187+
/*
1188+
* Please update _git_commit() in git-completion.bash when you
1189+
* add new options.
1190+
*/
11831191
else
11841192
die(_("Invalid cleanup mode %s"), cleanup_arg);
11851193

builtin/help.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ static enum help_format parse_help_format(const char *format)
7070
return HELP_FORMAT_INFO;
7171
if (!strcmp(format, "web") || !strcmp(format, "html"))
7272
return HELP_FORMAT_WEB;
73+
/*
74+
* Please update _git_config() in git-completion.bash when you
75+
* add new help formats.
76+
*/
7377
die(_("unrecognized help format '%s'"), format);
7478
}
7579

builtin/log.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ static int parse_decoration_style(const char *value)
8484
return DECORATE_SHORT_REFS;
8585
else if (!strcmp(value, "auto"))
8686
return auto_decoration_style();
87+
/*
88+
* Please update _git_log() in git-completion.bash when you
89+
* add new decoration styles.
90+
*/
8791
return -1;
8892
}
8993

@@ -1228,6 +1232,10 @@ static int thread_callback(const struct option *opt, const char *arg, int unset)
12281232
*thread = THREAD_SHALLOW;
12291233
else if (!strcmp(arg, "deep"))
12301234
*thread = THREAD_DEEP;
1235+
/*
1236+
* Please update _git_formatpatch() in git-completion.bash
1237+
* when you add new options.
1238+
*/
12311239
else
12321240
return 1;
12331241
return 0;

builtin/pull.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
5656
return REBASE_MERGES;
5757
else if (!strcmp(value, "interactive") || !strcmp(value, "i"))
5858
return REBASE_INTERACTIVE;
59+
/*
60+
* Please update _git_config() in git-completion.bash when you
61+
* add new rebase modes.
62+
*/
5963

6064
if (fatal)
6165
die(_("Invalid value for %s: %s"), key, value);

builtin/replace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ static int list_replace_refs(const char *pattern, const char *format)
8282
data.format = REPLACE_FORMAT_MEDIUM;
8383
else if (!strcmp(format, "long"))
8484
data.format = REPLACE_FORMAT_LONG;
85+
/*
86+
* Please update _git_replace() in git-completion.bash when
87+
* you add new format
88+
*/
8589
else
8690
return error(_("invalid replace format '%s'\n"
8791
"valid formats are 'short', 'medium' and 'long'"),

contrib/completion/git-completion.bash

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,11 @@ __git_compute_merge_strategies ()
853853
__git_merge_strategies=$(__git_list_merge_strategies)
854854
}
855855

856+
__git_merge_strategy_options="ours theirs subtree subtree= patience
857+
histogram diff-algorithm= ignore-space-change ignore-all-space
858+
ignore-space-at-eol renormalize no-renormalize no-renames
859+
find-renames find-renames= rename-threshold="
860+
856861
__git_complete_revlist_file ()
857862
{
858863
local dequoted_word pfx ls ref cur_="$cur"
@@ -996,12 +1001,21 @@ __git_complete_strategy ()
9961001
-s|--strategy)
9971002
__gitcomp "$__git_merge_strategies"
9981003
return 0
1004+
;;
1005+
-X)
1006+
__gitcomp "$__git_merge_strategy_options"
1007+
return 0
1008+
;;
9991009
esac
10001010
case "$cur" in
10011011
--strategy=*)
10021012
__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
10031013
return 0
10041014
;;
1015+
--strategy-option=*)
1016+
__gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
1017+
return 0
1018+
;;
10051019
esac
10061020
return 1
10071021
}
@@ -1163,6 +1177,7 @@ __git_count_arguments ()
11631177
}
11641178

11651179
__git_whitespacelist="nowarn warn error error-all fix"
1180+
__git_patchformat="mbox stgit stgit-series hg mboxrd"
11661181
__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
11671182

11681183
_git_am ()
@@ -1177,6 +1192,10 @@ _git_am ()
11771192
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
11781193
return
11791194
;;
1195+
--patch-format=*)
1196+
__gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
1197+
return
1198+
;;
11801199
--*)
11811200
__gitcomp_builtin am "" \
11821201
"$__git_am_inprogress_options"
@@ -1200,6 +1219,10 @@ _git_apply ()
12001219
_git_add ()
12011220
{
12021221
case "$cur" in
1222+
--chmod=*)
1223+
__gitcomp "+x -x" "" "${cur##--chmod=}"
1224+
return
1225+
;;
12031226
--*)
12041227
__gitcomp_builtin add
12051228
return
@@ -1260,6 +1283,8 @@ _git_bisect ()
12601283
esac
12611284
}
12621285

1286+
__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
1287+
12631288
_git_branch ()
12641289
{
12651290
local i c=1 only_local_ref="n" has_r="n"
@@ -1343,6 +1368,9 @@ _git_cherry_pick ()
13431368
__gitcomp "$__git_cherry_pick_inprogress_options"
13441369
return
13451370
fi
1371+
1372+
__git_complete_strategy && return
1373+
13461374
case "$cur" in
13471375
--*)
13481376
__gitcomp_builtin cherry-pick "" \
@@ -1506,6 +1534,10 @@ _git_fetch ()
15061534
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
15071535
return
15081536
;;
1537+
--filter=*)
1538+
__gitcomp "blob:none blob:limit= sparse:oid= sparse:path=" "" "${cur##--filter=}"
1539+
return
1540+
;;
15091541
--*)
15101542
__gitcomp_builtin fetch
15111543
return
@@ -1702,8 +1734,8 @@ __git_log_shortlog_options="
17021734
--all-match --invert-grep
17031735
"
17041736

1705-
__git_log_pretty_formats="oneline short medium full fuller email raw format:"
1706-
__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1737+
__git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd"
1738+
__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
17071739

17081740
_git_log ()
17091741
{
@@ -2221,7 +2253,7 @@ _git_config ()
22212253
return
22222254
;;
22232255
diff.submodule)
2224-
__gitcomp "log short"
2256+
__gitcomp "$__git_diff_submodule_formats"
22252257
return
22262258
;;
22272259
help.format)
@@ -2388,6 +2420,10 @@ _git_remote ()
23882420
_git_replace ()
23892421
{
23902422
case "$cur" in
2423+
--format=*)
2424+
__gitcomp "short medium long" "" "${cur##--format=}"
2425+
return
2426+
;;
23912427
--*)
23922428
__gitcomp_builtin replace
23932429
return
@@ -2429,6 +2465,7 @@ _git_revert ()
24292465
__gitcomp "$__git_revert_inprogress_options"
24302466
return
24312467
fi
2468+
__git_complete_strategy && return
24322469
case "$cur" in
24332470
--*)
24342471
__gitcomp_builtin revert "" \

date.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,10 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
921921
return DATE_UNIX;
922922
if (skip_prefix(format, "format", end))
923923
return DATE_STRFTIME;
924+
/*
925+
* Please update $__git_log_date_formats in
926+
* git-completion.bash when you add new formats.
927+
*/
924928

925929
die("unknown date format %s", format);
926930
}

diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ static int parse_submodule_params(struct diff_options *options, const char *valu
179179
options->submodule_format = DIFF_SUBMODULE_SHORT;
180180
else if (!strcmp(value, "diff"))
181181
options->submodule_format = DIFF_SUBMODULE_INLINE_DIFF;
182+
/*
183+
* Please update $__git_diff_submodule_formats in
184+
* git-completion.bash when you add new formats.
185+
*/
182186
else
183187
return -1;
184188
return 0;
@@ -205,6 +209,10 @@ long parse_algorithm_value(const char *value)
205209
return XDF_PATIENCE_DIFF;
206210
else if (!strcasecmp(value, "histogram"))
207211
return XDF_HISTOGRAM_DIFF;
212+
/*
213+
* Please update $__git_diff_algorithms in git-completion.bash
214+
* when you add new algorithms.
215+
*/
208216
return -1;
209217
}
210218

0 commit comments

Comments
 (0)