summaryrefslogtreecommitdiff
path: root/builtin-diff-files.c
AgeCommit message (Collapse)Author
2010-02-22Move 'builtin-*' into a 'builtin/' subdirectoryLinus Torvalds
This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil<tab> Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor<tab> builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil<tab> [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh<tab> [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor<tab> [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-15Add cache preload facilityLinus Torvalds
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 <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-18diff/diff-files: do not use --cc too aggressivelyJunio C Hamano
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 <gitster@pobox.com>
2008-07-13Make usage strings dash-lessStephan Beyer
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 <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-27Merge branch 'jc/diff-no-no-index'Junio C Hamano
* jc/diff-no-no-index: git diff --no-index: default to page like other diff frontends git-diff: allow --no-index semantics a bit more "git diff": do not ignore index without --no-index diff-files: do not play --no-index games tests: do not use implicit "git diff --no-index"
2008-05-24diff-files: do not play --no-index gamesJunio C Hamano
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 <gitster@pobox.com>
2008-05-14Provide git_config with a callback-data parameterJohannes Schindelin
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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-26Always set *nongit_ok in setup_git_directory_gently()SZEDER Gábor
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 <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05add a "basic" diff config callbackJeff King
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-14diff --check: minor fixupsJunio C Hamano
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 <gitster@pobox.com>
2007-12-14"diff --check" should affect exit statusWincent Colaiuta
"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 <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-12Make the diff_options bitfields be an unsigned with explicit masks.Pierre Habouzit
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>
2007-04-27Removing -n option from git-diff-files documentationAndrew Ruder
-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 <andy@aeruder.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-14Allow git-diff exit with codes similar to diff(1)Alex Riesen
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>
2007-03-01diff: make more cases implicit --no-indexJohannes Schindelin
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>
2007-02-23Teach git-diff-files the new option `--no-index`Johannes Schindelin
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>
2006-08-13Merge branch 'th/diff-extra'Junio C Hamano
2006-07-29Call setup_git_directory() much earlierLinus Torvalds
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>
2006-07-29Call setup_git_directory() earlyLinus Torvalds
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>
2006-07-28log and diff family: honor config even from subdirectoriesJunio C Hamano
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>
2006-07-08diff: do not use configuration magic at the core-levelJunio C Hamano
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>
2006-07-02Remove awkward compatibility wartsTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Set default diff output format after parsing command lineTimo Hirvonen
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>
2006-06-20Add "named object array" conceptLinus Torvalds
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>
2006-05-23Builtin git-diff-files, git-diff-index, git-diff-stages, and git-diff-tree.Peter Eriksen
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>