Skip to content

Commit 5e5a207

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 6d6238f commit 5e5a207

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
@@ -1074,9 +1074,15 @@ sub _update_target
10741074
my @gitlog;
10751075

10761076
# If a run crashed during copy_source(), repair.
1077-
if (-d "./git-save" && !-d "$target/.git")
1077+
if (-d "./git-save")
10781078
{
1079-
move "./git-save", "$target/.git";
1079+
system(qq{git -C $target rev-parse --is-inside-work-tree > $devnull 2>&1});
1080+
if ($?)
1081+
{
1082+
require File::Path;
1083+
File::Path::remove_tree("$target/.git");
1084+
move "./git-save", "$target/.git";
1085+
}
10801086
}
10811087

10821088
chdir $target;

0 commit comments

Comments
 (0)