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>
This commit is contained in:
parent
7fa1365c54
commit
89ea90351d
16
rerere.c
16
rerere.c
@ -476,27 +476,23 @@ out:
|
|||||||
|
|
||||||
static struct lock_file index_lock;
|
static struct lock_file index_lock;
|
||||||
|
|
||||||
static int update_paths(struct string_list *update)
|
static void update_paths(struct string_list *update)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int fd = hold_locked_index(&index_lock, 0);
|
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
if (fd < 0)
|
hold_locked_index(&index_lock, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < update->nr; i++) {
|
for (i = 0; i < update->nr; i++) {
|
||||||
struct string_list_item *item = &update->items[i];
|
struct string_list_item *item = &update->items[i];
|
||||||
if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS))
|
if (add_file_to_cache(item->string, 0))
|
||||||
status = -1;
|
exit(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status && active_cache_changed) {
|
if (active_cache_changed) {
|
||||||
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
|
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
|
||||||
die("Unable to write new index file");
|
die("Unable to write new index file");
|
||||||
} else if (fd >= 0)
|
} else
|
||||||
rollback_lock_file(&index_lock);
|
rollback_lock_file(&index_lock);
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_plain_rerere(struct string_list *rr, int fd)
|
static int do_plain_rerere(struct string_list *rr, int fd)
|
||||||
|
Loading…
Reference in New Issue
Block a user