From f9c2b64c9b1cf990702040beb300afc0c9073aee Mon Sep 17 00:00:00 2001 From: no92 Date: Fri, 10 Jun 2022 02:03:40 +0200 Subject: [PATCH] checkout: check whether commit exists and warn if it doesn't --- xbstrap/base.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xbstrap/base.py b/xbstrap/base.py index 0f675c7..8ba8aad 100644 --- a/xbstrap/base.py +++ b/xbstrap/base.py @@ -2086,6 +2086,18 @@ def checkout_src(cfg, src, settings): else: if fixed_commit is not None: commit = fixed_commit + missing_commit = False + try: + subprocess.check_call( + ["git", "cat-file", "-e", commit + "^{commit}"], + cwd=src.source_dir, + ) + except subprocess.CalledProcessError: + missing_commit = True + if missing_commit: + raise RuntimeError( + "git commit '{}' was not found for source '{}'".format(commit, src.name) + ) if init or settings.reset != ResetMode.NONE: subprocess.check_call( ["git", "checkout", "--no-track", "-B", source["branch"], commit],