{"thread":{"id":"35668","subject":"[PATCH 1/2] pull: add pull.ff configuration","startedAt":"2014-01-15T23:18:38Z","lastAt":"2014-01-15T23:18:39Z","messageCount":2,"participants":["David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"233179","messageId":"1389827919-13608-1-git-send-email-davvid@gmail.com","threadId":"35668","inReplyTo":null,"subject":"[PATCH 1/2] pull: add pull.ff configuration","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2014-01-15T23:18:38Z","receivedAt":"2014-01-15T23:18:38Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Add a `pull.ff` configuration option that is analogous\nto the `merge.ff` option.\n\nThis allows us to control the fast-forward behavior for\npull-initiated merges only.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/config.txt     | 10 ++++++++++\n git-pull.sh                  | 15 +++++++++++++++\n t/t7601-merge-pull-config.sh | 21 +++++++++++++++++++++\n 3 files changed, 46 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex ed59853..23b0016 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1881,6 +1881,16 @@ pretty.<name>::\n \tNote that an alias with the same name as a built-in format\n \twill be silently ignored.\n \n+pull.ff::\n+\tBy default, Git does not create an extra merge commit when merging\n+\ta commit that is a descendant of the current commit. Instead, the\n+\ttip of the current branch is fast-forwarded. When set to `false`,\n+\tthis variable tells Git to create an extra merge commit in such\n+\ta case (equivalent to giving the `--no-ff` option from the command\n+\tline). When set to `only`, only such fast-forward merges are\n+\tallowed (equivalent to giving the `--ff-only` option from the\n+\tcommand line).\n+\n pull.rebase::\n \tWhen true, rebase branches on top of the fetched branch, instead\n \tof merging the default branch from the default remote when \"git\ndiff --git a/git-pull.sh b/git-pull.sh\nindex f210d0a..7dbf6b1 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -52,6 +52,21 @@ if test -z \"$rebase\"\n then\n \trebase=$(bool_or_string_config pull.rebase)\n fi\n+\n+# Setup default fast-forward options via `pull.ff`\n+pull_ff=$(git config pull.ff)\n+case \"$pull_ff\" in\n+false)\n+\tno_ff=--no-ff\n+\tbreak\n+\t;;\n+only)\n+\tff_only=--ff-only\n+\tbreak\n+\t;;\n+esac\n+\n+\n dry_run=\n while :\n do\ndiff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh\nindex 830a4c3..f768c90 100755\n--- a/t/t7601-merge-pull-config.sh\n+++ b/t/t7601-merge-pull-config.sh\n@@ -38,6 +38,27 @@ test_expect_success 'merge c1 with c2' '\n \ttest -f c2.c\n '\n \n+test_expect_success 'fast-forward pull succeeds with \"true\" in pull.ff' '\n+\tgit reset --hard c0 &&\n+\ttest_config pull.ff true &&\n+\tgit pull . c1 &&\n+\ttest \"$(git rev-parse HEAD)\" = \"$(git rev-parse c1)\"\n+'\n+\n+test_expect_success 'fast-forward pull creates merge with \"false\" in pull.ff' '\n+\tgit reset --hard c0 &&\n+\ttest_config pull.ff false &&\n+\tgit pull . c1 &&\n+\ttest \"$(git rev-parse HEAD^1)\" = \"$(git rev-parse c0)\" &&\n+\ttest \"$(git rev-parse HEAD^2)\" = \"$(git rev-parse c1)\"\n+'\n+\n+test_expect_success 'pull prevents non-fast-forward with \"only\" in pull.ff' '\n+\tgit reset --hard c1 &&\n+\ttest_config pull.ff only &&\n+\ttest_must_fail git pull . c3\n+'\n+\n test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '\n \tgit reset --hard c1 &&\n \tgit config pull.twohead ours &&\n-- \n1.8.5.3.322.g71d2a99\n"},{"id":"233180","messageId":"1389827919-13608-2-git-send-email-davvid@gmail.com","threadId":"35668","inReplyTo":"1389827919-13608-1-git-send-email-davvid@gmail.com","subject":"[PATCH 2/2] pull: add --ff-only to the help text","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2014-01-15T23:18:39Z","receivedAt":"2014-01-15T23:18:39Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Signed-off-by: David Aguilar <davvid@gmail.com>\n---\n git-pull.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 7dbf6b1..68b2e40 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -4,7 +4,7 @@\n #\n # Fetch one or more remote refs and merge it/them into the current HEAD.\n \n-USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff] [--[no-]rebase|--rebase=preserve] [-s strategy]... [<fetch-options>] <repo> <head>...'\n+USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff|--ff-only] [--[no-]rebase|--rebase=preserve] [-s strategy]... [<fetch-options>] <repo> <head>...'\n LONG_USAGE='Fetch one or more remote refs and integrate it/them with the current HEAD.'\n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n-- \n1.8.5.3.322.g71d2a99\n"}]}