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

[PATCH v2 1/3] refs.c: refer to "object ID", not "sha1", in error messages

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
May 10, 2018, 19:29 UTC
Message-ID
<076c6847d4f533103a8be5d9b6dd4dc3dfb8c83a.1525979881.git.martin.agren@gmail.com>
In-Reply-To
<cover.1525979881.git.martin.agren@gmail.com>

We have two error messages that complain about the "sha1". Because we are about to touch one of these sites and add some tests, let's first modernize the messages to say "object ID" instead.

While at it, make the second one use `error()` instead of `warning()`. After printing the message, we do not continue, but actually drop the lock and return -1 without deleting the pseudoref.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
We could make error-reporting more consistent in general in this file,
but I'd rather not lose track of the original goal of this series.
 refs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index 64aadd14c9..7820a52c4f 100644
--- a/refs.c
+++ b/refs.c
@@ -684,7 +684,8 @@ static int write_pseudoref(const char *pseudoref, const struct object_id *oid,
 		if (read_ref(pseudoref, &actual_old_oid))
 			die("could not read ref '%s'", pseudoref);
 		if (oidcmp(&actual_old_oid, old_oid)) {
-			strbuf_addf(err, "unexpected sha1 when writing '%s'", pseudoref);
+			strbuf_addf(err, "unexpected object ID when writing '%s'",
+				    pseudoref);
 			rollback_lock_file(&lock);
 			goto done;
 		}
@@ -722,7 +723,8 @@ static int delete_pseudoref(const char *pseudoref, const struct object_id *old_o
 		if (read_ref(pseudoref, &actual_old_oid))
 			die("could not read ref '%s'", pseudoref);
 		if (oidcmp(&actual_old_oid, old_oid)) {
-			warning("Unexpected sha1 when deleting %s", pseudoref);
+			error("unexpected object ID when deleting '%s'",
+			      pseudoref);
 			rollback_lock_file(&lock);
 			return -1;
 		}
-- 
2.17.0
Previous: Martin ÅgrenNext: Martin Ågren
Message 9 of 11 in “git update-ref fails to create reference. (bug)”
  1. Rafael AscensãoMay 4, 2018
  2. Martin ÅgrenMay 4, 2018
  3. Rafael AscensãoMay 5, 2018
  4. refs: handle null-oid for pseudorefsMartin Ågren, May 6, 2018
  5. David TurnerMay 6, 2018
  6. Michael HaggertyMay 7, 2018
  7. Martin ÅgrenMay 7, 2018
  8. 0/3 refs: handle zero oid for pseudorefsMartin Ågren, May 10, 2018
  9. 1/3 refs.c: refer to "object ID", not "sha1", in error messagesMartin Ågren, May 10, 2018
  10. 2/3 t1400: add tests around adding/deleting pseudorefsMartin Ågren, May 10, 2018
  11. 3/3 refs: handle zero oid for pseudorefsMartin Ågren, May 10, 2018

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.