aboutsummaryrefslogtreecommitdiff
path: root/builtin-diff.c
Commit message (Collapse)AuthorAge
* Make the diff_options bitfields be an unsigned with explicit masks.Pierre Habouzit2007-11-11
| | | | | | | reverse_diff was a bit-value in disguise, it's merged in the flags now. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* refresh_index_quietly(): express "optional" nature of index writing betterJunio C Hamano2007-11-08
| | | | | | | | | | | | | | | | | The point of the part of the code this patch touches is that if we modified the active_cache, we try to write it out and make it the index file for later users to use by calling "commit_locked_index", but we do not really care about the failure from this sequence because it is done purely as an optimization. The original code called three functions primarily for their side effects but as condition of an if statement, which is admittedly a bad style. Incidentally, it squelches an "empty if body" warning from gcc. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-diff: resurrect the traditional empty "diff --git" behaviourJunio C Hamano2007-08-31
| | | | | | | | | | | | | | | | | | | | | | | | | The warning message to suggest "Consider running git-status" from "git-diff" that we experimented with during the 1.5.3 cycle turns out to be a bad idea. It robbed cache-dirty information from people who valued it, while still asking users to run "update-index --refresh". It was hoped that the new behaviour would at least have some educational value, but not showing the cache-dirty paths like before meant that the user would not even know easily which paths were cache-dirty, and it made the need to refresh the index look like even more unnecessary chore. This commit reinstates the traditional behaviour, but with a twist. By default, the empty "diff --git" output is totally squelched out from "git diff" output. At the end of the command, it automatically runs "update-index --refresh" as needed, without even bothering the user. In other words, people who do not care about the cache-dirtyness do not even have to see the warning. The traditional behaviour to see the stat-dirty output and to bypassing the overhead of content comparison can be specified by setting the configuration variable diff.autorefreshindex to false. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-diff: squelch "empty" diffsJunio C Hamano2007-08-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | After starting to edit a working tree file but later when your edit ends up identical to the original (this can also happen when you ran a wholesale regexp replace with something like "perl -i" that does not actually modify many of the paths), "git diff" between the index and the working tree outputs many "empty" diffs that show "diff --git" headers and nothing else, because these paths are stat-dirty. While it was a way to warn the user that the earlier action of the user made the index ineffective as an optimization mechanism, it was felt too loud for the purpose of warning even to experienced users, and also resulted in confusing people new to git. This replaces the "empty" diffs with a single warning message at the end. Having many such paths hurts performance, and you can run "git-update-index --refresh" to update the lstat(2) information recorded in the index in such a case. "git-status" does so as a side effect, and that is more familiar to the end-user, so we recommend it to them. The change affects only "git diff" that outputs patch text, because that is where the annoyance of too many "empty" diff is most strongly felt, and because the warning message can be safely ignored by downstream tools without getting mistaken as part of the patch. For the low-level "git diff-files" and "git diff-index", the traditional behaviour is retained. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* diff: don't run pager if user asked for a diff style exit codeRené Scharfe2007-08-13
| | | | | | | | | | | | | As Wincent Colaiuta found out, it's a bit unexpected for git diff to start a pager even when the --quiet option is specified. The problem is that the pager hides the return code -- which is the only output we're interested in in this case. Push pager setup down into builtin-diff.c and don't start the pager if --exit-code or --quiet (which implies --exit-code) was specified. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-diff: turn on recursion by defaultJeff King2007-07-29
| | | | | | | | | | | | | | The tree recursion behavior of git-diff may appear inconsistent to the user because it depends on the format of the patch as well as whether one is diffing between trees or against the index. Since git-diff is a porcelain wrapper for low-level diff commands, it makes sense for its behavior to be consistent no matter what is being diffed. This patch turns on recursion in all cases. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Diff between two blobs should take mode changes into account now.Junio C Hamano2007-04-24
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* use mode of the tree in git-diff, if <tree>:<file> syntax is usedMartin Koegler2007-04-24
| | | | | Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Support 'diff=pgm' attributeJunio C Hamano2007-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | This enhances the attributes mechanism so that external programs meant for existing GIT_EXTERNAL_DIFF interface can be specifed per path. To configure such a custom diff driver, first define a custom diff driver in the configuration: [diff "my-c-diff"] command = <<your command string comes here>> Then mark the paths that you want to use this custom driver using the attribute mechanism. *.c diff=my-c-diff The intent of this separation is that the attribute mechanism is used for specifying the type of the contents, while the configuration mechanism is used to define what needs to be done to that type of the contents, which would be specific to both platform and personal taste. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Allow git-diff exit with codes similar to diff(1)Alex Riesen2007-03-14
| | | | | | | | | This introduces a new command-line option: --exit-code. The diff programs will return 1 for differences, return 0 for equality, and something else for errors. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* diff: make more cases implicit --no-indexJohannes Schindelin2007-02-28
| | | | | | | | | When specifying an absolute path, or a relative path pointing outside the working tree, do not fail, but roll your own diffopt parsing, and execute a --no-index diff. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'master' into js/diff-niJunio C Hamano2007-02-26
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (201 commits) Documentation: link in 1.5.0.2 material to the top documentation page. Documentation: document remote.<name>.tagopt GIT 1.5.0.2 git-remote: support remotes with a dot in the name Documentation: describe "-f/-t/-m" options to "git-remote add" diff --cc: fix display of symlink conflicts during a merge. merge-recursive: fix longstanding bug in merging symlinks merge-index: fix longstanding bug in merging symlinks diff --cached: give more sensible error message when HEAD is yet to be created. Update tests to use test-chmtime Add test-chmtime: a utility to change mtime on files Add Release Notes to prepare for 1.5.0.2 Allow arbitrary number of arguments to git-pack-objects rerere: do not deal with symlinks. rerere: do not skip two conflicted paths next to each other. Don't modify CREDITS-FILE if it hasn't changed. diff-patch: Avoid emitting double-slashes in textual patch. Reword git-am 3-way fallback failure message. Limit filename for format-patch core.legacyheaders: Use the description used in RelNotes-1.5.0 ...
| * diff --cached: give more sensible error message when HEAD is yet to be created.Junio C Hamano2007-02-25
| | | | | | | | | | | | | | | | It is not like the user said 'diff --cached HEAD', so complaining about HEAD not being a valid commit, while technically might be correct, is not very helpful. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * git-diff: fix combined diffJohannes Schindelin2007-02-22
| | | | | | | | | | | | | | | | | | | | The code forgets that typecast binds tighter than addition, in other words: (cast *)array + i === ((cast *)array) + i Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Evil Merge branch 'jc/status' (early part) into js/diff-niJunio C Hamano2007-02-24
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'jc/status' (early part): run_diff_{files,index}(): update calling convention. update-index: do not die too early in a read-only repository. git-status: do not be totally useless in a read-only repository. This is to resolve semantic conflict (which is not textual) that changes the calling convention of run_diff_files() early.
| * | run_diff_{files,index}(): update calling convention.Junio C Hamano2007-02-22
| |/ | | | | | | | | | | | | They used to open and read index themselves, but they now expect their callers to do so. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Teach git-diff-files the new option `--no-index`Johannes Schindelin2007-02-22
|/ | | | | | | | | | | | | | | | | | | | | | With this flag and given two paths, git-diff-files behaves as a GNU diff lookalike (plus the git goodies like --check, colour, etc.). This flag is also available in git-diff. It also works outside of a git repository. In addition, if git-diff{,-files} is called without revision or stage parameter, and with exactly two paths at least one of which is not tracked, the default is --no-index. So, you can now say git diff /etc/inittab /etc/fstab and it actually works! This also unifies the duplicated argument parsing between cmd_diff_files() and builtin_diff_files(). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Revert "git-diff: Introduce --index and deprecate --cached."Junio C Hamano2006-12-13
| | | | | | | | | | | | | This reverts commit 4c81c213a479e4aae0653a56ad6e8db5c31f019c. Although --cached and --index are confusing wording, the use of word --cached for git-diff is consistent with git-apply. It means "work with index without looking at the working tree". We should probably come up with better wording for --cached, if somebody wants to deprecate it. But making --index and --cached synonyms for diff while leaving them mean different things for apply is no good.
* git-diff: Introduce --index and deprecate --cached.Andreas Ericsson2006-12-01
| | | | | | | | | 'git diff --cached' still works, but its use is discouraged in the documentation. 'git diff --index' does the same thing and is consistent with how 'git apply --index' works. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce2006-08-23
| | | | | | | | | | | | | | | | | | | | | | | This abstracts away the size of the hash values when copying them from memory location to memory location, much as the introduction of hashcmp abstracted away hash value comparsion. A few call sites were using char* rather than unsigned char* so I added the cast rather than open hashcpy to be void*. This is a reasonable tradeoff as most call sites already use unsigned char* and the existing hashcmp is also declared to be unsigned char*. [jc: Splitted the patch to "master" part, to be followed by a patch for merge-recursive.c which is not in "master" yet. Fixed the cast in the latter hunk to combine-diff.c which was wrong in the original. Also converted ones left-over in combine-diff.c, diff-lib.c and upload-pack.c ] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.David Rientjes2006-08-17
| | | | | | | | | | | | | Introduces global inline: hashcmp(const unsigned char *sha1, const unsigned char *sha2) Uses memcmp for comparison and returns the result based on the length of the hash name (a future runtime decision). Acked-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* make inline is_null_sha1 globalDavid Rientjes2006-08-15
| | | | | | | | | | Replace sha1 comparisons to null_sha1 with a global inline (which previously an unused static inline in builtin-apply.c) [jc: with a fix from Jonas Fonseca.] Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'th/diff-extra'Junio C Hamano2006-08-12
|\
| * Remove awkward compatibility wartsTimo Hirvonen2006-07-01
| | | | | | | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Fix git-diff A...BJunio C Hamano2006-08-10
| | | | | | | | | | | | | | | | Commit 9919f41 meant to make git-diff A...B to (usually) mean "git-diff `git-merge-base A B` B", but it got the parameters wrong and ended up showing "git-diff `git-merge-base A B` A" by mistake. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | check return value from diff_setup_done()Junio C Hamano2006-08-09
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Fixup command names in some usage strings.Ramsay Allan Jones2006-08-03
| | | | | | | | | | | | | | | | | | Most usage strings, such as for command xxx, start with "git-xxx". This updates the rebels to conform to the general pattern. (The git wrapper is an exception to this, of course ...) Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Show both blob names from "git diff blob1 blob2"Junio C Hamano2006-08-03
| | | | | | | | | | | | | | | | | | | | Earlier we deliberately showed only blob1's name because showing both names labeled the output as a renaming patch. Now the output routine (namely, diff.c::resolve_rename_copy()) is taught not to use pathname comparison to tell if a filepair is a rename, we can safely do this change. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Fix "git diff blob1 blob2" showing the diff in reverse.Junio C Hamano2006-08-03
| | | | | | | | | | | | | | This was introduced by mistake when revision.c::add_pending_object() was modified to use object-array instead of object-list. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Call setup_git_directory() much earlierLinus Torvalds2006-07-29
| | | | | | | | | | | | | | | | | | This changes the calling convention of built-in commands and passes the "prefix" (i.e. pathname of $PWD relative to the project root level) down to them. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Call setup_git_directory() earlyLinus Torvalds2006-07-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Any git command that expects to work in a subdirectory of a project, and that reads the git config files (which is just about all of them) needs to make sure that it does the "setup_git_directory()" call before it tries to read the config file. This means, among other things, that we need to move the call out of "init_revisions()", and into the caller. This does the mostly trivial conversion to do that. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'jc/diff'Junio C Hamano2006-07-28
|\ \ | | | | | | | | | | | | * jc/diff: git-diff A...B to (usually) mean "git-diff `git-merge-base A B` B"
| * | git-diff A...B to (usually) mean "git-diff `git-merge-base A B` B"Junio C Hamano2006-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tweaks the argument parser of "git diff" to allow "git-diff A...B" to show diffs leading to B since their merge-base, when there is only one sensible merge base between A and B. Currently nonsense cases are thrown at combined-diff to produce nonsense results, which would eventually need to be fixed. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | | log and diff family: honor config even from subdirectoriesJunio C Hamano2006-07-27
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There currently is an unfortunate circular dependency between what init_revisions (the command line revision specification parser) does and setting up the log and diff options. The function uses setup_git_directory() to find the root of the project relative to the current directory and calls diff_setup() to prepare diff generation. However, some of the things that diff_setup() does needs to depend on the configuration variable, which needs to be read after setup_git_directory() is called. This patch is a low impact workaround. It first lets init_revisions() to run and do its thing, then uses git_config() and diff_setup() after it returns, so that configuration variables that affects the diff operation can be used from subdirectories. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Remove TYPE_* constant macros and use object_type enums consistently.Linus Torvalds2006-07-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the type-enumeration constants introduced to reduce the memory footprint of "struct object" to match the type bits already used in the packfile format, by removing the former (i.e. TYPE_* constant macros) and using the latter (i.e. enum object_type) throughout the code for consistency. Eventually we can stop passing around the "type strings" entirely, and this will help - no confusion about two different integer enumeration. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Fix more typos, primarily in the codePavel Roskin2006-07-10
| | | | | | | | | | | | | | | | | | The only visible change is that git-blame doesn't understand "--compability" anymore, but it does accept "--compatibility" instead, which is already documented. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | diff: do not use configuration magic at the core-levelJunio C Hamano2006-07-08
|/ | | | | | | | | | | | | | | | | | | | The Porcelainish has become so much usable as the UI that there is not much reason people should be using the core programs by hand anymore. At this point we are better off making the behaviour of the core programs predictable by keeping them unaffected by the configuration variables. Otherwise they will become very hard to use as reliable building blocks. For example, "git-commit -a" internally uses git-diff-files to figure out the set of paths that need to be updated in the index, and we should never allow diff.renames that happens to be in the configuration to interfere (or slow down the process). The UI level configuration such as showing renamed diff and coloring are still honored by the Porcelainish ("git log" family and "git diff"), but not by the core anymore. Signed-off-by: Junio C Hamano <junkio@cox.net>
* builtin-diff: turn recursive on when defaulting to --patch format.Junio C Hamano2006-07-01
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Set default diff output format after parsing command lineTimo Hirvonen2006-06-26
| | | | | | | | | Initialize output_format to 0 instead of DIFF_FORMAT_RAW so that we can see later if any command line options changed it. Default value is set only if output format was not specified. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Make --raw option available for all diff commandsTimo Hirvonen2006-06-26
| | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge with_raw, with_stat and summary variables to output_formatTimo Hirvonen2006-06-26
| | | | | | | DIFF_FORMAT_* are now bit-flags instead of enumerated values. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add "named object array" conceptLinus Torvalds2006-06-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've had this notion of a "object_list" for a long time, which eventually grew a "name" member because some users (notably git-rev-list) wanted to name each object as it is generated. That object_list is great for some things, but it isn't all that wonderful for others, and the "name" member is generally not used by everybody. This patch splits the users of the object_list array up into two: the traditional list users, who want the list-like format, and who don't actually use or want the name. And another class of users that really used the list as an extensible array, and generally wanted to name the objects. The patch is fairly straightforward, but it's also biggish. Most of it really just cleans things up: switching the revision parsing and listing over to the array makes things like the builtin-diff usage much simpler (we now see exactly how many members the array has, and we don't get the objects reversed from the order they were on the command line). One of the main reasons for doing this at all is that the malloc overhead of the simple object list was actually pretty high, and the array is just a lot denser. So this patch brings down memory usage by git-rev-list by just under 3% (on top of all the other memory use optimizations) on the mozilla archive. It does add more lines than it removes, and more importantly, it adds a whole new infrastructure for maintaining lists of objects, but on the other hand, the new dynamic array code is pretty obvious. The change to builtin-diff-tree.c shows a fairly good example of why an array interface is sometimes more natural, and just much simpler for everybody. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Shrink "struct object" a bitLinus Torvalds2006-06-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shrinks "struct object" by a small amount, by getting rid of the "struct type *" pointer and replacing it with a 3-bit bitfield instead. In addition, we merge the bitfields and the "flags" field, which incidentally should also remove a useless 4-byte padding from the object when in 64-bit mode. Now, our "struct object" is still too damn large, but it's now less obviously bloated, and of the remaining fields, only the "util" (which is not used by most things) is clearly something that should be eventually discarded. This shrinks the "git-rev-list --all" memory use by about 2.5% on the kernel archive (and, perhaps more importantly, on the larger mozilla archive). That may not sound like much, but I suspect it's more on a 64-bit platform. There are other remaining inefficiencies (the parent lists, for example, probably have horrible malloc overhead), but this was pretty obvious. Most of the patch is just changing the comparison of the "type" pointer from one of the constant string pointers to the appropriate new TYPE_xxx small integer constant. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'master' into js/fmt-patchJunio C Hamano2006-05-21
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (119 commits) diff family: add --check option Document that "git add" only adds non-ignored files. Add a conversion tool to migrate remote information into the config fetch, pull: ask config for remote information Fix build procedure for builtin-init-db read-tree -m -u: do not overwrite or remove untracked working tree files. apply --cached: do not check newly added file in the working tree Implement a --dry-run option to git-quiltimport Implement git-quiltimport Revert "builtin-grep: workaround for non GNU grep." builtin-grep: workaround for non GNU grep. builtin-grep: workaround for non GNU grep. git-am: use apply --cached apply --cached: apply a patch without using working tree. apply --numstat: show new name, not old name. Documentation/Makefile: create tarballs for the man pages and html files Allow pickaxe and diff-filter options to be used by git log. Libify the index refresh logic Builtin git-init-db Remove unnecessary local in get_ref_sha1. ...
| * builtin-diff: do not say files are renamed when blob and file are givenJunio C Hamano2006-05-18
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
| * builtin-diff: fix comparison between two blobs.Junio C Hamano2006-05-15
| | | | | | | | | | | | | | The code forgot that setup_revisions() leaves parsed object names in reverse in the list. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Sparse fix for builtin-diffPeter Hagervall2006-05-07
| | | | | | | | | | | | | | | | | | You gotta love sparse: builtin-diff.c:88:4: error: Just how const do you want this type to be? Signed-off-by: Peter Hagervall <hager@cs.umu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | fmt-patch: understand old <his> notationJohannes Schindelin2006-05-06
|/ | | | | | | | | When calling "git fmt-patch HEAD~5", you now get the same as if you would have said "git fmt-patch HEAD~5..". This makes it easier for my fingers which are so used to the old syntax. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/diff'Junio C Hamano2006-05-03
| | | | | | | | * jc/diff: builtin-diff: call it "git-diff", really. builtin-diff.c: die() formatting type fix. built-in diff: assorted updates. built-in diff.
* builtin-diff.c: die() formatting type fix.Junio C Hamano2006-04-30
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>