Skip to content

Commit dda2d79

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[PATCH] Clean up diff option descriptions.
I got tired of maintaining almost duplicated descriptions in diff-* brothers, both in usage string and documentation. Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 52f2852 commit dda2d79

File tree

11 files changed

+96
-180
lines changed

11 files changed

+96
-180
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ man1: $(DOC_MAN1)
2525
man7: $(DOC_MAN7)
2626

2727
# 'include' dependencies
28-
git-diff-%.txt: diff-format.txt
28+
git-diff-%.txt: diff-format.txt diff-options.txt
2929
touch $@
3030

3131
clean:

Documentation/diff-options.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-p::
2+
Generate patch (see section on generating patches)
3+
4+
-u::
5+
Synonym for "-p".
6+
7+
-r::
8+
Look recursivelly in subdirectories; this flag does not
9+
mean anything to commands other than "git-diff-tree";
10+
other commands always looks at all the subdirectories.
11+
12+
-z::
13+
\0 line termination on output
14+
15+
--name-only::
16+
Show only names of changed files.
17+
18+
--name-only-z::
19+
Same as --name-only, but terminate lines with NUL.
20+
21+
-B::
22+
Break complete rewrite changes into pairs of delete and create.
23+
24+
-M::
25+
Detect renames.
26+
27+
-C::
28+
Detect copies as well as renames.
29+
30+
--find-copies-harder::
31+
By default, -C option finds copies only if the original
32+
file of the copy was modified in the same changeset for
33+
performance reasons. This flag makes the command
34+
inspect unmodified files as candidates for the source of
35+
copy. This is a very expensive operation for large
36+
projects, so use it with caution.
37+
38+
-S<string>::
39+
Look for differences that contains the change in <string>.
40+
41+
--pickaxe-all::
42+
When -S finds a change, show all the changes in that
43+
changeset, not just the files that contains the change
44+
in <string>.
45+
46+
-O<orderfile>::
47+
Output the patch in the order specified in the
48+
<orderfile>, which has one shell glob pattern per line.
49+
50+
-R::
51+
Swap two inputs; that is, show differences from cache or
52+
on-disk file to tree contents.
53+

Documentation/git-diff-cache.txt

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-diff-cache - Compares content and mode of blobs between the cache and reposi
99

1010
SYNOPSIS
1111
--------
12-
'git-diff-cache' [-p] [-r] [-z] [-m] [--cached] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> [<path>...]
12+
'git-diff-cache' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
1313

1414
DESCRIPTION
1515
-----------
@@ -21,53 +21,11 @@ entries in the cache are compared.
2121

2222
OPTIONS
2323
-------
24+
include::diff-options.txt[]
25+
2426
<tree-ish>::
2527
The id of a tree object to diff against.
2628

27-
-p::
28-
Generate patch (see section on generating patches)
29-
30-
-r::
31-
This flag does not mean anything. It is there only to match
32-
"git-diff-tree". Unlike "git-diff-tree", "git-diff-cache"
33-
always looks at all the subdirectories.
34-
35-
-z::
36-
\0 line termination on output
37-
38-
-B::
39-
Break complete rewrite changes into pairs of delete and create.
40-
41-
-M::
42-
Detect renames.
43-
44-
-C::
45-
Detect copies as well as renames.
46-
47-
--find-copies-harder::
48-
By default, -C option finds copies only if the original
49-
file of the copy was modified in the same changeset for
50-
performance reasons. This flag makes the command
51-
inspect unmodified files as candidates for the source of
52-
copy. This is a very expensive operation for large
53-
projects, so use it with caution.
54-
55-
-S<string>::
56-
Look for differences that contains the change in <string>.
57-
58-
--pickaxe-all::
59-
When -S finds a change, show all the changes in that
60-
changeset, not just the files that contains the change
61-
in <string>.
62-
63-
-O<orderfile>::
64-
Output the patch in the order specified in the
65-
<orderfile>, which has one shell glob pattern per line.
66-
67-
-R::
68-
Swap two inputs; that is, show differences from cache or
69-
on-disk file to tree contents.
70-
7129
--cached::
7230
do not consider the on-disk file at all
7331

Documentation/git-diff-files.txt

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-diff-files - Compares files in the working tree and the cache
99

1010
SYNOPSIS
1111
--------
12-
'git-diff-files' [-p] [-q] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]
12+
'git-diff-files' [-q] [<common diff options>] [<path>...]
1313

1414
DESCRIPTION
1515
-----------
@@ -20,51 +20,11 @@ same as "git-diff-cache" and "git-diff-tree".
2020

2121
OPTIONS
2222
-------
23-
-p::
24-
generate patch (see section on generating patches).
23+
include::diff-options.txt[]
2524

2625
-q::
2726
Remain silent even on nonexisting files
2827

29-
-R::
30-
Swap two inputs; that is, show differences from on-disk files
31-
to cache contents.
32-
33-
-B::
34-
Break complete rewrite changes into pairs of delete and create.
35-
36-
-M::
37-
Detect renames.
38-
39-
-C::
40-
Detect copies as well as renames.
41-
42-
--find-copies-harder::
43-
By default, -C option finds copies only if the original
44-
file of the copy was modified in the same changeset for
45-
performance reasons. This flag makes the command
46-
inspect unmodified files as candidates for the source of
47-
copy. This is a very expensive operation for large
48-
projects, so use it with caution.
49-
50-
-S<string>::
51-
Look for differences that contains the change in <string>.
52-
53-
--pickaxe-all::
54-
When -S finds a change, show all the changes in that
55-
changeset, not just the files that contains the change
56-
in <string>.
57-
58-
-O<orderfile>::
59-
Output the patch in the order specified in the
60-
<orderfile>, which has one shell glob pattern per line.
61-
62-
-r::
63-
This flag does not mean anything. It is there only to match
64-
git-diff-tree. Unlike git-diff-tree, git-diff-files always looks
65-
at all the subdirectories.
66-
67-
6828
Output format
6929
-------------
7030
include::diff-format.txt[]

Documentation/git-diff-stages.txt

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-diff-stages - Compares content and mode of blobs between stages in an unmerg
99

1010
SYNOPSIS
1111
--------
12-
'git-diff-stages' [-p] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <stage1> <stage2> [<path>...]
12+
'git-diff-stages' [<common diff options>] <stage1> <stage2> [<path>...]
1313

1414
DESCRIPTION
1515
-----------
@@ -18,53 +18,11 @@ unmerged index file.
1818

1919
OPTIONS
2020
-------
21+
include::diff-options.txt[]
22+
2123
<stage1>,<stage2>::
2224
The stage number to be compared.
2325

24-
-p::
25-
Generate patch (see section on generating patches)
26-
27-
-r::
28-
This flag does not mean anything. It is there only to match
29-
"git-diff-tree". Unlike "git-diff-tree", "git-diff-stages"
30-
always looks at all the subdirectories.
31-
32-
-z::
33-
\0 line termination on output
34-
35-
-B::
36-
Break complete rewrite changes into pairs of delete and create.
37-
38-
-M::
39-
Detect renames.
40-
41-
-C::
42-
Detect copies as well as renames.
43-
44-
--find-copies-harder::
45-
By default, -C option finds copies only if the original
46-
file of the copy was modified in the same changeset for
47-
performance reasons. This flag makes the command
48-
inspect unmodified files as candidates for the source of
49-
copy. This is a very expensive operation for large
50-
projects, so use it with caution.
51-
52-
-S<string>::
53-
Look for differences that contains the change in <string>.
54-
55-
--pickaxe-all::
56-
When -S finds a change, show all the changes in that
57-
changeset, not just the files that contains the change
58-
in <string>.
59-
60-
-O<orderfile>::
61-
Output the patch in the order specified in the
62-
<orderfile>, which has one shell glob pattern per line.
63-
64-
-R::
65-
Swap two inputs; that is, show differences from <stage2> to
66-
<stage1>.
67-
6826
Output format
6927
-------------
7028
include::diff-format.txt[]

Documentation/git-diff-tree.txt

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-diff-tree - Compares the content and mode of blobs found via two tree object
99

1010
SYNOPSIS
1111
--------
12-
'git-diff-tree' [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [-t] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish> [<path>...]
12+
'git-diff-tree' [--stdin] [-m] [-s] [-v] [--pretty] [-t] [<common diff options>] <tree-ish> <tree-ish> [<path>...]
1313

1414
DESCRIPTION
1515
-----------
@@ -19,6 +19,8 @@ Note that "git-diff-tree" can use the tree encapsulated in a commit object.
1919

2020
OPTIONS
2121
-------
22+
include::diff-options.txt[]
23+
2224
<tree-ish>::
2325
The id of a tree object.
2426

@@ -29,51 +31,9 @@ OPTIONS
2931
Note that this parameter does not provide any wildcard or regexp
3032
features.
3133

32-
-p::
33-
generate patch (see section on generating patches). For
34-
git-diff-tree, this flag implies '-r' as well.
35-
36-
-B::
37-
Break complete rewrite changes into pairs of delete and create.
38-
39-
-M::
40-
Detect renames.
41-
42-
-C::
43-
Detect copies as well as renames.
44-
45-
--find-copies-harder::
46-
By default, -C option finds copies only if the original
47-
file of the copy was modified in the same changeset for
48-
performance reasons. This flag makes the command
49-
inspect unmodified files as candidates for the source of
50-
copy. This is a very expensive operation for large
51-
projects, so use it with caution.
52-
53-
-R::
54-
Swap two input trees.
55-
56-
-S<string>::
57-
Look for differences that contains the change in <string>.
58-
59-
--pickaxe-all::
60-
When -S finds a change, show all the changes in that
61-
changeset, not just the files that contains the change
62-
in <string>.
63-
64-
-O<orderfile>::
65-
Output the patch in the order specified in the
66-
<orderfile>, which has one shell glob pattern per line.
67-
68-
-r::
69-
recurse
70-
7134
-t::
7235
show tree entry itself as well as subtrees. Implies -r.
7336

74-
-z::
75-
\0 line termination on output
76-
7737
--root::
7838
When '--root' is specified the initial commit will be showed as a big
7939
creation event. This is equivalent to a diff against the NULL tree.

diff-cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ static void mark_merge_entries(void)
159159
}
160160

161161
static char *diff_cache_usage =
162-
"git-diff-cache [-p] [-r] [-z] [-m] [--cached] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> [<path>...]";
162+
"git-diff-cache [-m] [--cached] "
163+
"[<common diff options>] <tree-ish> [<path>...]"
164+
COMMON_DIFF_OPTIONS_HELP;
163165

164166
int main(int argc, const char **argv)
165167
{

diff-files.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include "diff.h"
88

99
static const char *diff_files_usage =
10-
"git-diff-files [-p] [-q] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]";
10+
"git-diff-files [-q] "
11+
"[<common diff options>] [<path>...]"
12+
COMMON_DIFF_OPTIONS_HELP;
1113

1214
static int diff_output_format = DIFF_FORMAT_HUMAN;
1315
static int detect_rename = 0;

diff-stages.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ static const char *orderfile = NULL;
1717
static const char *diff_filter = NULL;
1818

1919
static char *diff_stages_usage =
20-
"git-diff-stages [-p] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <stage1> <stage2> [<path>...]";
20+
"git-diff-stages [<common diff options>] <stage1> <stage2> [<path>...]"
21+
COMMON_DIFF_OPTIONS_HELP;
2122

2223
static void diff_stages(int stage1, int stage2)
2324
{

diff-tree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ static int diff_tree_stdin(char *line)
395395
}
396396

397397
static char *diff_tree_usage =
398-
"git-diff-tree [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [--pretty] [-t] [-R] [-B] [-M] [-C] [--find-copies-header] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish>";
398+
"git-diff-tree [--stdin] [-m] [-s] [-v] [--pretty] [-t] "
399+
"[<common diff options>] <tree-ish> <tree-ish>"
400+
COMMON_DIFF_OPTIONS_HELP;
399401

400402
int main(int argc, const char **argv)
401403
{

diff.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ extern void diffcore_std_no_resolve(const char **paths,
5353
const char *pickaxe, int pickaxe_opts,
5454
const char *orderfile, const char *filter);
5555

56+
#define COMMON_DIFF_OPTIONS_HELP \
57+
"\ncommon diff options:\n" \
58+
" -r diff recursively (only meaningful in diff-tree)\n" \
59+
" -z output diff-raw with lines terminated with NUL.\n" \
60+
" -p output patch format.\n" \
61+
" -u synonym for -p.\n" \
62+
" --name-only show only names of changed files.\n" \
63+
" --name-only-z\n" \
64+
" same as --name-only but terminate lines with NUL.\n" \
65+
" -R swap input file pairs.\n" \
66+
" -B detect complete rewrites.\n" \
67+
" -M detect renames.\n" \
68+
" -C detect copies.\n" \
69+
" --find-copies-harder\n" \
70+
" try unchanged files as candidate for copy detection.\n" \
71+
" -O<file> reorder diffs according to the <file>.\n" \
72+
" -S<string> find filepair whose only one side contains the string.\n" \
73+
" --pickaxe-all\n" \
74+
" show all files diff when -S is used and hit is found.\n"
75+
5676
extern int diff_queue_is_empty(void);
5777

5878
#define DIFF_FORMAT_HUMAN 0

0 commit comments

Comments
 (0)