Skip to content

Commit ae3b18e

Browse files
committed
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.
1 parent b99f853 commit ae3b18e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

PGBuild/SCM.pm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,9 +1060,15 @@ sub _update_target
10601060
my @gitlog;
10611061

10621062
# If a run crashed during copy_source(), repair.
1063-
if (-d "./git-save" && !-d "$target/.git")
1063+
if (-d "./git-save")
10641064
{
1065-
move "./git-save", "$target/.git";
1065+
system(qq{git -C $target rev-parse --is-inside-work-tree > $devnull 2>&1});
1066+
if ($?)
1067+
{
1068+
require File::Path;
1069+
File::Path::remove_tree("$target/.git");
1070+
move "./git-save", "$target/.git";
1071+
}
10661072
}
10671073

10681074
chdir $target;

0 commit comments

Comments
 (0)