]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refs.c
refs: support symrefs in 'reference-transaction' hook
[thirdparty/git.git] / refs.c
diff --git a/refs.c b/refs.c
index e7b7c48d92cb49e18946caf478aa13a84098cbec..9d722d798a5f7c1c74ce36a194815956e3aebdbb 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2350,10 +2350,22 @@ static int run_transaction_hook(struct ref_transaction *transaction,
                struct ref_update *update = transaction->updates[i];
 
                strbuf_reset(&buf);
-               strbuf_addf(&buf, "%s %s %s\n",
-                           oid_to_hex(&update->old_oid),
-                           oid_to_hex(&update->new_oid),
-                           update->refname);
+
+               if (!(update->flags & REF_HAVE_OLD))
+                       strbuf_addf(&buf, "%s ", oid_to_hex(null_oid()));
+               else if (update->old_target)
+                       strbuf_addf(&buf, "ref:%s ", update->old_target);
+               else
+                       strbuf_addf(&buf, "%s ", oid_to_hex(&update->old_oid));
+
+               if (!(update->flags & REF_HAVE_NEW))
+                       strbuf_addf(&buf, "%s ", oid_to_hex(null_oid()));
+               else if (update->new_target)
+                       strbuf_addf(&buf, "ref:%s ", update->new_target);
+               else
+                       strbuf_addf(&buf, "%s ", oid_to_hex(&update->new_oid));
+
+               strbuf_addf(&buf, "%s\n", update->refname);
 
                if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
                        if (errno != EPIPE) {