]> git.ipfire.org Git - thirdparty/git.git/commit - builtin-commit.c
Generalize and libify index_is_dirty() to index_differs_from(...)
authorStephan Beyer <s-beyer@gmx.net>
Tue, 10 Feb 2009 14:30:35 +0000 (15:30 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Feb 2009 06:25:39 +0000 (22:25 -0800)
commit75f3ff2eeaba820b37016f464b6d1078cb6260e2
tree0401f9c7b3904977dc50afc8081e780405113bf1
parentfcb6c0760d14cd8ee284a0acf9f7424878cba5a0
Generalize and libify index_is_dirty() to index_differs_from(...)

index_is_dirty() in builtin-revert.c checks if the index is dirty.
This patch generalizes this function to check if the index differs
from a revision, i.e. the former index_is_dirty() behavior can now be
achieved by index_differs_from("HEAD", 0).

The second argument "diff_flags" allows to set further diff option
flags like DIFF_OPT_IGNORE_SUBMODULES. See DIFF_OPT_* macros in diff.h
for a list.

index_differs_from() seems to be useful for more than builtin-revert.c,
so it is moved into diff-lib.c and also used in builtin-commit.c.

Yet to mention:

 - "rev.abbrev = 0;" can be safely removed.
   This has no impact on performance or functioning of neither
   setup_revisions() nor run_diff_index().

 - rev.pending.objects is free()d because this fixes a leak.
   (Also see 295dd2ad "Fix memory leak in traverse_commit_list")

Mentored-by: Daniel Barkalow <barkalow@iabervon.org>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c
builtin-revert.c
diff-lib.c
diff.h