pull: add pull.ff configuration

Add a `pull.ff` configuration option that is analogous to the `merge.ff` option. This allows us to control the fast-forward behavior for pull-initiated merges only. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Aguilar committed Jan 15, 2014 at 15:18 UTC b814da891e8261b909fc5d9fb07b4e8b13989c2d
3 files changed +46
Documentation/config.txt
+10
@@ -1877,6 +1877,16 @@ pretty.<name>::
1877 Note that an alias with the same name as a built-in format
1878 will be silently ignored.
1879
1880 +pull.ff::
1881 + By default, Git does not create an extra merge commit when merging
1882 + a commit that is a descendant of the current commit. Instead, the
1883 + tip of the current branch is fast-forwarded. When set to `false`,
1884 + this variable tells Git to create an extra merge commit in such
1885 + a case (equivalent to giving the `--no-ff` option from the command
1886 + line). When set to `only`, only such fast-forward merges are
1887 + allowed (equivalent to giving the `--ff-only` option from the
1888 + command line).
1889 +
1890 pull.rebase::
1891 When true, rebase branches on top of the fetched branch, instead
1892 of merging the default branch from the default remote when "git
git-pull.sh
+15
@@ -52,6 +52,21 @@ if test -z "$rebase"
52 then
53 rebase=$(bool_or_string_config pull.rebase)
54 fi
55 +
56 +# Setup default fast-forward options via `pull.ff`
57 +pull_ff=$(git config pull.ff)
58 +case "$pull_ff" in
59 +false)
60 + no_ff=--no-ff
61 + break
62 + ;;
63 +only)
64 + ff_only=--ff-only
65 + break
66 + ;;
67 +esac
68 +
69 +
70 dry_run=
71 while :
72 do
t/t7601-merge-pull-config.sh
+21
@@ -38,6 +38,27 @@ test_expect_success 'merge c1 with c2' '
38 test -f c2.c
39 '
40
41 +test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
42 + git reset --hard c0 &&
43 + test_config pull.ff true &&
44 + git pull . c1 &&
45 + test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
46 +'
47 +
48 +test_expect_success 'fast-forward pull creates merge with "false" in pull.ff' '
49 + git reset --hard c0 &&
50 + test_config pull.ff false &&
51 + git pull . c1 &&
52 + test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
53 + test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
54 +'
55 +
56 +test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
57 + git reset --hard c1 &&
58 + test_config pull.ff only &&
59 + test_must_fail git pull . c3
60 +'
61 +
62 test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
63 git reset --hard c1 &&
64 git config pull.twohead ours &&