From 02ea323bb65d95dedf1af927151fc487452d734f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 27 Nov 2026 21:05:10 +0000 Subject: populate git: look at HEAD quietly, also before the first commit A git source with a commit as ref compared it with what git log printed for HEAD, which, in the repository git init just made for a shallow clone, has no commit yet, so git log failed, printing "fatal: your current branch 'master' does not have any commits yet", which looked like populate's failure, but wasn't. git rev-parse --verify --quiet HEAD prints nothing there. --- pkgs/populate/src/sh.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkgs/populate/src') diff --git a/pkgs/populate/src/sh.rs b/pkgs/populate/src/sh.rs index 77d2463..1f27b6b 100644 --- a/pkgs/populate/src/sh.rs +++ b/pkgs/populate/src/sh.rs @@ -547,7 +547,9 @@ deliver_git() { } if printf %s "$ref" | grep -Eqx '[0-9a-f]{4,40}'; then hash=$ref - if ! test "$(git log --format=%H -1)" = "$hash"; then + # Quietly, also in a repository without commits yet, e.g. a shallow + # one git init just made. + if ! test "$(git rev-parse --verify --quiet HEAD)" = "$hash"; then if test -n "$fetch_always"; then fetch_commit elif ! git log -1 "$hash" >/dev/null 2>&1; then -- cgit v1.3.1