summaryrefslogtreecommitdiffstats
path: root/refs.h
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2024-11-22 13:28:45 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-25 03:46:35 +0100
commitd842cd130122c6f3d3019d467040570d7d001f7a (patch)
tree89e96dc4ee82cbcf252d10b23eaddd77c9b9f9cc /refs.h
parentrefs: standardize output of refs_read_symbolic_ref (diff)
downloadgit-d842cd130122c6f3d3019d467040570d7d001f7a.tar.xz
git-d842cd130122c6f3d3019d467040570d7d001f7a.zip
refs: atomically record overwritten ref in update_symref
When updating a symref with update_symref it's currently not possible to know for sure what was the previous value that was overwritten. Extend refs_update_symref under a new function name, to record the value after the ref has been locked if the caller of refs_update_symref_extended requests it via a new variable in the function call. Make the return value of the function notify the caller, if the previous value was actually not a symbolic reference. Keep the original refs_update_symref function with the same signature, but now as a wrapper around refs_update_symref_extended. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/refs.h b/refs.h
index 22c2b45b8b..5c46ac9f34 100644
--- a/refs.h
+++ b/refs.h
@@ -584,6 +584,10 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
int refs_update_symref(struct ref_store *refs, const char *refname,
const char *target, const char *logmsg);
+int refs_update_symref_extended(struct ref_store *refs, const char *refname,
+ const char *target, const char *logmsg,
+ struct strbuf *referent);
+
enum action_on_err {
UPDATE_REFS_MSG_ON_ERR,
UPDATE_REFS_DIE_ON_ERR,