@@ -101,6 +101,11 @@ branch.<name>.updateMode::
possible values are 'fast-forward', 'merge', and 'rebase'.
See `update.mode` for doing this in a non branch-specific manner.
+branch.<name>.pullMode::
+ When `git pull` is run, this determines the mode of operation,
+ possible values are 'merge' and 'rebase'. See `pull.mode` for doing this
+ in a non branch-specific manner.
+
branch.<name>.description::
Branch description, can be edited with
`git branch --edit-description`. Branch description is
@@ -32,7 +32,8 @@ for details).
pull.mode::
When "git pull" is run, this determines if it would either merge or
rebase the fetched branch. The possible values are 'merge',
- and 'rebase'.
+ and 'rebase'. See "branch.<name>.pullMode" for setting this on a
+ per-branch basis.
pull.octopus::
The default merge strategy to use when pulling multiple branches
@@ -374,8 +374,21 @@ static enum rebase_type config_get_rebase(void)
static enum pull_mode_type config_get_pull_mode(const char *repo)
{
+ struct branch *curr_branch = branch_get("HEAD");
const char *value;
+ if (curr_branch) {
+ char *key = xstrfmt("branch.%s.pullmode", curr_branch->name);
+
+ if (!git_config_get_value(key, &value)) {
+ enum pull_mode_type ret = parse_config_pull_mode(key, value);
+ free(key);
+ return ret;
+ }
+
+ free(key);
+ }
+
if (!git_config_get_value("pull.mode", &value))
return parse_config_pull_mode("pull.mode", value);
@@ -493,6 +493,17 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
test_cmp expect actual
'
+test_expect_success 'branch..pullmode overrides pull.mode' '
+ git reset --hard before-rebase &&
+ test_config pull.mode rebase &&
+ test_config branch.to-rebase.pullmode merge &&
+ git pull . copy &&
+ test_cmp_rev ! HEAD^ copy &&
+ echo new >expect &&
+ git show HEAD:file2 >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'pull --rebase warns on --verify-signatures' '
git reset --hard before-rebase &&
git pull --rebase --verify-signatures . copy 2>err &&
Many people have argued that `git pull` should have a per-branch configuration for its mode of operation (e.g. Linus Torvalds [1] and Theodore Ts'o [2]). branch.<name>.pullMode achieves that. [1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/ [2] https://lore.kernel.org/git/20130312212027.GE14792@thunk.org/ Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- Documentation/config/branch.txt | 5 +++++ Documentation/config/pull.txt | 3 ++- builtin/pull.c | 13 +++++++++++++ t/t5520-pull.sh | 11 +++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-)