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>
Junio C Hamano committed
Nov 8, 2007 at 16:24 UTC
fbbdbfc3ccff209136c9f94fed8321e5d3d0ca85
1 file changed
+5
-9
builtin-diff.c
+5
-9
@@ -200,15 +200,11 @@ static void refresh_index_quietly(void)
200
discard_cache();
201
read_cache();
202
refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
203
- if (active_cache_changed) {
204
- if (write_cache(fd, active_cache, active_nr) ||
205
- close(fd) ||
206
- commit_locked_index(lock_file))
207
- ; /*
208
- * silently ignore it -- we haven't mucked
209
- * with the real index.
210
- */
211
- }
203
+
204
+ if (active_cache_changed &&
205
+ !write_cache(fd, active_cache, active_nr) && !close(fd))
206
+ commit_locked_index(lock_file);
207
+
208
rollback_lock_file(lock_file);
209
}
210