diff options
author | Paul Tan <pyokagan@gmail.com> | 2015-06-18 18:54:03 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-06-18 13:17:09 -0700 |
commit | a9de98975479ef7d42986db63c16251c1f87ebcb (patch) | |
tree | 15e0a8879ec52ae65b75734b1eb9022a8a4deae1 /builtin/pull.c | |
parent | 44c175c7a46b3a0446e046bdaa566adb9e57d89d (diff) | |
download | git-a9de98975479ef7d42986db63c16251c1f87ebcb.tar.gz |
pull: support pull.ff config
Since b814da8 (pull: add pull.ff configuration, 2014-01-15), git-pull.sh
would lookup the configuration value of "pull.ff", and set the flag
"--ff" if its value is "true", "--no-ff" if its value is "false" and
"--ff-only" if its value is "only".
Re-implement this behavior.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pull.c')
-rw-r--r-- | builtin/pull.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/builtin/pull.c b/builtin/pull.c index 647bcb9f3a..b61cff5d87 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -167,6 +167,32 @@ static void argv_push_force(struct argv_array *arr) } /** + * If pull.ff is unset, returns NULL. If pull.ff is "true", returns "--ff". If + * pull.ff is "false", returns "--no-ff". If pull.ff is "only", returns + * "--ff-only". Otherwise, if pull.ff is set to an invalid value, die with an + * error. + */ +static const char *config_get_ff(void) +{ + const char *value; + + if (git_config_get_value("pull.ff", &value)) + return NULL; + + switch (git_config_maybe_bool("pull.ff", value)) { + case 0: + return "--no-ff"; + case 1: + return "--ff"; + } + + if (!strcmp(value, "only")) + return "--ff-only"; + + die(_("Invalid value for pull.ff: %s"), value); +} + +/** * Appends merge candidates from FETCH_HEAD that are not marked not-for-merge * into merge_heads. */ @@ -397,6 +423,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) parse_repo_refspecs(argc, argv, &repo, &refspecs); + if (!opt_ff) + opt_ff = xstrdup_or_null(config_get_ff()); + if (run_fetch(repo, refspecs)) return 1; |