{"thread":{"id":"56016","subject":"[PATCH] pull: introduce --merge option","startedAt":"2021-06-28T03:16:53Z","lastAt":"2021-06-28T04:52:59Z","messageCount":3,"participants":["Felipe Contreras","Alex Henrie"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"428580","messageId":"20210628031642.699156-1-felipe.contreras@gmail.com","threadId":"56016","inReplyTo":null,"subject":"[PATCH] pull: introduce --merge option","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-28T03:16:42Z","receivedAt":"2021-06-28T03:16:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Previously --no-rebase (which still works for backwards compatibility).\n\nNow we can update the default warning, and the git-pull(1) man page to\nuse --merge instead of the non-intuitive --no-rebase.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nI've sent many versions of this patch over the years (since 2013) in\nmany different series and nobody has objected to it (to the best of my\nrecollection).\n\nThe idea came after a comment from Linus Torvalds regarding what should\nbe the default mode of \"git pull\" and why [1].\n\nIt conflicts with some of my previous patch series, but they aren't even\nin \"seen\" yet, and the ones that are resolve easily.\n\n[1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/\n\n Documentation/git-pull.txt   | 7 +++++--\n builtin/pull.c               | 4 +++-\n t/t7601-merge-pull-config.sh | 8 ++++----\n 3 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt\nindex 5c3fb67c01..d23128fa72 100644\n--- a/Documentation/git-pull.txt\n+++ b/Documentation/git-pull.txt\n@@ -131,8 +131,11 @@ It rewrites history, which does not bode well when you\n published that history already.  Do *not* use this option\n unless you have read linkgit:git-rebase[1] carefully.\n \n---no-rebase::\n-\tOverride earlier --rebase.\n+-m::\n+--merge::\n+\tForce a merge.\n++\n+Previously this was --no-rebase, but that usage has been deprecated.\n \n Options related to fetching\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex e8927fc2ff..186adbff71 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -129,6 +129,8 @@ static struct option pull_options[] = {\n \t  \"(false|true|merges|preserve|interactive)\",\n \t  N_(\"incorporate changes by rebasing rather than merging\"),\n \t  PARSE_OPT_OPTARG, parse_opt_rebase),\n+\tOPT_SET_INT('m', \"merge\", &opt_rebase,\n+\t\tN_(\"incorporate changes by merging\"), REBASE_FALSE),\n \tOPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,\n \t\tN_(\"do not show a diffstat at the end of the merge\"),\n \t\tPARSE_OPT_NOARG | PARSE_OPT_NONEG),\n@@ -936,7 +938,7 @@ static void show_advice_pull_non_ff(void)\n \t\t \"  git config pull.ff only       # fast-forward only\\n\"\n \t\t \"\\n\"\n \t\t \"You can replace \\\"git config\\\" with \\\"git config --global\\\" to set a default\\n\"\n-\t\t \"preference for all repositories. You can also pass --rebase, --no-rebase,\\n\"\n+\t\t \"preference for all repositories. You can also pass --rebase, --merge,\\n\"\n \t\t \"or --ff-only on the command line to override the configured default per\\n\"\n \t\t \"invocation.\\n\"));\n }\ndiff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh\nindex 52e8ccc933..6d03e0b9fe 100755\n--- a/t/t7601-merge-pull-config.sh\n+++ b/t/t7601-merge-pull-config.sh\n@@ -60,9 +60,9 @@ test_expect_success 'pull.rebase not set and --rebase given' '\n \ttest_i18ngrep ! \"Pulling without specifying how to reconcile\" err\n '\n \n-test_expect_success 'pull.rebase not set and --no-rebase given' '\n+test_expect_success 'pull.rebase not set and --merge given' '\n \tgit reset --hard c0 &&\n-\tgit pull --no-rebase . c1 2>err &&\n+\tgit pull --merge . c1 2>err &&\n \ttest_i18ngrep ! \"Pulling without specifying how to reconcile\" err\n '\n \n@@ -119,9 +119,9 @@ test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)'\n \ttest_i18ngrep ! \"Pulling without specifying how to reconcile\" err\n '\n \n-test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' '\n+test_expect_success 'pull.rebase not set and --merge given (not-fast-forward)' '\n \tgit reset --hard c2 &&\n-\tgit pull --no-rebase . c1 2>err &&\n+\tgit pull --merge . c1 2>err &&\n \ttest_i18ngrep ! \"Pulling without specifying how to reconcile\" err\n '\n \n-- \n2.32.0\n\n"},{"id":"428582","messageId":"CAMMLpeQ9BVNHqk2p748+4+ufuWJ46fYUnVvMvwFPxh3N--ASPg@mail.gmail.com","threadId":"56016","inReplyTo":"20210628031642.699156-1-felipe.contreras@gmail.com","subject":"Re: [PATCH] pull: introduce --merge option","fromName":"Alex Henrie","fromEmail":"alexhenrie24@gmail.com","sentAt":"2021-06-28T03:51:30Z","receivedAt":"2021-06-28T03:51:46Z","isPatch":true,"sender":{"key":"alexhenrie24@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5951993?v=4"},"body":"On Sun, Jun 27, 2021 at 9:16 PM Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n>\n> The idea came after a comment from Linus Torvalds regarding what should\n> be the default mode of \"git pull\" and why [1].\n>\n> [1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/\n\nOh wow, I didn't realize that Linus gave his opinion on the subject\nback in 2013, and he suggested doing nearly exactly what we are trying\nto do now.\n\n> ---no-rebase::\n> -       Override earlier --rebase.\n> +-m::\n> +--merge::\n> +       Force a merge.\n> ++\n> +Previously this was --no-rebase, but that usage has been deprecated.\n\nI don't think --no-rebase should be \"deprecated\", at least not yet.\nAfter all, the equivalent config option is still pull.rebase=false.\nAlso, --merge doesn't necessarily force a merge because it does not\nimply --no-ff. I would prefer to list --no-rebase, -m, and --merge\ntogether on the same line and leave the description alone.\n\nBut other than the documentation and the commit message, I like the\nidea here, and I think it will make Git a lot more user-friendly.\n\n-Alex\n"},{"id":"428584","messageId":"60d955a473187_aaf7e208f6@natae.notmuch","threadId":"56016","inReplyTo":"CAMMLpeQ9BVNHqk2p748+4+ufuWJ46fYUnVvMvwFPxh3N--ASPg@mail.gmail.com","subject":"Re: [PATCH] pull: introduce --merge option","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-28T04:52:52Z","receivedAt":"2021-06-28T04:52:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Alex Henrie wrote:\n> On Sun, Jun 27, 2021 at 9:16 PM Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n> >\n> > The idea came after a comment from Linus Torvalds regarding what should\n> > be the default mode of \"git pull\" and why [1].\n> >\n> > [1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/\n> \n> Oh wow, I didn't realize that Linus gave his opinion on the subject\n> back in 2013, and he suggested doing nearly exactly what we are trying\n> to do now.\n\nIndeed. I incorporated his feedback--along with the feedback of many\nothers--in my proposal.\n\nI have been re-reading the old threads to write a blog post, and the\nwhole story starts from 2008. At this point I have probably read more\nthan one thousand emails, and I'm still far from done.\n\nActually now that I'm re-reading the draft, the first suggestion of\n--merge came from Thomas Rast in 2009 [1] (I forgot).\n\nLong story short: *everyone* (and I do mean everyone) is in favor making\nff-only the default. The disagreements come from how we get there.\n\n> > ---no-rebase::\n> > -       Override earlier --rebase.\n> > +-m::\n> > +--merge::\n> > +       Force a merge.\n> > ++\n> > +Previously this was --no-rebase, but that usage has been deprecated.\n> \n> I don't think --no-rebase should be \"deprecated\", at least not yet.\n\nDeprecated means that we discourage people from using it. It doesn't\nmean it's unsupported.\n\nIt's not obsolete.\n\n> After all, the equivalent config option is still pull.rebase=false.\n\nYes, but the equivalent from the command line is:\n\n  git pull --rebase=false\n\nAnd that's still properly documented:\n\n  -r, --rebase[=false|true|merges|preserve|interactive]\n\n> Also, --merge doesn't necessarily force a merge because it does not\n> imply --no-ff.\n\nThis is a bit of semantics that I have discussed before with Elijah, and\nsomehow I managed to convince him [2] that fast-forward can be used as\nan adverb, and in fact it already is in plenty of the documentation.\n\nBasically this:\n\n  git merge --ff-only\n\nDoes a fast-forward merge. So it's a merge of a special kind. What kind?\nThe fast-forward kind.\n\n> I would prefer to list --no-rebase, -m, and --merge\n> together on the same line and leave the description alone.\n\nI prefer to deprecate --no-rebase. Both --rebase=false and --merge are\nless cumbersome alternatives.\n\nBut I'm not married to this. If other people want to keep --no-rebase at\nthe same level as the other two options, I would not object to it.\n\n> But other than the documentation and the commit message, I like the\n> idea here, and I think it will make Git a lot more user-friendly.\n\nGood. And for the record I think if this patch is not merged, eventually\nsomebody else will send something along these lines, since I'm not the\nfirst person to think of it, nor will I be the last.\n\nCheers.\n\n[1] https://lore.kernel.org/git/200910201947.50423.trast@student.ethz.ch/\n[2] https://lore.kernel.org/git/CABPp-BESMs1tuVoLFMy-BahSChFz7oANqTaeJShFa_zDbEnvBA@mail.gmail.com/\n\n-- \nFelipe Contreras\n"}]}