{"thread":{"id":"37293","subject":"[PATCH] rebase: introduce \"rebase.preserve\" configuration option","startedAt":"2014-08-05T20:48:34Z","lastAt":"2014-08-05T22:39:15Z","messageCount":2,"participants":["Ralf Thielow","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"247292","messageId":"1407271714-1624-1-git-send-email-ralf.thielow@gmail.com","threadId":"37293","inReplyTo":null,"subject":"[PATCH] rebase: introduce \"rebase.preserve\" configuration option","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2014-08-05T20:48:34Z","receivedAt":"2014-08-05T20:48:34Z","isPatch":true,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"There are several ways to configure Git to preserve merges.\nThere is \"pull.rebase=preserve\" for all branches and\n\"branch.<name>.rebase=preserve\" for individual branches.\nHowever, there is no configuration option to preserve merges\nfor all branches when running git-rebase.\n\nThis patch introduces a new configuration variable\n\"rebase.preserve\". If set to true, \"--preserve-merges\" option\nwill be enabled in git-rebase by default.\n\nSigned-off-by: Ralf Thielow <ralf.thielow@gmail.com>\n---\n Documentation/config.txt          |  3 +++\n git-rebase.sh                     |  1 +\n t/t3409-rebase-preserve-merges.sh | 20 ++++++++++++++++++++\n 3 files changed, 24 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c08286e..4166be0 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2031,6 +2031,9 @@ rebase.autostash::\n \tsuccessful rebase might result in non-trivial conflicts.\n \tDefaults to false.\n \n+rebase.preserve::\n+\tIf set to true enable '--preserve-merges' option by default.\n+\n receive.autogc::\n \tBy default, git-receive-pack will run \"git-gc --auto\" after\n \treceiving data from git-push and updating refs.  You can stop\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 47ca3b9..e0b3e05 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -83,6 +83,7 @@ state_dir=\n # One of {'', continue, skip, abort}, as parsed from command line\n action=\n preserve_merges=\n+test \"$(git config --bool rebase.preserve)\" = \"true\" && preserve_merges=t && interactive_rebase=implied\n autosquash=\n keep_empty=\n test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 8c251c5..3a02240 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -76,6 +76,16 @@ test_expect_success 'setup for merge-preserving rebase' \\\n \t\tgit merge --no-ff topic2\n \t) &&\n \n+\tgit clone ./. clone5 &&\n+\t(\n+\t\tcd clone5 &&\n+\t\tgit checkout -b topic2 origin/topic &&\n+\t\techo Sixth > A &&\n+\t\tgit commit -a -m \"Modify A3\" &&\n+\t\tgit checkout -b topic origin/topic &&\n+\t\tgit merge --no-ff topic2\n+\t) &&\n+\n \tgit checkout topic &&\n \techo Fourth >> B &&\n \tgit commit -a -m \"Modify B2\"\n@@ -119,4 +129,14 @@ test_expect_success 'rebase -p ignores merge.log config' '\n \t)\n '\n \n+test_expect_success 'config rebase.preserve preserves no-ff merges' '\n+\t(\n+\tcd clone5 &&\n+\tgit fetch &&\n+\tgit -c rebase.preserve=true rebase origin/topic &&\n+\ttest 3 = $(git rev-list --all --pretty=oneline | grep \"Modify A\" | wc -l) &&\n+\ttest 1 = $(git rev-list --all --pretty=oneline | grep \"Merge branch\" | wc -l)\n+\t)\n+'\n+\n test_done\n-- \n2.1.0.rc1.205.gf9880d1\n"},{"id":"247304","messageId":"xmqq61i6o92k.fsf@gitster.dls.corp.google.com","threadId":"37293","inReplyTo":"1407271714-1624-1-git-send-email-ralf.thielow@gmail.com","subject":"Re: [PATCH] rebase: introduce \"rebase.preserve\" configuration option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-08-05T22:39:15Z","receivedAt":"2014-08-05T22:39:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ralf Thielow <ralf.thielow@gmail.com> writes:\n\n> There are several ways to configure Git to preserve merges.\n> There is \"pull.rebase=preserve\" for all branches and\n> \"branch.<name>.rebase=preserve\" for individual branches.\n> However, there is no configuration option to preserve merges\n> for all branches when running git-rebase.\n\nHow should this interact with pull.rebase?  Specifically, what\nshould happen with these settings?\n\n\t[rebase] preserve = true\n        [pull] rebase = true\n\nHistorically, the variable was a way to tell 'pull' to use 'rebase'\nto integrate (if true) or use 'merge' to integrate (if false), and\nthen the third value that is clearly not 'false' was added to say\n\"How should the underlying 'rebase' integrate the local and the\nremote histories?\".\n\nIn that light, one can argue 'git pull' with the above two should\nrun 'rebase --preserve'.  In other words, rebase.preserve tells us\n\"When 'rebase' is told to run, it should do the 'preserving'\nvariant.\"\n\nBut then when somebody sets pull.rebase to true, expecting that\n'true' does not just mean \"Yup, please use rebase, I do not like\nmerges\", but means \"Use rebase without preserve\", it would be hard\nto debug if the behaviour of 'git pull' is affected by a separate\nvariable rebase.preserve that may be defined in a far-away place in\nthe configuration file.\n\nI dunno.  This kind of complications is one reason why I wouldn't\nencourage adding these configurations to affect the behaviours of\ncommands.\n"}]}