aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-27 21:05:10 +0000
committertv <tv@krebsco.de>2026-11-30 14:22:03 +0000
commit41fe8746f14564ca277e70fb4172dba63d9a3351 (patch)
tree68a3be073d2b0183c022bb32f051a45a2c019268
parentaa33ec01df2e523483f355de5e350f89b5cef5d5 (diff)
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.
-rw-r--r--pkgs/populate/src/sh.rs4
1 files changed, 3 insertions, 1 deletions
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