aboutsummaryrefslogtreecommitdiffstats
path: root/refs/refs-internal.h
diff options
context:
space:
mode:
authorKarthik Nayak <karthik.188@gmail.com>2024-06-07 15:32:58 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-07 10:25:44 -0700
commitaba381c09034c2c31f3476e8cc9a46ea6889f1d5 (patch)
treee4b1cf90e57660ce1971524576f435c68a0bc8fa /refs/refs-internal.h
parentMerge branch 'kn/ref-transaction-symref' into kn/update-ref-symref (diff)
downloadgit-aba381c09034c2c31f3476e8cc9a46ea6889f1d5.tar.gz
git-aba381c09034c2c31f3476e8cc9a46ea6889f1d5.zip
refs: create and use `ref_update_expects_existing_old_ref()`
The files and reftable backend, need to check if a ref must exist, so that the required validation can be done. A ref must exist only when the `old_oid` value of the update has been explicitly set and it is not the `null_oid` value. Since we also support symrefs now, we need to ensure that even when `old_target` is set a ref must exist. While this was missed when we added symref support in transactions, there are no active users of this path. As we introduce the 'symref-verify' command in the upcoming commits, it is important to fix this. So let's export this to a function called `ref_update_expects_existing_old_ref()` and expose it internally via 'refs-internal.h'. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/refs-internal.h')
-rw-r--r--refs/refs-internal.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 53a6c5d842..ee298ec0d5 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -765,4 +765,10 @@ int ref_update_has_null_new_value(struct ref_update *update);
int ref_update_check_old_target(const char *referent, struct ref_update *update,
struct strbuf *err);
+/*
+ * Check if the ref must exist, this means that the old_oid or
+ * old_target is non NULL.
+ */
+int ref_update_expects_existing_old_ref(struct ref_update *update);
+
#endif /* REFS_REFS_INTERNAL_H */