pull: update docs & code for option compatibility with rebasing

git-pull.txt includes merge-options.txt, which is written assuming merges will happen. git-pull has allowed rebases for many years; update the documentation to reflect that. While at it, pass any `--signoff` flag through to the rebase backend too so that we don't have to document it as merge-specific. Rebase has supported the --signoff flag for years now as well. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jul 22, 2021 at 05:04 UTC 359ff6938990a438b99e95fe36b6b359f3eb9811
4 files changed +48 -5
Documentation/git-merge.txt
+2
@@ -61,6 +61,8 @@ merge has resulted in conflicts.
61
62 OPTIONS
63 -------
64 +:git-merge: 1
65 +
66 include::merge-options.txt[]
67
68 -m <msg>::
Documentation/git-pull.txt
+4 -5
@@ -19,13 +19,12 @@ Incorporates changes from a remote repository into the current branch.
19 If the current branch is behind the remote, then by default it will
20 fast-forward the current branch to match the remote. If the current
21 branch and the remote have diverged, the user needs to specify how to
22 -reconcile the divergent branches with `--no-ff`, `--ff`, or `--rebase`
23 -(or the corresponding configuration options in `pull.ff` or
24 -`pull.rebase`).
22 +reconcile the divergent branches with `--rebase` or `--no-rebase` (or
23 +the corresponding configuration option in `pull.rebase`).
24
25 More precisely, `git pull` runs `git fetch` with the given parameters
26 and then depending on configuration options or command line flags,
28 -will call either `git merge` or `git rebase` to reconcile diverging
27 +will call either `git rebase` or `git merge` to reconcile diverging
28 branches.
29
30 <repository> should be the name of a remote repository as
@@ -136,7 +135,7 @@ published that history already. Do *not* use this option
135 unless you have read linkgit:git-rebase[1] carefully.
136
137 --no-rebase::
139 - Override earlier --rebase.
138 + This is shorthand for --rebase=false.
139
140 Options related to fetching
141 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Documentation/merge-options.txt
+40
@@ -2,6 +2,9 @@
2 --no-commit::
3 Perform the merge and commit the result. This option can
4 be used to override --no-commit.
5 +ifdef::git-pull[]
6 + Only useful when merging.
7 +endif::git-pull[]
8 +
9 With --no-commit perform the merge and stop just before creating
10 a merge commit, to give the user a chance to inspect and further
@@ -39,6 +42,7 @@ set to `no` at the beginning of them.
42 to `MERGE_MSG` before being passed on to the commit machinery in the
43 case of a merge conflict.
44
45 +ifdef::git-merge[]
46 --ff::
47 --no-ff::
48 --ff-only::
@@ -47,6 +51,22 @@ set to `no` at the beginning of them.
51 default unless merging an annotated (and possibly signed) tag
52 that is not stored in its natural place in the `refs/tags/`
53 hierarchy, in which case `--no-ff` is assumed.
54 +endif::git-merge[]
55 +ifdef::git-pull[]
56 +--ff-only::
57 + Only update to the new history if there is no divergent local
58 + history. This is the default when no method for reconciling
59 + divergent histories is provided (via the --rebase=* flags).
60 +
61 +--ff::
62 +--no-ff::
63 + When merging rather than rebasing, specifies how a merge is
64 + handled when the merged-in history is already a descendant of
65 + the current history. If merging is requested, `--ff` is the
66 + default unless merging an annotated (and possibly signed) tag
67 + that is not stored in its natural place in the `refs/tags/`
68 + hierarchy, in which case `--no-ff` is assumed.
69 +endif::git-pull[]
70 +
71 With `--ff`, when possible resolve the merge as a fast-forward (only
72 update the branch pointer to match the merged branch; do not create a
@@ -55,9 +75,11 @@ descendant of the current history), create a merge commit.
75 +
76 With `--no-ff`, create a merge commit in all cases, even when the merge
77 could instead be resolved as a fast-forward.
78 +ifdef::git-merge[]
79 +
80 With `--ff-only`, resolve the merge as a fast-forward when possible.
81 When not possible, refuse to merge and exit with a non-zero status.
82 +endif::git-merge[]
83
84 -S[<keyid>]::
85 --gpg-sign[=<keyid>]::
@@ -73,6 +95,9 @@ When not possible, refuse to merge and exit with a non-zero status.
95 In addition to branch names, populate the log message with
96 one-line descriptions from at most <n> actual commits that are being
97 merged. See also linkgit:git-fmt-merge-msg[1].
98 +ifdef::git-pull[]
99 + Only useful when merging.
100 +endif::git-pull[]
101 +
102 With --no-log do not list one-line descriptions from the
103 actual commits being merged.
@@ -102,10 +127,17 @@ With --no-squash perform the merge and commit the result. This
127 option can be used to override --squash.
128 +
129 With --squash, --commit is not allowed, and will fail.
130 +ifdef::git-pull[]
131 ++
132 +Only useful when merging.
133 +endif::git-pull[]
134
135 --no-verify::
136 This option bypasses the pre-merge and commit-msg hooks.
137 See also linkgit:githooks[5].
138 +ifdef::git-pull[]
139 + Only useful when merging.
140 +endif::git-pull[]
141
142 -s <strategy>::
143 --strategy=<strategy>::
@@ -127,6 +159,10 @@ With --squash, --commit is not allowed, and will fail.
159 default trust model, this means the signing key has been signed by
160 a trusted key. If the tip commit of the side branch is not signed
161 with a valid key, the merge is aborted.
162 +ifdef::git-pull[]
163 ++
164 +Only useful when merging.
165 +endif::git-pull[]
166
167 --summary::
168 --no-summary::
@@ -166,3 +202,7 @@ endif::git-pull[]
202 projects that started their lives independently. As that is
203 a very rare occasion, no configuration variable to enable
204 this by default exists and will not be added.
205 +ifdef::git-pull[]
206 ++
207 +Only useful when merging.
208 +endif::git-pull[]
builtin/pull.c
+2
@@ -893,6 +893,8 @@ static int run_rebase(const struct object_id *newbase,
893 strvec_pushv(&args, opt_strategy_opts.v);
894 if (opt_gpg_sign)
895 strvec_push(&args, opt_gpg_sign);
896 + if (opt_signoff)
897 + strvec_push(&args, opt_signoff);
898 if (opt_autostash == 0)
899 strvec_push(&args, "--no-autostash");
900 else if (opt_autostash == 1)