From: "Ludovic Courtès" <ludo@gnu.org>
To: Simon Tournier <zimon.toutoune@gmail.com>
Cc: 74481@debbugs.gnu.org, Josselin Poiret <dev@jpoiret.xyz>,
Tobias Geerinckx-Rice <me@tobias.gr>,
Mathieu Othacehe <othacehe@gnu.org>,
Christopher Baines <guix@cbaines.net>
Subject: [bug#74481] [PATCH 1/2] git: Catch Git errors when updating cached checkout.
Date: Thu, 12 Dec 2024 12:34:57 +0100 [thread overview]
Message-ID: <87bjxhb0da.fsf@gnu.org> (raw)
In-Reply-To: <cac32323de53f86d27508edc676ee7ed601d7b98.1732302033.git.zimon.toutoune@gmail.com> (Simon Tournier's message of "Fri, 22 Nov 2024 20:09:26 +0100")
Hi,
Simon Tournier <zimon.toutoune@gmail.com> skribis:
> * guix/git.scm (resolve-reference): Catch Git error when reference does not
> exist and return #false.
> (switch-to-ref): Adjust.
> (update-cached-checkout)[close-and-clean!]: New helper.
> Catch Git error when reference does not exist and warn.
> Return #false values when reference does not exist.
>
> Change-Id: If6e244fe40ebee978ec8de51a6a68bcbd4a2c79e
[...]
> (define (resolve-reference repository ref)
> "Resolve the branch, commit or tag specified by REF, and return the
> -corresponding Git object."
> +corresponding Git object. Return #false if REF is not found."
> (let resolve ((ref ref))
> (match ref
> (('branch . branch)
> @@ -281,9 +281,12 @@ (define (resolve-reference repository ref)
> ;; can't be sure it's available. Furthermore, 'string->oid' used to
> ;; read out-of-bounds when passed a string shorter than 40 chars,
> ;; which is why we delay calls to it below.
> - (if (< len 40)
> - (object-lookup-prefix repository (string->oid commit) len)
> - (object-lookup repository (string->oid commit)))))
> + (catch 'git-error
> + (lambda ()
> + (if (< len 40)
> + (object-lookup-prefix repository (string->oid commit) len)
> + (object-lookup repository (string->oid commit))))
> + (lambda _ #f))))
> (('tag-or-commit . str)
> (cond ((and (string-contains str "-g")
> (match (string-split str #\-)
> @@ -300,7 +303,10 @@ (define (resolve-reference repository ref)
> => (lambda (commit) (resolve `(commit . ,commit))))
> ((or (> (string-length str) 40)
> (not (string-every char-set:hex-digit str)))
> - (resolve `(tag . ,str))) ;definitely a tag
> + (catch 'git-error ;definitely a tag
> + (lambda ()
> + (resolve `(tag . ,str)))
> + (lambda _ #f)))
Sorry for not replynig earlier. I would avoid such a change: it changes
the semantics of ‘resolve-reference’ in a non-trivial and hard-to-test
way.
Instead, since the goal is to address a problem that’s specific to
importers (or to one importer), I would suggest making a local change in
the importer itself, or in code that is shared among importers only.
(This comment applies to this entire patch.)
Ludo’.
next prev parent reply other threads:[~2024-12-12 11:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 19:05 [bug#74481] [PATCH 0/2] Handle corner cases of 'guix import go' Simon Tournier
2024-11-22 19:09 ` [bug#74481] [PATCH 1/2] git: Catch Git errors when updating cached checkout Simon Tournier
2024-12-12 11:34 ` Ludovic Courtès [this message]
2024-12-12 12:04 ` Simon Tournier
2024-11-22 19:09 ` [bug#74481] [PATCH 2/2] import: go: Warn instead of error out when reference is missing Simon Tournier
2024-12-10 14:09 ` [bug#74481] [PATCH 0/2] Handle corner cases of 'guix import go' Simon Tournier
2024-12-10 18:40 ` Sharlatan Hellseher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bjxhb0da.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=74481@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.