Skip to content

Commit ce24067

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[PATCH] diff: Fix docs and add -O to diff-helper.
This patch updates diff documentation and usage strings: - clarify the semantics of -R. It is not "output in reverse"; rather, it is "I will feed diff backwards". Semantically they are different when -C is involved. - describe -O in usage strings of diff-* brothers. It was implemented, documented but not described in usage text. Also it adds -O to diff-helper. Like -S (and unlike -M/-C/-B), this option can work on sanitized diff-raw output produced by the diff-* brothers. While we are at it, the call it makes to diffcore is cleaned up to use the diffcore_std() like everybody else, and the declaration for the low level diffcore routines are moved from diff.h (public) to diffcore.h (private between diff.c and diffcore backends). Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 355e76a commit ce24067

File tree

10 files changed

+33
-27
lines changed

10 files changed

+33
-27
lines changed

Documentation/git-diff-cache.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ OPTIONS
5757
<orderfile>, which has one shell glob pattern per line.
5858

5959
-R::
60-
Output diff in reverse.
60+
Swap two inputs; that is, show differences from cache or
61+
on-disk file to tree contents.
6162

6263
--cached::
6364
do not consider the on-disk file at all

Documentation/git-diff-files.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ OPTIONS
2727
Remain silent even on nonexisting files
2828

2929
-R::
30-
Output diff in reverse.
30+
Swap two inputs; that is, show differences from on-disk files
31+
to cache contents.
3132

3233
-B::
3334
Break complete rewrite changes into pairs of delete and create.

Documentation/git-diff-helper.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ git-diff-helper - Generates patch format output for git-diff-*
99

1010
SYNOPSIS
1111
--------
12-
'git-diff-helper' [-z] [-S<string>]
12+
'git-diff-helper' [-z] [-S<string>] [-O<orderfile>]
1313

1414
DESCRIPTION
1515
-----------
@@ -24,6 +24,9 @@ OPTIONS
2424
-S<string>::
2525
Look for differences that contains the change in <string>.
2626

27+
-O<orderfile>::
28+
Output the patch in the order specified in the
29+
<orderfile>, which has one shell glob pattern per line.
2730

2831
See Also
2932
--------

Documentation/git-diff-tree.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ OPTIONS
4343
Detect copies as well as renames.
4444

4545
-R::
46-
Output diff in reverse.
46+
Swap two input trees.
4747

4848
-S<string>::
4949
Look for differences that contains the change in <string>.

diff-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void mark_merge_entries(void)
157157
}
158158

159159
static char *diff_cache_usage =
160-
"git-diff-cache [-p] [-r] [-z] [-m] [-M] [-C] [-R] [-S<string>] [--cached] <tree-ish> [<path>...]";
160+
"git-diff-cache [-p] [-r] [-z] [-m] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [--cached] <tree-ish> [<path>...]";
161161

162162
int main(int argc, const char **argv)
163163
{

diff-files.c

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

99
static const char *diff_files_usage =
10-
"git-diff-files [-p] [-q] [-r] [-z] [-M] [-C] [-R] [-S<string>] [paths...]";
10+
"git-diff-files [-p] [-q] [-r] [-z] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [paths...]";
1111

1212
static int diff_output_format = DIFF_FORMAT_HUMAN;
1313
static int detect_rename = 0;

diff-helper.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@
77

88
static const char *pickaxe = NULL;
99
static int pickaxe_opts = 0;
10+
static const char *orderfile = NULL;
1011
static int line_termination = '\n';
1112
static int inter_name_termination = '\t';
1213

14+
static void flush_them(int ac, const char **av)
15+
{
16+
diffcore_std(av + 1,
17+
0, 0, /* no renames */
18+
pickaxe, pickaxe_opts,
19+
-1, /* no breaks */
20+
orderfile);
21+
diff_flush(DIFF_FORMAT_PATCH, 0);
22+
}
23+
1324
static const char *diff_helper_usage =
14-
"git-diff-helper [-z] [-S<string>] paths...";
25+
"git-diff-helper [-z] [-S<string>] [-O<orderfile>] paths...";
1526

1627
int main(int ac, const char **av) {
1728
struct strbuf sb;
@@ -131,17 +142,9 @@ int main(int ac, const char **av) {
131142
new_path);
132143
continue;
133144
}
134-
if (1 < ac)
135-
diffcore_pathspec(av + 1);
136-
if (pickaxe)
137-
diffcore_pickaxe(pickaxe, pickaxe_opts);
138-
diff_flush(DIFF_FORMAT_PATCH, 0);
145+
flush_them(ac, av);
139146
printf(garbage_flush_format, sb.buf);
140147
}
141-
if (1 < ac)
142-
diffcore_pathspec(av + 1);
143-
if (pickaxe)
144-
diffcore_pickaxe(pickaxe, pickaxe_opts);
145-
diff_flush(DIFF_FORMAT_PATCH, 0);
148+
flush_them(ac, av);
146149
return 0;
147150
}

diff-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int diff_tree_stdin(char *line)
397397
}
398398

399399
static char *diff_tree_usage =
400-
"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S<string>] [-m] [-s] [-v] [-t] <tree-ish> <tree-ish>";
400+
"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [-m] [-s] [-v] [-t] <tree-ish> <tree-ish>";
401401

402402
int main(int argc, const char **argv)
403403
{

diff.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,13 @@ extern int diff_scoreopt_parse(const char *opt);
3535
#define DIFF_SETUP_REVERSE 1
3636
#define DIFF_SETUP_USE_CACHE 2
3737
#define DIFF_SETUP_USE_SIZE_CACHE 4
38+
3839
extern void diff_setup(int flags);
3940

4041
#define DIFF_DETECT_RENAME 1
4142
#define DIFF_DETECT_COPY 2
4243

43-
extern void diffcore_rename(int rename_copy, int minimum_score);
44-
4544
#define DIFF_PICKAXE_ALL 1
46-
extern void diffcore_pickaxe(const char *needle, int opts);
47-
48-
extern void diffcore_pathspec(const char **pathspec);
49-
50-
extern void diffcore_order(const char *orderfile);
51-
52-
extern void diffcore_break(int max_score);
5345

5446
extern void diffcore_std(const char **paths,
5547
int detect_rename, int rename_score,

diffcore.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ extern struct diff_filepair *diff_queue(struct diff_queue_struct *,
7373
struct diff_filespec *);
7474
extern void diff_q(struct diff_queue_struct *, struct diff_filepair *);
7575

76+
extern void diffcore_pathspec(const char **pathspec);
77+
extern void diffcore_break(int);
78+
extern void diffcore_rename(int rename_copy, int);
79+
extern void diffcore_pickaxe(const char *needle, int opts);
80+
extern void diffcore_order(const char *orderfile);
81+
7682
#define DIFF_DEBUG 0
7783
#if DIFF_DEBUG
7884
void diff_debug_filespec(struct diff_filespec *, int, const char *);

0 commit comments

Comments
 (0)