From 4551d05fe44c6d87ff8a24cfba7a79bba0179d5e Mon Sep 17 00:00:00 2001 From: Andrew Ruder Date: Thu, 26 Apr 2007 23:58:55 -0500 Subject: Removing -n option from git-diff-files documentation -n is not a short form of --no-index as the documentation suggests. Removing it from the documentation and command usage string. Signed-off-by: Andrew Ruder Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 6ba5077a2b..6cb30c8e12 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -10,7 +10,7 @@ #include "builtin.h" static const char diff_files_usage[] = -"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|-n|--no-index] [] [...]" +"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|--no-index] [] [...]" COMMON_DIFF_OPTIONS_HELP; int cmd_diff_files(int argc, const char **argv, const char *prefix) -- cgit v1.2.3 From 8f67f8aefb1b751073f8b36fae8be8f72eb93f4a Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 10 Nov 2007 20:05:14 +0100 Subject: Make the diff_options bitfields be an unsigned with explicit masks. reverse_diff was a bit-value in disguise, it's merged in the flags now. Signed-off-by: Pierre Habouzit Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 6cb30c8e12..046b7e34b5 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -31,5 +31,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; result = run_diff_files_cmd(&rev, argc, argv); - return rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result; + if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS)) + return DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0; + return result; } -- cgit v1.2.3 From 62c64895cfcf3bbf34969a69fa96a631f7d5b14e Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Thu, 13 Dec 2007 21:24:52 +0100 Subject: "diff --check" should affect exit status "git diff" has a --check option that can be used to check for whitespace problems but it only reported by printing warnings to the console. Now when the --check option is used we give a non-zero exit status, making "git diff --check" nicer to use in scripts and hooks. Signed-off-by: Wincent Colaiuta Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 046b7e34b5..4afc8724e7 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -33,5 +33,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) result = run_diff_files_cmd(&rev, argc, argv); if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS)) return DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0; + if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF) + return DIFF_OPT_TST(&rev.diffopt, CHECK_FAILED) != 0; return result; } -- cgit v1.2.3 From da31b358fb39b32622c14343ffe157a765f3948b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 13 Dec 2007 23:40:27 -0800 Subject: diff --check: minor fixups There is no reason --exit-code and --check-diff must be mutually exclusive, so assign different bits to different results and allow them to be returned from the command. Introduce diff_result_code() to factor out the common code to decide final status code based on diffopt settings and use it everywhere. Update tests to match the above fix. Turning pager off when "diff --check" is used is a regression. Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 4afc8724e7..9c04111656 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -31,9 +31,5 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; result = run_diff_files_cmd(&rev, argc, argv); - if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS)) - return DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0; - if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF) - return DIFF_OPT_TST(&rev.diffopt, CHECK_FAILED) != 0; - return result; + return diff_result_code(&rev.diffopt, result); } -- cgit v1.2.3 From 9a1805a8726ee41f25be2e0f2d5f38f1150d38e4 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 4 Jan 2008 03:59:34 -0500 Subject: add a "basic" diff config callback The diff porcelain uses git_diff_ui_config to set porcelain-ish config options, like automatically turning on color. The plumbing specifically avoids calling this function, since it doesn't want things like automatic color or rename detection. However, some diff options should be set for both plumbing and porcelain. For example, one can still turn on color in git-diff-files using the --color command line option. This means we want the color config from color.diff.* (so that once color is on, we use the user's preferred scheme), but _not_ the color.diff variable. We split the diff config into "ui" and "basic", where "basic" is suitable for use by plumbing (so _most_ things affecting the output should still go into the "ui" part). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 9c04111656..4abe3c28fb 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -21,7 +21,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) prefix = setup_git_directory_gently(&nongit); init_revisions(&rev, prefix); - git_config(git_default_config); /* no "diff" UI options */ + git_config(git_diff_basic_config); /* no "diff" UI options */ rev.abbrev = 0; if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) -- cgit v1.2.3 From af05d67939f306a68c5f81ed30f65a82ae025661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Tue, 25 Mar 2008 22:06:26 +0100 Subject: Always set *nongit_ok in setup_git_directory_gently() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setup_git_directory_gently() only modified the value of its *nongit_ok argument if we were not in a git repository. Now it will always set it to 0 when we are inside a repository. Also remove now unnecessary initializations in the callers of this function. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 4abe3c28fb..e2306c162a 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -16,7 +16,7 @@ COMMON_DIFF_OPTIONS_HELP; int cmd_diff_files(int argc, const char **argv, const char *prefix) { struct rev_info rev; - int nongit = 0; + int nongit; int result; prefix = setup_git_directory_gently(&nongit); -- cgit v1.2.3 From ef90d6d4208a5130185b04f06e5f90a5f9959fe3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 14 May 2008 18:46:53 +0100 Subject: Provide git_config with a callback-data parameter git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index e2306c162a..907392a1f3 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -21,7 +21,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) prefix = setup_git_directory_gently(&nongit); init_revisions(&rev, prefix); - git_config(git_diff_basic_config); /* no "diff" UI options */ + git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ rev.abbrev = 0; if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) -- cgit v1.2.3 From 6304c29d518206b0780291a02f94f435abf82d74 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 May 2008 18:15:03 -0700 Subject: diff-files: do not play --no-index games Being able to say "git diff A B" outside a git repository and getting a colourful version of "diff -u A B" may be nice, but such a cute hack should not give bogus results to scripts that want to give two paths, either or both of which happen to have been removed from the work tree, to "git diff-files". Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index e2306c162a..3aa031f24f 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -10,26 +10,54 @@ #include "builtin.h" static const char diff_files_usage[] = -"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|--no-index] [] [...]" +"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [] [...]" COMMON_DIFF_OPTIONS_HELP; int cmd_diff_files(int argc, const char **argv, const char *prefix) { struct rev_info rev; - int nongit; int result; + unsigned options = 0; - prefix = setup_git_directory_gently(&nongit); init_revisions(&rev, prefix); git_config(git_diff_basic_config); /* no "diff" UI options */ rev.abbrev = 0; - if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix)) - argc = 0; - else - argc = setup_revisions(argc, argv, &rev, NULL); + argc = setup_revisions(argc, argv, &rev, NULL); + while (1 < argc && argv[1][0] == '-') { + if (!strcmp(argv[1], "--base")) + rev.max_count = 1; + else if (!strcmp(argv[1], "--ours")) + rev.max_count = 2; + else if (!strcmp(argv[1], "--theirs")) + rev.max_count = 3; + else if (!strcmp(argv[1], "-q")) + options |= DIFF_SILENT_ON_REMOVED; + else + usage(diff_files_usage); + argv++; argc--; + } if (!rev.diffopt.output_format) rev.diffopt.output_format = DIFF_FORMAT_RAW; - result = run_diff_files_cmd(&rev, argc, argv); + + /* + * Make sure there are NO revision (i.e. pending object) parameter, + * rev.max_count is reasonable (0 <= n <= 3), and + * there is no other revision filtering parameters. + */ + if (rev.pending.nr || + rev.min_age != -1 || rev.max_age != -1 || + 3 < rev.max_count) + usage(diff_files_usage); + + if (rev.max_count == -1 && + (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) + rev.combine_merges = rev.dense_combined_merges = 1; + + if (read_cache() < 0) { + perror("read_cache"); + return -1; + } + result = run_diff_files(&rev, options); return diff_result_code(&rev.diffopt, result); } -- cgit v1.2.3 From 1b1dd23f2d6a707b7077cdf6bc6d4055bd0bfb7d Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Sun, 13 Jul 2008 15:36:15 +0200 Subject: Make usage strings dash-less When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 384d871263..9bf10bb37e 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -10,7 +10,7 @@ #include "builtin.h" static const char diff_files_usage[] = -"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [] [...]" +"git diff-files [-q] [-0/-1/2/3 |-c|--cc] [] [...]" COMMON_DIFF_OPTIONS_HELP; int cmd_diff_files(int argc, const char **argv, const char *prefix) -- cgit v1.2.3 From 903e09a3ecca8941b32bae08b821545941591348 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 18 Sep 2008 00:32:37 -0700 Subject: diff/diff-files: do not use --cc too aggressively Textual diff output for unmerged paths was too eager to give condensed combined diff. Even though "diff -c" (and "diff-files -c -p") is a request to view combined diff without condensing (otherwise the user would have explicitly asked for --cc, not -c), we showed "--cc" output anyway. 0fe7c1d (built-in diff: assorted updates, 2006-04-29) claimed to be careful about doing this, but its breakage was hidden because back then "git diff" was still a shell script that did not use the codepath it introduced fully. Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 9bf10bb37e..2b578c714d 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) 3 < rev.max_count) usage(diff_files_usage); - if (rev.max_count == -1 && + /* + * "diff-files --base -p" should not combine merges because it + * was not asked to. "diff-files -c -p" should not densify + * (the user should ask with "diff-files --cc" explicitly). + */ + if (rev.max_count == -1 && !rev.combine_merges && (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) rev.combine_merges = rev.dense_combined_merges = 1; -- cgit v1.2.3 From 671c9b7e315db89081cc69f83a8f405e4aca37bc Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 13 Nov 2008 16:36:30 -0800 Subject: Add cache preload facility This can do the lstat() storm in parallel, giving potentially much improved performance for cold-cache cases or things like NFS that have weak metadata caching. Just use "read_cache_preload()" instead of "read_cache()" to force an optimistic preload of the index stat data. The function takes a pathspec as its argument, allowing us to preload only the relevant portion of the index. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-diff-files.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin-diff-files.c') diff --git a/builtin-diff-files.c b/builtin-diff-files.c index 2b578c714d..5b64011de8 100644 --- a/builtin-diff-files.c +++ b/builtin-diff-files.c @@ -59,8 +59,8 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) (rev.diffopt.output_format & DIFF_FORMAT_PATCH)) rev.combine_merges = rev.dense_combined_merges = 1; - if (read_cache() < 0) { - perror("read_cache"); + if (read_cache_preload(rev.diffopt.paths) < 0) { + perror("read_cache_preload"); return -1; } result = run_diff_files(&rev, options); -- cgit v1.2.3