summaryrefslogtreecommitdiff
path: root/diff.c
AgeCommit message (Collapse)Author
2010-03-13Refactor dirty submodule detection in diff-lib.cJens Lehmann
Moving duplicated code into the new function match_stat_with_submodule(). Replacing the implicit activation of detailed checks for the dirtiness of submodules when DIFF_FORMAT_PATCH was selected with explicitly setting the recently added DIFF_OPT_DIRTY_SUBMODULES option in diff_setup_done(). Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-05Merge branch 'ld/maint-diff-quiet-w' into maintJunio C Hamano
* ld/maint-diff-quiet-w: git-diff: add a test for git diff --quiet -w git diff --quiet -w: check and report the status
2010-03-02Merge branch 'ld/maint-diff-quiet-w'Junio C Hamano
* ld/maint-diff-quiet-w: git-diff: add a test for git diff --quiet -w git diff --quiet -w: check and report the status
2010-03-02Merge branch 'ml/color-when'Junio C Hamano
* ml/color-when: Add an optional argument for --color options
2010-02-19Add an optional argument for --color optionsMark Lodato
Make git-branch, git-show-branch, git-grep, and all the diff-based programs accept an optional argument <when> for --color. The argument is a colorbool: "always", "never", or "auto". If no argument is given, "always" is used; --no-color is an alias for --color=never. This makes the command-line interface consistent with other GNU tools, such as `ls' and `grep', and with the git-config color options. Note that, without an argument, --color and --no-color work exactly as before. To implement this, two internal changes were made: 1. Allow the first argument of git_config_colorbool() to be NULL, in which case it returns -1 if the argument isn't "always", "never", or "auto". 2. Add OPT_COLOR_FLAG(), OPT__COLOR(), and parse_opt_color_flag_cb() to the option parsing library. The callback uses git_config_colorbool(), so color.h is now a dependency of parse-options.c. Signed-off-by: Mark Lodato <lodatom@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-17Merge branch 'jc/typo' into maintJunio C Hamano
* jc/typo: Typofixes outside documentation area
2010-02-17Merge branch 'jc/typo'Junio C Hamano
* jc/typo: Typofixes outside documentation area
2010-02-16Merge branch 'maint-1.6.6' into maintJunio C Hamano
* maint-1.6.6: dwim_ref: fix dangling symref warning stash pop: remove 'apply' options during 'drop' invocation diff: make sure --output=/bad/path is caught Remove hyphen from "git-command" in two error messages
2010-02-16Merge branch 'maint-1.6.5' into maint-1.6.6Junio C Hamano
* maint-1.6.5: dwim_ref: fix dangling symref warning stash pop: remove 'apply' options during 'drop' invocation diff: make sure --output=/bad/path is caught
2010-02-16git diff --quiet -w: check and report the statusLarry D'Anna
The option -w tells the diff machinery to inspect the contents to set the exit status, instead of checking the blob object level difference alone. However, --quiet tells the diff machinery not to look at the contents, which means DIFF_FROM_CONTENTS has no chance to inspect the change. Work it around by calling diff_flush_patch() with output sent to /dev/null. Signed-off-by: Larry D'Anna <larry@elder-gods.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-16diff: make sure --output=/bad/path is caughtLarry D'Anna
The return value from fopen wasn't being checked. Signed-off-by: Larry D'Anna <larry@elder-gods.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-04Typofixes outside documentation areaJunio C Hamano
begining -> beginning canonicalizations -> canonicalization comand -> command dewrapping -> unwrapping dirtyness -> dirtiness DISCLAMER -> DISCLAIMER explicitely -> explicitly feeded -> fed impiled -> implied madatory -> mandatory mimick -> mimic preceeding -> preceding reqeuest -> request substition -> substitution Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-27Merge branch 'jl/diff-submodule-ignore'Junio C Hamano
* jl/diff-submodule-ignore: Teach diff --submodule that modified submodule directory is dirty git diff: Don't test submodule dirtiness with --ignore-submodules Make ce_uptodate() trustworthy again
2010-01-25Teach diff --submodule that modified submodule directory is dirtyJens Lehmann
Since commit 8e08b4 git diff does append "-dirty" to the work tree side if the working directory of a submodule contains new or modified files. Lets do the same when the --submodule option is used. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-25Merge branch 'jc/fix-tree-walk'Junio C Hamano
* jc/fix-tree-walk: read-tree --debug-unpack unpack-trees.c: look ahead in the index unpack-trees.c: prepare for looking ahead in the index Aggressive three-way merge: fix D/F case traverse_trees(): handle D/F conflict case sanely more D/F conflict tests tests: move convenience regexp to match object names to test-lib.sh Conflicts: builtin-read-tree.c unpack-trees.c unpack-trees.h
2010-01-23Merge branch 'jl/submodule-diff'Junio C Hamano
* jl/submodule-diff: Performance optimization for detection of modified submodules git status: Show uncommitted submodule changes too when enabled Teach diff that modified submodule directory is dirty Show submodules as modified when they contain a dirty work tree
2010-01-19Merge branch 'maint-1.6.4' into maint-1.6.5Junio C Hamano
* maint-1.6.4: Fix mis-backport of t7002 base85: Make the code more obvious instead of explaining the non-obvious base85: encode_85() does not use the decode table base85 debug code: Fix length byte calculation checkout -m: do not try to fall back to --merge from an unborn branch branch: die explicitly why when calling "git branch [-a|-r] branchname". textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails
2010-01-19Merge branch 'maint-1.6.3' into maint-1.6.4Junio C Hamano
* maint-1.6.3: base85: Make the code more obvious instead of explaining the non-obvious base85: encode_85() does not use the decode table base85 debug code: Fix length byte calculation checkout -m: do not try to fall back to --merge from an unborn branch branch: die explicitly why when calling "git branch [-a|-r] branchname". textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Conflicts: builtin-commit.c
2010-01-19Merge branch 'maint-1.6.2' into maint-1.6.3Junio C Hamano
* maint-1.6.2: base85: Make the code more obvious instead of explaining the non-obvious base85: encode_85() does not use the decode table base85 debug code: Fix length byte calculation checkout -m: do not try to fall back to --merge from an unborn branch branch: die explicitly why when calling "git branch [-a|-r] branchname". textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Conflicts: diff.c
2010-01-19Performance optimization for detection of modified submodulesJens Lehmann
In the worst case is_submodule_modified() got called three times for each submodule. The information we got from scanning the whole submodule tree the first time can be reused instead. New parameters have been added to diff_change() and diff_addremove(), the information is stored in a new member of struct diff_filespec. Its value is then reused instead of calling is_submodule_modified() again. When no explicit "-dirty" is needed in the output the call to is_submodule_modified() is not necessary when the submodules HEAD already disagrees with the ref of the superproject, as this alone marks it as modified. To achieve that, get_stat_data() got an extra argument. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-17Merge branch 'jk/run-command-use-shell'Junio C Hamano
* jk/run-command-use-shell: t4030, t4031: work around bogus MSYS bash path conversion diff: run external diff helper with shell textconv: use shell to run helper editor: use run_command's shell feature run-command: optimize out useless shell calls run-command: convert simple callsites to use_shell t0021: use $SHELL_PATH for the filter script run-command: add "use shell" option
2010-01-17Teach diff that modified submodule directory is dirtyJunio C Hamano
A diff run in superproject only compares the name of the commit object bound at the submodule paths. When we compare with a work tree and the checked out submodule directory is dirty (e.g. has either staged or unstaged changes, or has new files the user forgot to add to the index), show the work tree side as "dirty". Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-13Merge branch 'nd/sparse'Junio C Hamano
* nd/sparse: (25 commits) t7002: test for not using external grep on skip-worktree paths t7002: set test prerequisite "external-grep" if supported grep: do not do external grep on skip-worktree entries commit: correctly respect skip-worktree bit ie_match_stat(): do not ignore skip-worktree bit with CE_MATCH_IGNORE_VALID tests: rename duplicate t1009 sparse checkout: inhibit empty worktree Add tests for sparse checkout read-tree: add --no-sparse-checkout to disable sparse checkout support unpack-trees(): ignore worktree check outside checkout area unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout unpack-trees.c: generalize verify_* functions unpack-trees(): add CE_WT_REMOVE to remove on worktree alone Introduce "sparse checkout" dir.c: export excluded_1() and add_excludes_from_file_1() excluded_1(): support exclude files in index unpack-trees(): carry skip-worktree bit over in merged_entry() Read .gitignore from index if it is skip-worktree Avoid writing to buffer in add_excludes_from_file_1() ... Conflicts: .gitignore Documentation/config.txt Documentation/git-update-index.txt Makefile entry.c t/t7002-grep.sh
2010-01-10Merge branch 'maint-1.6.1' into maint-1.6.2Junio C Hamano
* maint-1.6.1: base85: Make the code more obvious instead of explaining the non-obvious base85: encode_85() does not use the decode table base85 debug code: Fix length byte calculation checkout -m: do not try to fall back to --merge from an unborn branch branch: die explicitly why when calling "git branch [-a|-r] branchname". textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Conflicts: diff.c
2010-01-07unpack-trees.c: look ahead in the indexJunio C Hamano
This makes the traversal of index be in sync with the tree traversal. When unpack_callback() is fed a set of tree entries from trees, it inspects the name of the entry and checks if the an index entry with the same name could be hiding behind the current index entry, and (1) if the name appears in the index as a leaf node, it is also fed to the n_way_merge() callback function; (2) if the name is a directory in the index, i.e. there are entries in that are underneath it, then nothing is fed to the n_way_merge() callback function; (3) otherwise, if the name comes before the first eligible entry in the index, the index entry is first unpacked alone. When traverse_trees_recursive() descends into a subdirectory, the cache_bottom pointer is moved to walk index entries within that directory. All of these are omitted for diff-index, which does not even want to be fed an index entry and a tree entry with D/F conflicts. This fixes 3-way read-tree and exposes a bug in other parts of the system in t6035, test #5. The test prepares these three trees: O = HEAD^ 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/b-2/c/d 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/b/c/d 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/x A = HEAD 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/b-2/c/d 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/b/c/d 100644 blob 587be6b4c3f93f93c489c0111bba5596147a26cb a/x B = master 120000 blob a36b77384451ea1de7bd340ffca868249626bc52 a/b 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/b-2/c/d 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 a/x With a clean index that matches HEAD, running git read-tree -m -u --aggressive $O $A $B now yields 120000 a36b77384451ea1de7bd340ffca868249626bc52 3 a/b 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 a/b-2/c/d 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1 a/b/c/d 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 2 a/b/c/d 100644 587be6b4c3f93f93c489c0111bba5596147a26cb 0 a/x which is correct. "master" created "a/b" symlink that did not exist, and removed "a/b/c/d" while HEAD did not do touch either path. Before this series, read-tree did not notice the situation and resolved addition of "a/b" and removal of "a/b/c/d" independently. If A = HEAD had another path "a/b/c/e" added, this merge should conflict but instead it silently resolved "a/b" and then immediately overwrote it to add "a/b/c/e", which was quite bogus. Tests in t1012 start to work with this. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-06diff: run external diff helper with shellJeff King
This is mostly to make it more consistent with the rest of git, which uses the shell to exec helpers. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-06textconv: use shell to run helperJeff King
Currently textconv helpers are run directly. Running through the shell is useful because the user can provide a program with command line arguments, like "antiword -f". It also makes textconv more consistent with other parts of git, most of which run their helpers using the shell. The downside is that textconv helpers with shell metacharacters (like space) in the filename will be broken. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-30Merge branch 'maint'Junio C Hamano
* maint: textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Documentation: always respect core.worktree if set
2009-12-30Merge branch 'maint-1.6.1' into maintJunio C Hamano
* maint-1.6.1: textconv: stop leaking file descriptors commit: --cleanup is a message option git count-objects: handle packs bigger than 4G t7102: make the test fail if one of its check fails Conflicts: builtin-commit.c diff.c
2009-12-30textconv: stop leaking file descriptorsJeff King
We read the output from textconv helpers over a pipe, but we never actually closed our end of the pipe after using it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-26Merge branch 'gb/1.7.0-diff-whitespace-only-output'Junio C Hamano
* gb/1.7.0-diff-whitespace-only-output: No diff -b/-w output for all-whitespace changes
2009-12-26Merge branch 'jc/1.7.0-diff-whitespace-only-status'Junio C Hamano
* jc/1.7.0-diff-whitespace-only-status: diff.c: fix typoes in comments Make test case number unique diff: Rename QUIET internal option to QUICK diff: change semantics of "ignore whitespace" options Conflicts: diff.h
2009-12-16Merge branch 'maint' to sync with 1.6.5.7Junio C Hamano
* maint: Git 1.6.5.7 worktree: don't segfault with an absolute pathspec without a work tree ignore unknown color configuration help.autocorrect: do not run a command if the command given is junk Illustrate "filter" attribute with an example
2009-12-16ignore unknown color configurationJeff King
When parsing the config file, if there is a value that is syntactically correct but unused, we generally ignore it. This lets non-core porcelains store arbitrary information in the config file, and it means that configuration files can be shared between new and old versions of git (the old versions might simply ignore certain configuration). The one exception to this is color configuration; if we encounter a color.{diff,branch,status}.$slot variable, we die if it is not one of the recognized slots (presumably as a safety valve for user misconfiguration). This behavior has existed since 801235c (diff --color: use $GIT_DIR/config, 2006-06-24), but hasn't yet caused a problem. No porcelain has wanted to store extra colors, and we once a color area (like color.diff) has been introduced, we've never changed the set of color slots. However, that changed recently with the addition of color.diff.func. Now a user with color.diff.func in their config can no longer freely switch between v1.6.6 and older versions; the old versions will complain about the existence of the variable. This patch loosens the check to match the rest of git-config; unknown color slots are simply ignored. This doesn't fix this particular problem, as the older version (without this patch) is the problem, but it at least prevents it from happening again in the future. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-28Give the hunk comment its own colorBert Wesarg
Inspired by the coloring of quilt. Introduce a separate color and paint the hunk comment part, i.e. the name of the function, in a separate color "diff.func" (defaults to plain). Whitespace between hunk header and hunk comment is printed in plain color. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-28emit_line(): don't emit an empty <SET><RESET> followed by a newlineJunio C Hamano
When emit_line() is called with an empty line (but non-zero length, as we send line terminating LF or CRLF to the function), it used to emit <SET><RESET> followed by a newline. Stop the wastefulness. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-21No diff -b/-w output for all-whitespace changesGreg Bacon
Change git-diff's whitespace-ignoring modes to generate output only if a non-empty patch results, which git-apply rejects. Update the tests to look for the new behavior. Signed-off-by: Greg Bacon <gbacon@dbresearch.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-16Merge branch 'js/maint-diff-color-words' into maintJunio C Hamano
* js/maint-diff-color-words: diff --color-words: bit of clean-up diff --color-words -U0: fix the location of hunk headers t4034-diff-words: add a test for word diff without context Conflicts: diff.c
2009-11-16Merge branch 'jc/maint-blank-at-eof' into maintJunio C Hamano
* jc/maint-blank-at-eof: diff -B: colour whitespace errors diff.c: emit_add_line() takes only the rest of the line diff.c: split emit_line() from the first char and the rest of the line diff.c: shuffling code around diff --whitespace: fix blank lines at end core.whitespace: split trailing-space into blank-at-{eol,eof} diff --color: color blank-at-eof diff --whitespace=warn/error: fix blank-at-eof check diff --whitespace=warn/error: obey blank-at-eof diff.c: the builtin_diff() deals with only two-file comparison apply --whitespace: warn blank but not necessarily empty lines at EOF apply --whitespace=warn/error: diagnose blank at EOF apply.c: split check_whitespace() into two apply --whitespace=fix: detect new blank lines at eof correctly apply --whitespace=fix: fix handling of blank lines at the eof
2009-11-16Merge branch 'js/maint-diff-color-words'Junio C Hamano
* js/maint-diff-color-words: diff --color-words: bit of clean-up diff --color-words -U0: fix the location of hunk headers t4034-diff-words: add a test for word diff without context Conflicts: diff.c
2009-10-31diff --color-words: bit of clean-upJunio C Hamano
When we introduced the "word diff" mode, we could have done one of three things: * change fn_out_consume() to "this is called every time a line worth of diff becomes ready from the lower-level diff routine. This function knows two sets of helpers (one for line-oriented diff, another for word diff), and each set has various functions to be called at certain places (e.g. hunk header, context, ...). The function's role is to inspect the incoming line, and dispatch appropriate helpers to produce either line- or word- oriented diff output." * introduce fn_out_consume_word_diff() that is "this is called every time a line worth of diff becomes ready from the lower-level diff routine, and here is what we do to prepare word oriented diff using that line." without touching fn_out_consume() at all. * Do neither of the above, and keep fn_out_consume() to "this is called every time a line worth of diff becomes ready from the lower-level diff routine, and here is what we do to output line oriented diff using that line." but sprinkle a handful of 'are we in word-diff mode? if so do this totally different thing' at random places. This patch is to at least abstract the details of "this totally different thing" out from the main codepath, in order to improve readability. We can later refactor it by introducing fn_out_consume_word_diff(), taking the second route above, but that is a separate topic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-31Merge branch 'js/diff-verbose-submodule'Junio C Hamano
* js/diff-verbose-submodule: add tests for git diff --submodule Add the --submodule option to the diff option family
2009-10-30diff --color-words -U0: fix the location of hunk headersJohannes Schindelin
Colored word diff without context lines firstly printed all the hunk headers among each other and then printed the diff. This was due to the code relying on getting at least one context line at the end of each hunk, where the colored words would be flushed (it is done that way to be able to ignore rewrapped lines). Noticed by Markus Heidelberg. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-20Add the --submodule option to the diff option familyJohannes Schindelin
When you use the option --submodule=log you can see the submodule summaries inlined in the diff, instead of not-quite-helpful SHA-1 pairs. The format imitates what "git submodule summary" shows. To do that, <path>/.git/objects/ is added to the alternate object databases (if that directory exists). This option was requested by Jens Lehmann at the GitTogether in Berlin. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-17Merge branch 'jc/maint-blank-at-eof'Junio C Hamano
* jc/maint-blank-at-eof: diff -B: colour whitespace errors diff.c: emit_add_line() takes only the rest of the line diff.c: split emit_line() from the first char and the rest of the line diff.c: shuffling code around diff --whitespace: fix blank lines at end core.whitespace: split trailing-space into blank-at-{eol,eof} diff --color: color blank-at-eof diff --whitespace=warn/error: fix blank-at-eof check diff --whitespace=warn/error: obey blank-at-eof diff.c: the builtin_diff() deals with only two-file comparison apply --whitespace: warn blank but not necessarily empty lines at EOF apply --whitespace=warn/error: diagnose blank at EOF apply.c: split check_whitespace() into two apply --whitespace=fix: detect new blank lines at eof correctly apply --whitespace=fix: fix handling of blank lines at the eof
2009-10-12diff.c: stylefixFelipe Contreras
Essentially; s/type* /type */ as per the coding guidelines. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-15Merge branch 'jc/maint-1.6.0-blank-at-eof' into jc/maint-blank-at-eofJunio C Hamano
* jc/maint-1.6.0-blank-at-eof: diff -B: colour whitespace errors
2009-09-15Merge branch 'jc/maint-1.6.0-blank-at-eof' (early part) into ↵Junio C Hamano
jc/maint-blank-at-eof * 'jc/maint-1.6.0-blank-at-eof' (early part): diff.c: emit_add_line() takes only the rest of the line diff.c: split emit_line() from the first char and the rest of the line
2009-09-15Merge branch 'jc/maint-1.6.0-blank-at-eof' (early part) into ↵Junio C Hamano
jc/maint-blank-at-eof * 'jc/maint-1.6.0-blank-at-eof' (early part): diff.c: shuffling code around
2009-09-15Merge branch 'jc/maint-1.6.0-blank-at-eof' (early part) into ↵Junio C Hamano
jc/maint-blank-at-eof * 'jc/maint-1.6.0-blank-at-eof' (early part): diff --whitespace: fix blank lines at end core.whitespace: split trailing-space into blank-at-{eol,eof} diff --color: color blank-at-eof diff --whitespace=warn/error: fix blank-at-eof check diff --whitespace=warn/error: obey blank-at-eof diff.c: the builtin_diff() deals with only two-file comparison apply --whitespace: warn blank but not necessarily empty lines at EOF apply --whitespace=warn/error: diagnose blank at EOF apply.c: split check_whitespace() into two apply --whitespace=fix: detect new blank lines at eof correctly apply --whitespace=fix: fix handling of blank lines at the eof