|
8 | 8 | #include "git-compat-util.h" |
9 | 9 |
|
10 | 10 | #include "builtin.h" |
| 11 | +#include "config.h" |
11 | 12 | #include "environment.h" |
12 | 13 | #include "hex.h" |
13 | 14 | #include "lockfile.h" |
@@ -298,6 +299,22 @@ static enum ref_action_mode parse_ref_action_mode(const char *ref_action, const |
298 | 299 | die(_("invalid %s value: '%s'"), source, ref_action); |
299 | 300 | } |
300 | 301 |
|
| 302 | +static enum ref_action_mode get_ref_action_mode(struct repository *repo, const char *ref_action) |
| 303 | +{ |
| 304 | + const char *config_value = NULL; |
| 305 | + |
| 306 | + /* Command line option takes precedence */ |
| 307 | + if (ref_action) |
| 308 | + return parse_ref_action_mode(ref_action, "--ref-action"); |
| 309 | + |
| 310 | + /* Check config value */ |
| 311 | + if (!repo_config_get_string_tmp(repo, "replay.refAction", &config_value)) |
| 312 | + return parse_ref_action_mode(config_value, "replay.refAction"); |
| 313 | + |
| 314 | + /* Default to update mode */ |
| 315 | + return REF_ACTION_UPDATE; |
| 316 | +} |
| 317 | + |
301 | 318 | static int handle_ref_update(enum ref_action_mode mode, |
302 | 319 | struct ref_transaction *transaction, |
303 | 320 | const char *refname, |
@@ -332,7 +349,7 @@ int cmd_replay(int argc, |
332 | 349 | const char *onto_name = NULL; |
333 | 350 | int contained = 0; |
334 | 351 | const char *ref_action = NULL; |
335 | | - enum ref_action_mode ref_mode = REF_ACTION_UPDATE; |
| 352 | + enum ref_action_mode ref_mode; |
336 | 353 |
|
337 | 354 | struct rev_info revs; |
338 | 355 | struct commit *last_commit = NULL; |
@@ -378,9 +395,8 @@ int cmd_replay(int argc, |
378 | 395 | die_for_incompatible_opt2(!!advance_name_opt, "--advance", |
379 | 396 | contained, "--contained"); |
380 | 397 |
|
381 | | - /* Parse ref action mode */ |
382 | | - if (ref_action) |
383 | | - ref_mode = parse_ref_action_mode(ref_action, "--ref-action"); |
| 398 | + /* Parse ref action mode from command line or config */ |
| 399 | + ref_mode = get_ref_action_mode(repo, ref_action); |
384 | 400 |
|
385 | 401 | advance_name = xstrdup_or_null(advance_name_opt); |
386 | 402 |
|
|
0 commit comments