From 46f7011591601b4783b2dc2c7252c41564ca0140 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 11 Oct 2022 11:16:23 +0200 Subject: git: 'update-cached-checkout' returns the commit ID when given a tag. Previously, starting with commit efa578ecaece67366b4b0e2266de7c2faaa4ae54, 'update-cached-checkout' would return the OID of the annotated tag the tag points to. With this change it returns the OID of the commit object in all cases. * guix/git.scm (resolve-reference): In the 'tag' case, call 'tag-target-id' and 'tag-lookup' when OID designates an annotated tag. * tests/git.scm ("update-cached-checkout, tag"): New test. --- guix/git.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'guix/git.scm') diff --git a/guix/git.scm b/guix/git.scm index 10e6dcaf23..95630a5e69 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -272,12 +272,15 @@ corresponding Git object." ;; There's no such tag, so it must be a commit ID. (resolve `(commit . ,str))))))) (('tag . tag) - (let ((oid (reference-name->oid repository - (string-append "refs/tags/" tag)))) - ;; OID may point to a "tag" object, but it can also point directly - ;; to a "commit" object, as surprising as it may seem. Return that - ;; object, whatever that is. - (object-lookup repository oid)))))) + (let* ((oid (reference-name->oid repository + (string-append "refs/tags/" tag))) + (obj (object-lookup repository oid))) + ;; OID may designate an "annotated tag" object or a "commit" object. + ;; Return the commit object in both cases. + (if (= OBJ-TAG (object-type obj)) + (object-lookup repository + (tag-target-id (tag-lookup repository oid))) + obj)))))) (define (switch-to-ref repository ref) "Switch to REPOSITORY's branch, commit or tag specified by REF. Return the -- cgit v1.2.3