* [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel>
@ 2022-10-11 9:51 Ludovic Courtès
2022-10-11 9:52 ` [bug#58433] [PATCH 1/2] git: 'update-cached-checkout' returns the commit ID when given a tag Ludovic Courtès
2022-10-13 13:03 ` [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Christopher Baines
0 siblings, 2 replies; 5+ messages in thread
From: Ludovic Courtès @ 2022-10-11 9:51 UTC (permalink / raw)
To: 58433; +Cc: Ludovic Courtès
Hi!
This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
as in:
guix time-machine --commit=v1.2.0 -- describe
At last!
Thoughts?
Ludo’.
Ludovic Courtès (2):
git: 'update-cached-checkout' returns the commit ID when given a tag.
channels: Interpret the 'commit' field of channel as a tag or commit.
doc/guix.texi | 23 +++++++++++++++++++++--
guix/channels.scm | 2 +-
guix/git.scm | 15 +++++++++------
guix/inferior.scm | 2 +-
tests/git.scm | 32 +++++++++++++++++++++++++++++++-
5 files changed, 63 insertions(+), 11 deletions(-)
base-commit: 5d5bc072059f514394afdaccfcc72cdb282d7ce2
--
2.38.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [bug#58433] [PATCH 1/2] git: 'update-cached-checkout' returns the commit ID when given a tag.
2022-10-11 9:51 [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Ludovic Courtès
@ 2022-10-11 9:52 ` Ludovic Courtès
2022-10-11 9:52 ` [bug#58433] [PATCH 2/2] channels: Interpret the 'commit' field of channel as a tag or commit Ludovic Courtès
2022-10-13 13:03 ` [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Christopher Baines
1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2022-10-11 9:52 UTC (permalink / raw)
To: 58433; +Cc: Ludovic Courtès
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 +++++++++------
tests/git.scm | 32 +++++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/guix/git.scm b/guix/git.scm
index d7fd320f50..0220fe1068 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -271,12 +271,15 @@ (define (resolve-reference repository ref)
;; 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
diff --git a/tests/git.scm b/tests/git.scm
index ca59d2a33e..9c944d65b1 100644
--- a/tests/git.scm
+++ b/tests/git.scm
@@ -22,8 +22,12 @@ (define-module (test-git)
#:use-module (guix git)
#:use-module (guix tests git)
#:use-module (guix build utils)
+ #:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (srfi srfi-1)
- #:use-module (srfi srfi-64))
+ #:use-module (srfi srfi-64)
+ #:use-module (srfi srfi-71)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 textual-ports))
;; Test the (guix git) tools.
@@ -239,4 +243,30 @@ (define-module (test-git)
(tag "v1.1" "Release 1.1"))
(remote-refs directory #:tags? #t)))
+(unless (which (git-command)) (test-skip 1))
+(test-assert "update-cached-checkout, tag"
+ (call-with-temporary-directory
+ (lambda (cache)
+ (with-temporary-git-repository directory
+ '((add "a.txt" "A")
+ (commit "First commit")
+ (tag "v1.0" "release-1.0")
+ (branch "develop")
+ (checkout "develop")
+ (add "b.txt" "B")
+ (commit "Second commit")
+ (tag "v1.1" "release-1.1"))
+ (let ((directory commit relation
+ (update-cached-checkout directory
+ #:ref '(tag . "v1.1")
+ #:cache-directory cache))
+ (head (let* ((pipe (open-pipe* OPEN_READ (git-command)
+ "-C" directory
+ "rev-parse" "HEAD"))
+ (str (get-string-all pipe)))
+ (close-pipe pipe)
+ (string-trim-right str))))
+ ;; COMMIT should be the ID of the commit object, not that of the tag.
+ (string=? commit head))))))
+
(test-end "git")
--
2.38.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#58433] [PATCH 2/2] channels: Interpret the 'commit' field of channel as a tag or commit.
2022-10-11 9:52 ` [bug#58433] [PATCH 1/2] git: 'update-cached-checkout' returns the commit ID when given a tag Ludovic Courtès
@ 2022-10-11 9:52 ` Ludovic Courtès
0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2022-10-11 9:52 UTC (permalink / raw)
To: 58433; +Cc: Ludovic Courtès
Previously the 'commit' field would always be interpreted as a commit
ID. This change adds flexibility, allowing for things like:
guix time-machine --commit=v1.2.0 -- describe
* guix/channels.scm (channel-reference): Use 'tag-or-commit' rather than 'commit'.
* guix/inferior.scm (channel-full-commit): Likewise.
* doc/guix.texi (Invoking guix pull): Document it.
(Invoking guix time-machine): Likewise.
---
doc/guix.texi | 23 +++++++++++++++++++++--
guix/channels.scm | 2 +-
guix/inferior.scm | 2 +-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 14592142dd..4c24600f04 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4631,7 +4631,7 @@ but it supports the following options:
@itemx --branch=@var{branch}
Download code for the @code{guix} channel from the specified @var{url}, at the
given @var{commit} (a valid Git commit ID represented as a hexadecimal
-string), or @var{branch}.
+string or the name of a tag), or @var{branch}.
@cindex @file{channels.scm}, configuration file
@cindex configuration file for channels
@@ -4783,6 +4783,25 @@ of Guix to be used is defined by a commit or by a channel
description file created by @command{guix describe}
(@pxref{Invoking guix describe}).
+Let's assume that you want to travel to those days of November 2020 when
+version 1.2.0 of Guix was released and, once you're there, run the
+@command{guile} of that time:
+
+@example
+guix time-machine --commit=v1.2.0 -- \
+ environment -C --ad-hoc guile -- guile
+@end example
+
+The command above fetches Guix@tie{}1.2.0 and runs its @command{guix
+environment} command to spawn an environment in a container running
+@command{guile} (@command{guix environment} has since been subsumed by
+@command{guix shell}; @pxref{Invoking guix shell}). It's like driving a
+DeLorean@footnote{If you don't know what a DeLorean is, consider
+traveling back to the 1980's.}! The first @command{guix time-machine}
+invocation can be expensive: it may have to download or even build a
+large number of packages; the result is cached though and subsequent
+commands targeting the same commit are almost instantaneous.
+
The general syntax is:
@example
@@ -4799,7 +4818,7 @@ this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull
@itemx --branch=@var{branch}
Use the @code{guix} channel from the specified @var{url}, at the
given @var{commit} (a valid Git commit ID represented as a hexadecimal
-string), or @var{branch}.
+string or the name of a tag), or @var{branch}.
@item --channels=@var{file}
@itemx -C @var{file}
diff --git a/guix/channels.scm b/guix/channels.scm
index f1c23c17fb..d84228c47e 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -248,7 +248,7 @@ (define (channel-reference channel)
'latest-repository-commit'."
(match (channel-commit channel)
(#f `(branch . ,(channel-branch channel)))
- (commit `(commit . ,(channel-commit channel)))))
+ (commit `(tag-or-commit . ,(channel-commit channel)))))
(define sexp->channel-introduction
(match-lambda
diff --git a/guix/inferior.scm b/guix/inferior.scm
index cbb3c0a36e..2fe34ca0dc 100644
--- a/guix/inferior.scm
+++ b/guix/inferior.scm
@@ -835,7 +835,7 @@ (define (channel-full-commit channel)
(branch (channel-branch channel)))
(if (and commit (commit-id? commit))
commit
- (let* ((ref (if commit `(commit . ,commit) `(branch . ,branch)))
+ (let* ((ref (if commit `(tag-or-commit . ,commit) `(branch . ,branch)))
(cache commit relation
(update-cached-checkout (channel-url channel)
#:ref ref
--
2.38.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel>
2022-10-11 9:51 [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Ludovic Courtès
2022-10-11 9:52 ` [bug#58433] [PATCH 1/2] git: 'update-cached-checkout' returns the commit ID when given a tag Ludovic Courtès
@ 2022-10-13 13:03 ` Christopher Baines
2022-10-17 8:47 ` bug#58433: " Ludovic Courtès
1 sibling, 1 reply; 5+ messages in thread
From: Christopher Baines @ 2022-10-13 13:03 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 58433
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
> as in:
>
> guix time-machine --commit=v1.2.0 -- describe
>
> At last!
>
> Thoughts?
This sounds good to me :)
Thanks,
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#58433: [PATCH 0/2] Accept tags in the 'commit' field of <channel>
2022-10-13 13:03 ` [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Christopher Baines
@ 2022-10-17 8:47 ` Ludovic Courtès
0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2022-10-17 8:47 UTC (permalink / raw)
To: Christopher Baines; +Cc: 58433-done
Hi,
Christopher Baines <mail@cbaines.net> skribis:
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> This change lets us pass tags to ‘guix time-machine’ and ‘guix pull’,
>> as in:
>>
>> guix time-machine --commit=v1.2.0 -- describe
>>
>> At last!
>>
>> Thoughts?
>
> This sounds good to me :)
Pushed, thanks for taking a look!
f36522416e * channels: Interpret the 'commit' field of channel as a tag or commit.
46f7011591 * git: 'update-cached-checkout' returns the commit ID when given a tag.
Ludo’.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-17 8:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 9:51 [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Ludovic Courtès
2022-10-11 9:52 ` [bug#58433] [PATCH 1/2] git: 'update-cached-checkout' returns the commit ID when given a tag Ludovic Courtès
2022-10-11 9:52 ` [bug#58433] [PATCH 2/2] channels: Interpret the 'commit' field of channel as a tag or commit Ludovic Courtès
2022-10-13 13:03 ` [bug#58433] [PATCH 0/2] Accept tags in the 'commit' field of <channel> Christopher Baines
2022-10-17 8:47 ` bug#58433: " Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.