Skip to content

Commit 89ea903

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7fa1365 commit 89ea903

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

rerere.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,27 +476,23 @@ static int merge(const char *name, const char *path)
476476

477477
static struct lock_file index_lock;
478478

479-
static int update_paths(struct string_list *update)
479+
static void update_paths(struct string_list *update)
480480
{
481481
int i;
482-
int fd = hold_locked_index(&index_lock, 0);
483-
int status = 0;
484482

485-
if (fd < 0)
486-
return -1;
483+
hold_locked_index(&index_lock, 1);
487484

488485
for (i = 0; i < update->nr; i++) {
489486
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);
492489
}
493490

494-
if (!status && active_cache_changed) {
491+
if (active_cache_changed) {
495492
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
496493
die("Unable to write new index file");
497-
} else if (fd >= 0)
494+
} else
498495
rollback_lock_file(&index_lock);
499-
return status;
500496
}
501497

502498
static int do_plain_rerere(struct string_list *rr, int fd)

0 commit comments

Comments
 (0)