commit 1df1761f7094815d15b11a908b2132ca58169fea from: Stefan Sperling date: Fri Jun 16 08:58:13 2023 UTC make gotd show relevant commit hashes in error message if ref-updates collide commit - f8780fee7a5de8db320833efc4a30aa1ad3814e2 commit + 1df1761f7094815d15b11a908b2132ca58169fea blob - 8f6b8985f8c929a7a85fd139238d5a1481b1fe84 blob + 2818e0cdca9ab6d00ae35b461e2289cb82f51255 --- gotd/session.c +++ gotd/session.c @@ -410,6 +410,8 @@ update_ref(int *shut, struct gotd_session_client *clie char *refname = NULL; size_t datalen; int locked = 0; + char hex1[SHA1_DIGEST_STRING_LENGTH]; + char hex2[SHA1_DIGEST_STRING_LENGTH]; log_debug("update-ref from uid %d", client->euid); @@ -451,10 +453,17 @@ update_ref(int *shut, struct gotd_session_client *clie if (err) goto done; } else { + err = got_ref_resolve(&id, repo, ref); + if (err) + goto done; + got_object_id_hex(&new_id, hex1, sizeof(hex1)); + got_object_id_hex(id, hex2, sizeof(hex2)); err = got_error_fmt(GOT_ERR_REF_BUSY, - "%s has been created by someone else " - "while transaction was in progress", - got_ref_get_name(ref)); + "Addition %s: %s failed; %s: %s has been " + "created by someone else while transaction " + "was in progress", + got_ref_get_name(ref), hex1, + got_ref_get_name(ref), hex2); goto done; } } else if (iref.delete_ref) { @@ -468,10 +477,14 @@ update_ref(int *shut, struct gotd_session_client *clie goto done; if (got_object_id_cmp(id, &old_id) != 0) { + got_object_id_hex(&old_id, hex1, sizeof(hex1)); + got_object_id_hex(id, hex2, sizeof(hex2)); err = got_error_fmt(GOT_ERR_REF_BUSY, - "%s has been modified by someone else " - "while transaction was in progress", - got_ref_get_name(ref)); + "Deletion %s: %s failed; %s: %s has been " + "created by someone else while transaction " + "was in progress", + got_ref_get_name(ref), hex1, + got_ref_get_name(ref), hex2); goto done; } @@ -492,10 +505,14 @@ update_ref(int *shut, struct gotd_session_client *clie goto done; if (got_object_id_cmp(id, &old_id) != 0) { + got_object_id_hex(&old_id, hex1, sizeof(hex1)); + got_object_id_hex(id, hex2, sizeof(hex2)); err = got_error_fmt(GOT_ERR_REF_BUSY, - "%s has been modified by someone else " - "while transaction was in progress", - got_ref_get_name(ref)); + "Update %s: %s failed; %s: %s has been " + "created by someone else while transaction " + "was in progress", + got_ref_get_name(ref), hex1, + got_ref_get_name(ref), hex2); goto done; }