Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2023-11-02 11:46:41 +0300
committerJunio C Hamano <gitster@pobox.com>2023-11-03 02:37:06 +0300
commit9ddd5b883b0221d80392a914eb621ea680476e75 (patch)
tree75ed697e1f2172ccf37ab0b36689c17a7ad6daf5 /t/helper
parentd5dbad0c767707eb690e68778f0a75203d18b72a (diff)
t: allow skipping expected object ID in `ref-store update-ref`
We require the caller to pass both the old and new expected object ID to our `test-tool ref-store update-ref` helper. When trying to update a symbolic reference though it's impossible to specify the expected object ID, which means that the test would instead have to force-update the reference. This is currently impossible though. Update the helper to optionally skip verification of the old object ID in case the test passes in an empty old object ID as input. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-ref-store.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 48552e6a9e..702ec1f128 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -298,16 +298,19 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv)
const char *new_sha1_buf = notnull(*argv++, "new-sha1");
const char *old_sha1_buf = notnull(*argv++, "old-sha1");
unsigned int flags = arg_flags(*argv++, "flags", transaction_flags);
- struct object_id old_oid;
+ struct object_id old_oid, *old_oid_ptr = NULL;
struct object_id new_oid;
- if (get_oid_hex(old_sha1_buf, &old_oid))
- die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name);
+ if (*old_sha1_buf) {
+ if (get_oid_hex(old_sha1_buf, &old_oid))
+ die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name);
+ old_oid_ptr = &old_oid;
+ }
if (get_oid_hex(new_sha1_buf, &new_oid))
die("cannot parse %s as %s", new_sha1_buf, the_hash_algo->name);
return refs_update_ref(refs, msg, refname,
- &new_oid, &old_oid,
+ &new_oid, old_oid_ptr,
flags, UPDATE_REFS_DIE_ON_ERR);
}