Skip to contentSkip to conversation

pull: introduce a pull.rebase option to enable --rebase

PATCH In review Ævar Arnfjörð Bjarmason 5 participants 10 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pull: introduce a pull.rebase option to enable --rebase

Currently we either need to set branch.<name>.rebase for existing branches if we'd like "git pull" to mean "git pull --rebase", or have the forethought of setting "branch.autosetuprebase" before we create the branch.

But there's no way to globally configure "git pull" to mean "git pull --rebase" for existing branches, introduce a "pull.rebase" option to do that.

This option will be considered at a lower priority than branch.<name>.rebase, i.e. we could set pull.rebase=true and branch.<name>.rebase=false and the latter configuration option would win.

---
 Documentation/config.txt   |   14 +++++++++++++-
 Documentation/git-pull.txt |    2 +-
 git-pull.sh                |    4 ++++
 t/t5520-pull.sh            |   24 ++++++++++++++++++++++--
 4 files changed, 40 insertions(+), 4 deletions(-)
Documentation/config.txt +13 -1
index 5a841da..b2d7d92 100644
@@ -677,7 +677,9 @@ branch.<name>.mergeoptions::
 branch.<name>.rebase::
 	When true, rebase the branch <name> on top of the fetched branch,
 	instead of merging the default branch from the default remote when
-	"git pull" is run.
+	"git pull" is run. See "pull.rebase" for doing this in a non
+	branch-specific manner.
+
 	*NOTE*: this is a possibly dangerous operation; do *not* use
 	it unless you understand the implications (see linkgit:git-rebase[1]
 	for details).
@@ -1590,6 +1592,16 @@ pretty.<name>::
 	Note that an alias with the same name as a built-in format
 	will be silently ignored.
 
+pull.rebase::
+	When true, rebase branches on top of the fetched branch, instead
+	of merging the default branch from the default remote when "git
+	pull" is run. See "branch.<name>.rebase" for setting this on a
+	per-branch basis.
+
+	*NOTE*: this is a possibly dangerous operation; do *not* use
+	it unless you understand the implications (see linkgit:git-rebase[1]
+	for details).
+
 pull.octopus::
 	The default merge strategy to use when pulling multiple branches
 	at once.
Documentation/git-pull.txt +1 -1
index e1da468..0f18ec8 100644
@@ -108,7 +108,7 @@ include::merge-options.txt[]
 	fetched, the rebase uses that information to avoid rebasing
 	non-local changes.
 +
-See `branch.<name>.rebase` and `branch.autosetuprebase` in
+See `pull.rebase`, `branch.<name>.rebase` and `branch.autosetuprebase` in
 linkgit:git-config[1] if you want to make `git pull` always use
 `{litdd}rebase` instead of merging.
 +
git-pull.sh +4 -0
index 9868a0b..24b6b7c 100755
@@ -44,6 +44,10 @@ merge_args=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short="${curr_branch#refs/heads/}"
 rebase=$(git config --bool branch.$curr_branch_short.rebase)
+if test -z "$rebase"
+then 
+	rebase=$(git config --bool pull.rebase)
+fi
 dry_run=
 while :
 do
t/t5520-pull.sh +22 -2
index 0e5eb67..ecc4fdc 100755
@@ -94,16 +94,36 @@ test_expect_success '--rebase' '
 	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
 	test new = $(git show HEAD:file2)
 '
+test_expect_success 'pull.rebase' '
+	git reset --hard before-rebase &&
+	git config --bool pull.rebase true &&
+	test_when_finished "git config --unset pull.rebase" &&
+	git pull . copy &&
+	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
+	test new = $(git show HEAD:file2)
+'
 
 test_expect_success 'branch.to-rebase.rebase' '
 	git reset --hard before-rebase &&
-	git config branch.to-rebase.rebase 1 &&
+	git config --bool branch.to-rebase.rebase true &&
+	test_when_finished "git config --unset branch.to-rebase.rebase" &&
 	git pull . copy &&
-	git config branch.to-rebase.rebase 0 &&
 	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
 	test new = $(git show HEAD:file2)
 '
 
+test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
+	git reset --hard before-rebase &&
+	git config --bool pull.rebase true &&
+	test_when_finished "git config --unset pull.rebase" &&
+	git config --bool branch.to-rebase.rebase false &&
+	test_when_finished "git config --unset branch.to-rebase.rebase" &&
+	git pull . copy &&
+	git config --unset branch.to-rebase.rebase &&
+	test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
+	test new = $(git show HEAD:file2)
+'
+
 test_expect_success '--rebase with rebased upstream' '
 
 	git remote add -f me . &&
Signature · 1 line
1.7.7
#1 lore raw
Quoted 9 lines · Ævar Arnfjörð Bjarmason

This option will be considered at a lower priority than branch.<name>.rebase, i.e. we could set pull.rebase=true and branch.<name>.rebase=false and the latter configuration option would win.

I see many reviewed-by lines, but what kind of review did this patch have, exactly? It seem to break its own test (branch.to-rebase.rebase should override pull.rebase).

I think I've queued most (if not all) of the patches in flight except for Ram's sequencer reroll to 'pu' and pu^ passes the test but the tip of pu does not due to this topic.

Thanks for other topics from the Amsterdam together, by the way. I did not comment on them individually but they looked mostly reasonable from a quick glance.

#2 lore raw

PATCH v2 1/1 pull: introduce a pull.rebase option to enable --rebase

Currently we either need to set branch.<name>.rebase for existing branches if we'd like "git pull" to mean "git pull --rebase", or have the forethought of setting "branch.autosetuprebase" before we create the branch.

But there's no way to globally configure "git pull" to mean "git pull --rebase" for existing branches, introduce a "pull.rebase" option to do that.

This option will be considered at a lower priority than branch.<name>.rebase, i.e. we could set pull.rebase=true and branch.<name>.rebase=false and the latter configuration option would win.

---

Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Ævar Arnfjörð Bjarmason

This option will be considered at a lower priority than branch.<name>.rebase, i.e. we could set pull.rebase=true and branch.<name>.rebase=false and the latter configuration option would win.

Quoted 8 lines
Quoted 4 lines

I see many reviewed-by lines, but what kind of review did this patch have, exactly? It seem to break its own test (branch.to-rebase.rebase should override pull.rebase).

We all stood behind my laptop while I explained what it did and why. Sverre pointed out that I should use the test_when_finished() function for unsetting the config variables, Eric and Fernando looked it over as well.

Quoted 3 lines

I think I've queued most (if not all) of the patches in flight except for Ram's sequencer reroll to 'pu' and pu^ passes the test but the tip of pu does not due to this topic.

Due to a trivial error of mine. I sent out the wrong patch as Sverre thought, the problem was that I was trying to --unset a config variable twice, that's now fixed and the tests pass with this patch.

 Documentation/config.txt   |   14 +++++++++++++-
 Documentation/git-pull.txt |    2 +-
 git-pull.sh                |    4 ++++
 t/t5520-pull.sh            |   23 +++++++++++++++++++++--
 4 files changed, 39 insertions(+), 4 deletions(-)
Documentation/config.txt +13 -1
index 5a841da..b2d7d92 100644
@@ -677,7 +677,9 @@ branch.<name>.mergeoptions::
 branch.<name>.rebase::
 	When true, rebase the branch <name> on top of the fetched branch,
 	instead of merging the default branch from the default remote when
-	"git pull" is run.
+	"git pull" is run. See "pull.rebase" for doing this in a non
+	branch-specific manner.
+
 	*NOTE*: this is a possibly dangerous operation; do *not* use
 	it unless you understand the implications (see linkgit:git-rebase[1]
 	for details).
@@ -1590,6 +1592,16 @@ pretty.<name>::
 	Note that an alias with the same name as a built-in format
 	will be silently ignored.
 
+pull.rebase::
+	When true, rebase branches on top of the fetched branch, instead
+	of merging the default branch from the default remote when "git
+	pull" is run. See "branch.<name>.rebase" for setting this on a
+	per-branch basis.
+
+	*NOTE*: this is a possibly dangerous operation; do *not* use
+	it unless you understand the implications (see linkgit:git-rebase[1]
+	for details).
+
 pull.octopus::
 	The default merge strategy to use when pulling multiple branches
 	at once.
Documentation/git-pull.txt +1 -1
index e1da468..0f18ec8 100644
@@ -108,7 +108,7 @@ include::merge-options.txt[]
 	fetched, the rebase uses that information to avoid rebasing
 	non-local changes.
 +
-See `branch.<name>.rebase` and `branch.autosetuprebase` in
+See `pull.rebase`, `branch.<name>.rebase` and `branch.autosetuprebase` in
 linkgit:git-config[1] if you want to make `git pull` always use
 `{litdd}rebase` instead of merging.
 +
git-pull.sh +4 -0
index 9868a0b..24b6b7c 100755
@@ -44,6 +44,10 @@ merge_args=
 curr_branch=$(git symbolic-ref -q HEAD)
 curr_branch_short="${curr_branch#refs/heads/}"
 rebase=$(git config --bool branch.$curr_branch_short.rebase)
+if test -z "$rebase"
+then 
+	rebase=$(git config --bool pull.rebase)
+fi
 dry_run=
 while :
 do
t/t5520-pull.sh +21 -2
index 0e5eb67..35304b4 100755
@@ -94,16 +94,35 @@ test_expect_success '--rebase' '
 	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
 	test new = $(git show HEAD:file2)
 '
+test_expect_success 'pull.rebase' '
+	git reset --hard before-rebase &&
+	git config --bool pull.rebase true &&
+	test_when_finished "git config --unset pull.rebase" &&
+	git pull . copy &&
+	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
+	test new = $(git show HEAD:file2)
+'
 
 test_expect_success 'branch.to-rebase.rebase' '
 	git reset --hard before-rebase &&
-	git config branch.to-rebase.rebase 1 &&
+	git config --bool branch.to-rebase.rebase true &&
+	test_when_finished "git config --unset branch.to-rebase.rebase" &&
 	git pull . copy &&
-	git config branch.to-rebase.rebase 0 &&
 	test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
 	test new = $(git show HEAD:file2)
 '
 
+test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
+	git reset --hard before-rebase &&
+	git config --bool pull.rebase true &&
+	test_when_finished "git config --unset pull.rebase" &&
+	git config --bool branch.to-rebase.rebase false &&
+	test_when_finished "git config --unset branch.to-rebase.rebase" &&
+	git pull . copy &&
+	test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
+	test new = $(git show HEAD:file2)
+'
+
 test_expect_success '--rebase with rebased upstream' '
 
 	git remote add -f me . &&
Signature · 1 line
1.7.6.3
#3 lore raw

Am 06.11.2011 10:50, schrieb Ævar Arnfjörð Bjarmason:

Quoted 5 lines
Documentation/config.txt +0 -0
index 5a841da..b2d7d92 100644

Documentation/config.txt branch.<name>.mergeoptions:: · line 685

Quoted 10 lines
Documentation/config.txt +3 -1
@@ -677,7 +677,9 @@ branch.<name>.mergeoptions::
 branch.<name>.rebase::
 	When true, rebase the branch <name> on top of the fetched branch,
 	instead of merging the default branch from the default remote when
-	"git pull" is run.
+	"git pull" is run. See "pull.rebase" for doing this in a non
+	branch-specific manner.
+
 	*NOTE*: this is a possibly dangerous operation; do *not* use
 	it unless you understand the implications (see linkgit:git-rebase[1]
 	for details).

When you continue an indented item in a separate paragraph, then you must not use an empty line, but have line with '+' and un-indented continuation paragraphs. See examples in this file.

-- Hannes

#7 lore raw
In reply to Ævar Arnfjörð Bjarmason
Quoted 4 lines · Ævar Arnfjörð Bjarmason

We all stood behind my laptop while I explained what it did and why. Sverre pointed out that I should use the test_when_finished() function for unsetting the config variables, Eric and Fernando looked it over as well.

Sounds like fun ;-)

Will re-queue. Thanks.

#8 lore raw
In reply to Junio C Hamano

Heya,

Quoted 3 lines · Junio C Hamano

I see many reviewed-by lines, but what kind of review did this patch have, exactly? It seem to break its own test (branch.to-rebase.rebase should override pull.rebase).

We looked at the patch the same way one would on list, and I assumed that the tests passed. Ævar, did you sent a wrong version by accident perhaps?

Quoted 3 lines

Thanks for other topics from the Amsterdam together, by the way. I did not comment on them individually but they looked mostly reasonable from a quick glance.

Thanks.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#9 lore raw
In reply to Ævar Arnfjörð Bjarmason

Hi,

Quoted 5 lines · Ævar Arnfjörð Bjarmason

Currently we either need to set branch.<name>.rebase for existing branches if we'd like "git pull" to mean "git pull --rebase", or have the forethought of setting "branch.autosetuprebase" before we create the branch.

Quoted 8 lines

But there's no way to globally configure "git pull" to mean "git pull --rebase" for existing branches, introduce a "pull.rebase" option to do that.

This option will be considered at a lower priority than branch.<name>.rebase, i.e. we could set pull.rebase=true and branch.<name>.rebase=false and the latter configuration option would win.

Nice.

Ciao,
Johannes

#4 lore raw
In reply to Johannes Sixt
Quoted 3 lines · Johannes Sixt

When you continue an indented item in a separate paragraph, then you must not use an empty line, but have line with '+' and un-indented continuation paragraphs. See examples in this file.

Thanks for spotting that.

Junio: Should I spam you with another patch or is something you'd prefer to just fix up?

#5 lore raw
Quoted 9 lines · Ævar Arnfjörð Bjarmason
Quoted 3 lines · Johannes Sixt

When you continue an indented item in a separate paragraph, then you must not use an empty line, but have line with '+' and un-indented continuation paragraphs. See examples in this file.

Thanks for spotting that.

Junio: Should I spam you with another patch or is something you'd prefer to just fix up?

It is about the same amount of work for me; I've just dedented the two paragraphs that start with "*NOTE*:" and replaced the blank lines before them with a single "+". Is that what you wanted to resend, or is there anything else?

#6 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 3 lines · Johannes Sixt

When you continue an indented item in a separate paragraph, then you must not use an empty line, but have line with '+' and un-indented continuation paragraphs. See examples in this file.

Thanks for spotting that.

Quoted 7 lines
Quoted 2 lines

Junio: Should I spam you with another patch or is something you'd prefer to just fix up?

It is about the same amount of work for me; I've just dedented the two paragraphs that start with "*NOTE*:" and replaced the blank lines before them with a single "+". Is that what you wanted to resend, or is there anything else?

That should cover it, thanks!