Skip to content

Commit cf958af

Browse files
moygitster
authored andcommitted
Document -B<n>[/<m>], -M<n> and -C<n> variants of -B, -M and -C
These options take an optional argument, but this optional argument was not documented. Original patch by Matthieu Moy, but documentation for -B mostly copied from the explanations of Junio C Hamano. While we're there, fix a typo in a comment in diffcore.h. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 08b2982 commit cf958af

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

Documentation/diff-options.txt

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,29 @@ endif::git-format-patch[]
206206
the diff-patch output format. Non default number of
207207
digits can be specified with `--abbrev=<n>`.
208208

209-
-B::
210-
Break complete rewrite changes into pairs of delete and create.
211-
212-
-M::
209+
-B[<n>][/<m>]::
210+
Break complete rewrite changes into pairs of delete and
211+
create. This serves two purposes:
212+
+
213+
It affects the way a change that amounts to a total rewrite of a file
214+
not as a series of deletion and insertion mixed together with a very
215+
few lines that happen to match textually as the context, but as a
216+
single deletion of everything old followed by a single insertion of
217+
everything new, and the number `m` controls this aspect of the -B
218+
option (defaults to 60%). `-B/70%` specifies that less than 30% of the
219+
original should remain in the result for git to consider it a total
220+
rewrite (i.e. otherwise the resulting patch will be a series of
221+
deletion and insertion mixed together with context lines).
222+
+
223+
When used with -M, a totally-rewritten file is also considered as the
224+
source of a rename (usually -M only considers a file that disappeared
225+
as the source of a rename), and the number `n` controls this aspect of
226+
the -B option (defaults to 50%). `-B20%` specifies that a change with
227+
addition and deletion compared to 20% or more of the file's size are
228+
eligible for being picked up as a possible source of a rename to
229+
another file.
230+
231+
-M[<n>]::
213232
ifndef::git-log[]
214233
Detect renames.
215234
endif::git-log[]
@@ -218,9 +237,15 @@ ifdef::git-log[]
218237
For following files across renames while traversing history, see
219238
`--follow`.
220239
endif::git-log[]
240+
If `n` is specified, it is a is a threshold on the similarity
241+
index (i.e. amount of addition/deletions compared to the
242+
file's size). For example, `-M90%` means git should consider a
243+
delete/add pair to be a rename if more than 90% of the file
244+
hasn't changed.
221245

222-
-C::
246+
-C[<n>]::
223247
Detect copies as well as renames. See also `--find-copies-harder`.
248+
If `n` is specified, it has the same meaning as for `-M<n>`.
224249

225250
ifndef::git-format-patch[]
226251
--diff-filter=[ACDMRTUXB*]::

diffcore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define MAX_SCORE 60000.0
1919
#define DEFAULT_RENAME_SCORE 30000 /* rename/copy similarity minimum (50%) */
2020
#define DEFAULT_BREAK_SCORE 30000 /* minimum for break to happen (50%) */
21-
#define DEFAULT_MERGE_SCORE 36000 /* maximum for break-merge to happen 60%) */
21+
#define DEFAULT_MERGE_SCORE 36000 /* maximum for break-merge to happen (60%) */
2222

2323
#define MINIMUM_BREAK_SIZE 400 /* do not break a file smaller than this */
2424

0 commit comments

Comments
 (0)