From: Junio C Hamano Date: Tue, 31 May 2011 17:57:32 +0000 (-0700) Subject: Merge remote-tracking branch 'ko/maint' into jc/diff-index-quick-exit-early X-Git-Tag: v1.7.6.1~32^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d11f21c365821ccba1e093f22b99ad71b955f21;p=git.git Merge remote-tracking branch 'ko/maint' into jc/diff-index-quick-exit-early * ko/maint: (4352 commits) git-submodule.sh: separate parens by a space to avoid confusing some shells Documentation/technical/api-diff.txt: correct name of diff_unmerge() read_gitfile_gently: use ssize_t to hold read result remove tests of always-false condition rerere.c: diagnose a corrupt MERGE_RR when hitting EOF between TAB and '\0' Git 1.7.5.3 init/clone: remove short option -L and document --separate-git-dir do not read beyond end of malloc'd buffer git-svn: Fix git svn log --show-commit Git 1.7.5.2 provide a copy of the LGPLv2.1 test core.gitproxy configuration copy_gecos: fix not adding nlen to len when processing "&" Update draft release notes to 1.7.5.2 Documentation/git-fsck.txt: fix typo: unreadable -> unreachable send-pack: avoid deadlock on git:// push with failed pack-objects connect: let callers know if connection is a socket connect: treat generic proxy processes like ssh processes sideband_demux(): fix decl-after-stmt t3503: test cherry picking and reverting root commits ... Conflicts: diff.c --- 2d11f21c365821ccba1e093f22b99ad71b955f21 diff --cc diff-lib.c index 869d8f0e7,3b5f2242a..9c29293bb --- a/diff-lib.c +++ b/diff-lib.c @@@ -72,11 -100,14 +100,12 @@@ int run_diff_files(struct rev_info *rev unsigned int oldmode, newmode; struct cache_entry *ce = active_cache[i]; int changed; + unsigned dirty_submodule = 0; - if (DIFF_OPT_TST(&revs->diffopt, QUICK) && - !revs->diffopt.filter && - DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) + if (diff_can_quit_early(&revs->diffopt)) break; - if (!ce_path_match(ce, revs->prune_data)) + if (!ce_path_match(ce, &revs->prune_data)) continue; if (ce_stage(ce)) { diff --cc diff.c index ae6853fcf,9a8012e36..7d1cdea31 --- a/diff.c +++ b/diff.c @@@ -3513,13 -4288,24 +4288,31 @@@ int diff_result_code(struct diff_option return result; } +int diff_can_quit_early(struct diff_options *opt) +{ + return (DIFF_OPT_TST(opt, QUICK) && + !opt->filter && + DIFF_OPT_TST(opt, HAS_CHANGES)); +} + + /* + * Shall changes to this submodule be ignored? + * + * Submodule changes can be configured to be ignored separately for each path, + * but that configuration can be overridden from the command line. + */ + static int is_submodule_ignored(const char *path, struct diff_options *options) + { + int ignored = 0; + unsigned orig_flags = options->flags; + if (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG)) + set_diffopt_flags_from_submodule_config(options, path); + if (DIFF_OPT_TST(options, IGNORE_SUBMODULES)) + ignored = 1; + options->flags = orig_flags; + return ignored; + } + void diff_addremove(struct diff_options *options, int addremove, unsigned mode, const unsigned char *sha1, diff --cc t/t4040-whitespace-status.sh index 000000000,abc49348b..3c728a3eb mode 000000,100755..100755 --- a/t/t4040-whitespace-status.sh +++ b/t/t4040-whitespace-status.sh @@@ -1,0 -1,70 +1,75 @@@ + #!/bin/sh + + test_description='diff --exit-code with whitespace' + . ./test-lib.sh + + test_expect_success setup ' + mkdir a b && + echo >c && + echo >a/d && + echo >b/e && + git add . && + test_tick && + git commit -m initial && + echo " " >a/d && + test_tick && + git commit -a -m second && + echo " " >a/d && + echo " " >b/e && + git add a/d + ' + + test_expect_success 'diff-tree --exit-code' ' + test_must_fail git diff --exit-code HEAD^ HEAD && + test_must_fail git diff-tree --exit-code HEAD^ HEAD + ' + + test_expect_success 'diff-tree -b --exit-code' ' + git diff -b --exit-code HEAD^ HEAD && + git diff-tree -b -p --exit-code HEAD^ HEAD && + git diff-tree -b --exit-code HEAD^ HEAD + ' + + test_expect_success 'diff-index --cached --exit-code' ' + test_must_fail git diff --cached --exit-code HEAD && + test_must_fail git diff-index --cached --exit-code HEAD + ' + + test_expect_success 'diff-index -b -p --cached --exit-code' ' + git diff -b --cached --exit-code HEAD && + git diff-index -b -p --cached --exit-code HEAD + ' + + test_expect_success 'diff-index --exit-code' ' + test_must_fail git diff --exit-code HEAD && + test_must_fail git diff-index --exit-code HEAD + ' + + test_expect_success 'diff-index -b -p --exit-code' ' + git diff -b --exit-code HEAD && + git diff-index -b -p --exit-code HEAD + ' + + test_expect_success 'diff-files --exit-code' ' + test_must_fail git diff --exit-code && + test_must_fail git diff-files --exit-code + ' + + test_expect_success 'diff-files -b -p --exit-code' ' + git diff -b --exit-code && + git diff-files -b -p --exit-code + ' + + test_expect_success 'diff-files --diff-filter --quiet' ' + git reset --hard && + rm a/d && + echo x >>b/e && + test_must_fail git diff-files --diff-filter=M --quiet + ' + ++test_expect_success 'diff-tree --diff-filter --quiet' ' ++ git commit -a -m "worktree state" && ++ test_must_fail git diff-tree --diff-filter=M --quiet HEAD^ HEAD ++' ++ + test_done diff --cc tree-diff.c index 33881d1ad,76f83fcc2..072c44160 --- a/tree-diff.c +++ b/tree-diff.c @@@ -281,16 -137,30 +137,29 @@@ static void skip_uninteresting(struct t } } - int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt) + int diff_tree(struct tree_desc *t1, struct tree_desc *t2, + const char *base_str, struct diff_options *opt) { - int baselen = strlen(base); + struct strbuf base; + int baselen = strlen(base_str); + int all_t1_interesting = 0; + int all_t2_interesting = 0; + + /* Enable recursion indefinitely */ + opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE); + opt->pathspec.max_depth = -1; + + strbuf_init(&base, PATH_MAX); + strbuf_add(&base, base_str, baselen); for (;;) { - if (DIFF_OPT_TST(opt, QUICK) && - DIFF_OPT_TST(opt, HAS_CHANGES)) + if (diff_can_quit_early(opt)) break; - if (opt->nr_paths) { - skip_uninteresting(t1, base, baselen, opt); - skip_uninteresting(t2, base, baselen, opt); + if (opt->pathspec.nr) { + if (!all_t1_interesting) + skip_uninteresting(t1, &base, opt, &all_t1_interesting); + if (!all_t2_interesting) + skip_uninteresting(t2, &base, opt, &all_t2_interesting); } if (!t1->size) { if (!t2->size)