From 4bf630b6baf342fa929a8f7e4e6643197b74216f Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 31 Oct 2013 14:36:52 -0700 Subject: Make diff and status perform soft index reload This changes `git_index_read` to have two modes - a hard index reload that always resets the index to match the on-disk data (which was the old behavior) and a soft index reload that uses the timestamp / file size information and only replaces the index data if the file on disk has been modified. This then updates the git_status code to do a soft reload unless the new GIT_STATUS_OPT_NO_REFRESH flag is passed in. This also changes the behavior of the git_diff functions that use the index so that when an index is not explicitly passed in (i.e. when the functions call git_repository_index for you), they will also do a soft reload for you. This intentionally breaks the file signature of git_index_read because there has been some confusion about the behavior previously and it seems like all existing uses of the API should probably be examined to select the desired behavior. --- tests-clar/diff/diff_helpers.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index 466d0ef54..33bb561f6 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -221,11 +221,15 @@ static int diff_print_cb( const git_diff_line *line, void *payload) { - GIT_UNUSED(payload); - GIT_UNUSED(delta); - GIT_UNUSED(hunk); - fprintf((FILE *)payload, "%c%.*s", - line->origin, (int)line->content_len, line->content); + FILE *fp = payload; + + GIT_UNUSED(delta); GIT_UNUSED(hunk); + + if (line->origin == GIT_DIFF_LINE_CONTEXT || + line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION) + fputc(line->origin, fp); + fwrite(line->content, 1, line->content_len, fp); return 0; } -- cgit v1.2.1