Skip to content

Commit 1ee740e

Browse files
committed
Merge branch 'ab/pull-rebase-config'
* ab/pull-rebase-config: pull: introduce a pull.rebase option to enable --rebase
2 parents ef87690 + 6b37dff commit 1ee740e

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

Documentation/config.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,12 @@ branch.<name>.mergeoptions::
677677
branch.<name>.rebase::
678678
When true, rebase the branch <name> on top of the fetched branch,
679679
instead of merging the default branch from the default remote when
680-
"git pull" is run.
681-
*NOTE*: this is a possibly dangerous operation; do *not* use
682-
it unless you understand the implications (see linkgit:git-rebase[1]
683-
for details).
680+
"git pull" is run. See "pull.rebase" for doing this in a non
681+
branch-specific manner.
682+
+
683+
*NOTE*: this is a possibly dangerous operation; do *not* use
684+
it unless you understand the implications (see linkgit:git-rebase[1]
685+
for details).
684686

685687
browser.<tool>.cmd::
686688
Specify the command to invoke the specified browser. The
@@ -1590,6 +1592,16 @@ pretty.<name>::
15901592
Note that an alias with the same name as a built-in format
15911593
will be silently ignored.
15921594

1595+
pull.rebase::
1596+
When true, rebase branches on top of the fetched branch, instead
1597+
of merging the default branch from the default remote when "git
1598+
pull" is run. See "branch.<name>.rebase" for setting this on a
1599+
per-branch basis.
1600+
+
1601+
*NOTE*: this is a possibly dangerous operation; do *not* use
1602+
it unless you understand the implications (see linkgit:git-rebase[1]
1603+
for details).
1604+
15931605
pull.octopus::
15941606
The default merge strategy to use when pulling multiple branches
15951607
at once.

Documentation/git-pull.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ include::merge-options.txt[]
108108
fetched, the rebase uses that information to avoid rebasing
109109
non-local changes.
110110
+
111-
See `branch.<name>.rebase` and `branch.autosetuprebase` in
111+
See `pull.rebase`, `branch.<name>.rebase` and `branch.autosetuprebase` in
112112
linkgit:git-config[1] if you want to make `git pull` always use
113113
`{litdd}rebase` instead of merging.
114114
+

git-pull.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ merge_args=
4444
curr_branch=$(git symbolic-ref -q HEAD)
4545
curr_branch_short="${curr_branch#refs/heads/}"
4646
rebase=$(git config --bool branch.$curr_branch_short.rebase)
47+
if test -z "$rebase"
48+
then
49+
rebase=$(git config --bool pull.rebase)
50+
fi
4751
dry_run=
4852
while :
4953
do

t/t5520-pull.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,35 @@ test_expect_success '--rebase' '
9494
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
9595
test new = $(git show HEAD:file2)
9696
'
97+
test_expect_success 'pull.rebase' '
98+
git reset --hard before-rebase &&
99+
git config --bool pull.rebase true &&
100+
test_when_finished "git config --unset pull.rebase" &&
101+
git pull . copy &&
102+
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
103+
test new = $(git show HEAD:file2)
104+
'
97105

98106
test_expect_success 'branch.to-rebase.rebase' '
99107
git reset --hard before-rebase &&
100-
git config branch.to-rebase.rebase 1 &&
108+
git config --bool branch.to-rebase.rebase true &&
109+
test_when_finished "git config --unset branch.to-rebase.rebase" &&
101110
git pull . copy &&
102-
git config branch.to-rebase.rebase 0 &&
103111
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
104112
test new = $(git show HEAD:file2)
105113
'
106114

115+
test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
116+
git reset --hard before-rebase &&
117+
git config --bool pull.rebase true &&
118+
test_when_finished "git config --unset pull.rebase" &&
119+
git config --bool branch.to-rebase.rebase false &&
120+
test_when_finished "git config --unset branch.to-rebase.rebase" &&
121+
git pull . copy &&
122+
test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
123+
test new = $(git show HEAD:file2)
124+
'
125+
107126
test_expect_success '--rebase with rebased upstream' '
108127
109128
git remote add -f me . &&

0 commit comments

Comments
 (0)