diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-08 16:24:00 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-08 16:26:23 -0800 |
commit | fbbdbfc3ccff209136c9f94fed8321e5d3d0ca85 (patch) | |
tree | c3fd8702e36c87582b938b08c4d0f583fcc0ced9 /builtin-diff.c | |
parent | 4f2e94c0f7685f9c58e67b0651147684efb0f57e (diff) | |
download | git-fbbdbfc3ccff209136c9f94fed8321e5d3d0ca85.tar.gz |
refresh_index_quietly(): express "optional" nature of index writing better
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>
Diffstat (limited to 'builtin-diff.c')
-rw-r--r-- | builtin-diff.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/builtin-diff.c b/builtin-diff.c index f77352b40d..f557d21929 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -200,15 +200,11 @@ static void refresh_index_quietly(void) discard_cache(); read_cache(); refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); - if (active_cache_changed) { - if (write_cache(fd, active_cache, active_nr) || - close(fd) || - commit_locked_index(lock_file)) - ; /* - * silently ignore it -- we haven't mucked - * with the real index. - */ - } + + if (active_cache_changed && + !write_cache(fd, active_cache, active_nr) && !close(fd)) + commit_locked_index(lock_file); + rollback_lock_file(lock_file); } |