git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC] rerere: error out on autoupdate failure

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 3, 2014, 04:20 UTC
Message-ID
<20141203042049.GI6527@google.com>

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>
---
I ran into this while auditing hold_locked_index callers.  Tests
still pass after this change.  Sensible?
 rerere.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/rerere.c b/rerere.c
index 1b0555f..195f663 100644
--- a/rerere.c
+++ b/rerere.c
@@ -477,27 +477,23 @@ out:
 
 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 fd = hold_locked_index(&index_lock, 0);
-	int status = 0;
 
-	if (fd < 0)
-		return -1;
+	hold_locked_index(&index_lock, 1);
 
 	for (i = 0; i < update->nr; i++) {
 		struct string_list_item *item = &update->items[i];
 		if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS))
-			status = -1;
+			die("staging updated %s failed", item->string);
 	}
 
-	if (!status && active_cache_changed) {
+	if (active_cache_changed) {
 		if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
 			die("Unable to write new index file");
-	} else if (fd >= 0)
+	} else
 		rollback_lock_file(&index_lock);
-	return status;
 }
 
 static int do_plain_rerere(struct string_list *rr, int fd)
Next: Junio C Hamano
Message 1 of 4 in “rerere: error out on autoupdate failure”
  1. rerere: error out on autoupdate failureJonathan Nieder, Dec 3, 2014
  2. Junio C HamanoDec 3, 2014
  3. Junio C HamanoDec 3, 2014
  4. rerere: error out on autoupdate failureJonathan Nieder, Dec 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.