From 39edd41567fd9aeac114f2d8181416ed2fb69510 Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Mon, 11 Aug 2025 11:45:44 -0400 Subject: [PATCH] Have git verify the repository Rather than simply check for the presence of `.git` when `git-save` exists, run `git rev-parse --is-inside-work-tree` and replace the `.git` directory when it returns an error. This will fix corrupted `.git` directories left over from previous builds, as well as missing `.git` directories. --- PGBuild/SCM.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PGBuild/SCM.pm b/PGBuild/SCM.pm index fb14d9b..c089038 100644 --- a/PGBuild/SCM.pm +++ b/PGBuild/SCM.pm @@ -1060,9 +1060,15 @@ sub _update_target my @gitlog; # If a run crashed during copy_source(), repair. - if (-d "./git-save" && !-d "$target/.git") + if (-d "./git-save") { - move "./git-save", "$target/.git"; + system(qq{git -C $target rev-parse --is-inside-work-tree > $devnull 2>&1}); + if ($?) + { + require File::Path; + File::Path::remove_tree("$target/.git"); + move "./git-save", "$target/.git"; + } } chdir $target;