fix_git_config()
{
+ if ! [ -f ".git/config" ]; then
+ $ECHO "Not a git repository. Bailing out to not cause damage."
+ exit 1
+ fi
verbose git config remote.origin.url "$1"
if [ -n "$2" ]; then
verbose git config remote.origin.pushurl "$2"
url=`repourl "$d"`
pushurl=`repopushurl "$d"`
branch=`repobranch "$d"`
- if [ -d "$d0/$d" ]; then
+ if [ -f "$d0/$d/.git/config" ]; then
verbose cd "$d0/$d"
fix_git_config "$url" "$pushurl"
cd "$d0"
url=`repourl "$d"`
pushurl=`repopushurl "$d"`
branch=`repobranch "$d"`
- if [ -d "$d0/$d" ]; then
+ if [ -f "$d0/$d/.git/config" ]; then
# if we have .no file, skip
if [ -f "$d0/$d.no" ]; then
msg "Repository $d disabled by a .no file, delete $d.no to enable; thus, not updated"
cd "$d0"
fi
else
+ if [ -d "$d0/$d" ]; then
+ if yesno "$d0/$d is in the way, get rid of it and reclone?"; then
+ verbose rm -rf "$d0/$d"
+ else
+ echo "Note: $d0/$d will stay broken."
+ continue
+ fi
+ fi
verbose git clone "$url" "$d0/$d"
enter "$d0/$d" verbose
fix_git_config "$url" "$pushurl"
{
if(/^-i$/) # info
{
- my $total = 17 * 8 + 8 + length($msg);
+ my $msgalign = [0, 3, 2, 1]->[length($msg) % 4];
+ my $total = 17 * 8 + 8 + length($msg) + $msgalign;
my $max = 0;
for(0..@bsp-1)
{
my $nl = length $bsp[$_]->[2];
- $total += $nl;
+ my $align = [0, 3, 2, 1]->[$nl % 4];
+ $total += $nl + $align;
print "BSP lump $_ ($lumpname[$_]): offset $bsp[$_]->[0] length $bsp[$_]->[1] newlength $nl\n";
my $endpos = $bsp[$_]->[0] + $bsp[$_]->[1];
$max = $endpos if $max < $endpos;
open my $fh, ">", $outfile
or die "$outfile: $!";
print $fh $header;
- my $pos = 17 * 8 + tell($fh) + length $msg;
+ my $msgalign = [0, 3, 2, 1]->[length($msg) % 4];
+ my $pos = 17 * 8 + tell($fh) + length($msg) + $msgalign;
for(@bsp)
{
+ my $align = [0, 3, 2, 1]->[length($_->[2]) % 4];
$_->[0] = $pos;
$_->[1] = length $_->[2];
- $pos += $_->[1];
+ $pos += $_->[1] + $align;
print $fh pack "VV", $_->[0], $_->[1];
}
print $fh $msg;
+ print $fh "\x00" x $msgalign;
for(@bsp)
{
+ my $align = [0, 3, 2, 1]->[length($_->[2]) % 4];
print $fh $_->[2];
+ print $fh "\x00" x $align;
}
close $fh;
print STDERR "Wrote $outfile\n";