Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 69 lines (61 sloc) 1.912 kb
8bc9a0c Add copyright notices.
Linus Torvalds authored
1 /*
2 * GIT - The information manager from hell
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
e83c516 Initial revision of "git", the information manager from hell
Linus Torvalds authored
6 #include "cache.h"
4a6bf9e [PATCH] Reactivate show-diff patch generation
Junio C Hamano authored
7 #include "diff.h"
9153983 Log message printout cleanups
Linus Torvalds authored
8 #include "commit.h"
9 #include "revision.h"
e8cc9cd Builtin git-diff-files, git-diff-index, git-diff-stages, and git-diff-tr...
Peter Eriksen authored
10 #include "builtin.h"
c0fb976 [PATCH] show-diff show deleted files as diff as well.
Christopher Li authored
11
4d1f119 [PATCH] Unify usage strings declaration
Petr Baudis authored
12 static const char diff_files_usage[] =
1b1dd23 @sbeyer Make usage strings dash-less
sbeyer authored
13 "git diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
dda2d79 [PATCH] Clean up diff option descriptions.
Junio C Hamano authored
14 COMMON_DIFF_OPTIONS_HELP;
b8f8092 [PATCH] Optionally tell show-diff to show only named files
Junio C Hamano authored
15
a633fca Call setup_git_directory() much earlier
Linus Torvalds authored
16 int cmd_diff_files(int argc, const char **argv, const char *prefix)
e83c516 Initial revision of "git", the information manager from hell
Linus Torvalds authored
17 {
6973dca Libify diff-files.
Junio C Hamano authored
18 struct rev_info rev;
41bbf9d @raalkml Allow git-diff exit with codes similar to diff(1)
raalkml authored
19 int result;
6304c29 @gitster diff-files: do not play --no-index games
gitster authored
20 unsigned options = 0;
e83c516 Initial revision of "git", the information manager from hell
Linus Torvalds authored
21
a633fca Call setup_git_directory() much earlier
Linus Torvalds authored
22 init_revisions(&rev, prefix);
ef90d6d @dscho Provide git_config with a callback-data parameter
dscho authored
23 git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
6973dca Libify diff-files.
Junio C Hamano authored
24 rev.abbrev = 0;
25
6304c29 @gitster diff-files: do not play --no-index games
gitster authored
26 argc = setup_revisions(argc, argv, &rev, NULL);
27 while (1 < argc && argv[1][0] == '-') {
28 if (!strcmp(argv[1], "--base"))
29 rev.max_count = 1;
30 else if (!strcmp(argv[1], "--ours"))
31 rev.max_count = 2;
32 else if (!strcmp(argv[1], "--theirs"))
33 rev.max_count = 3;
34 else if (!strcmp(argv[1], "-q"))
35 options |= DIFF_SILENT_ON_REMOVED;
36 else
37 usage(diff_files_usage);
38 argv++; argc--;
39 }
c9b5ef9 @tihirvon Set default diff output format after parsing command line
tihirvon authored
40 if (!rev.diffopt.output_format)
41 rev.diffopt.output_format = DIFF_FORMAT_RAW;
6304c29 @gitster diff-files: do not play --no-index games
gitster authored
42
43 /*
44 * Make sure there are NO revision (i.e. pending object) parameter,
45 * rev.max_count is reasonable (0 <= n <= 3), and
46 * there is no other revision filtering parameters.
47 */
48 if (rev.pending.nr ||
49 rev.min_age != -1 || rev.max_age != -1 ||
50 3 < rev.max_count)
51 usage(diff_files_usage);
52
903e09a @gitster diff/diff-files: do not use --cc too aggressively
gitster authored
53 /*
54 * "diff-files --base -p" should not combine merges because it
55 * was not asked to. "diff-files -c -p" should not densify
56 * (the user should ask with "diff-files --cc" explicitly).
57 */
58 if (rev.max_count == -1 && !rev.combine_merges &&
6304c29 @gitster diff-files: do not play --no-index games
gitster authored
59 (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
60 rev.combine_merges = rev.dense_combined_merges = 1;
61
671c9b7 @torvalds Add cache preload facility
torvalds authored
62 if (read_cache_preload(rev.diffopt.paths) < 0) {
63 perror("read_cache_preload");
6304c29 @gitster diff-files: do not play --no-index games
gitster authored
64 return -1;
65 }
66 result = run_diff_files(&rev, options);
da31b35 @gitster diff --check: minor fixups
gitster authored
67 return diff_result_code(&rev.diffopt, result);
e83c516 Initial revision of "git", the information manager from hell
Linus Torvalds authored
68 }
Something went wrong with that request. Please try again.