summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f2e94c)
raw | patch | inline | side by side (parent: 4f2e94c)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 9 Nov 2007 00:24:00 +0000 (16:24 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 9 Nov 2007 00:26:23 +0000 (16:26 -0800) |
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>
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>
builtin-diff.c | patch | blob | history |
diff --git a/builtin-diff.c b/builtin-diff.c
index f77352b40decdc4cf8d2db29102703cb1193b49c..f557d21929fe3df018f30e68c7943ead7f8eb4a1 100644 (file)
--- a/builtin-diff.c
+++ b/builtin-diff.c
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);
}