rerere: error out on autoupdate failure

We have been silently tolerating errors by returning early with an error that the caller ignores since rerere.autoupdate was introduced in v1.6.0-rc0~120^2 (2008-06-22). So on error (for example if the index is already locked), rerere can return success silently without updating the index or with only some items in the index updated. Better to treat such failures as a fatal error so the operator can figure out what is wrong and fix it. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Dec 2, 2014 at 20:20 UTC 89ea90351dd32fbe384d0cf844640a9c55606f3b
1 file changed +6 -10
rerere.c
+6 -10
@@ -476,27 +476,23 @@ out:
476
477 static struct lock_file index_lock;
478
479 -static int update_paths(struct string_list *update)
479 +static void update_paths(struct string_list *update)
480 {
481 int i;
482 - int fd = hold_locked_index(&index_lock, 0);
483 - int status = 0;
482
485 - if (fd < 0)
486 - return -1;
483 + hold_locked_index(&index_lock, 1);
484
485 for (i = 0; i < update->nr; i++) {
486 struct string_list_item *item = &update->items[i];
490 - if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS))
491 - status = -1;
487 + if (add_file_to_cache(item->string, 0))
488 + exit(128);
489 }
490
494 - if (!status && active_cache_changed) {
491 + if (active_cache_changed) {
492 if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
493 die("Unable to write new index file");
497 - } else if (fd >= 0)
494 + } else
495 rollback_lock_file(&index_lock);
499 - return status;
496 }
497
498 static int do_plain_rerere(struct string_list *rr, int fd)