Merge branch 'keni-gitset2' into NetHack-3.7

This commit is contained in:
nhkeni
2024-11-11 11:27:27 -05:00
27 changed files with 1412 additions and 677 deletions

View File

@@ -92,10 +92,11 @@ B. Specify the prefix for variable substitution:
tree you cloned from git. I use ~/nethack/GITADDDIR; for that base,
create the needed directories and edit the file:
~/nethack/GITADDDIR/DOTGIT/PRE
Put this in it (if your OS is not Unix-like you may need to change
the first line):
Put this in it, adapting it to your variant (if your OS is not Unix-like
you may need to change the first line):
#!/bin/sh
git config nethack.substprefix MINE
git config nethack.projectname MineHack
Now make it executable:
chmod +x ~/nethack/GITADDDIR/DOTGIT/PRE
C. Configure the repository:
@@ -169,8 +170,8 @@ A. Introduction
The PREFIX is the value in the git config variable nethack.substprefix.
VARNAME is one of:
Date
Branch (experimental)
Revision (experimental)
Branch
Revision
other names will give a warning.
B. Enabling variable expansion

40
DEVEL/VERSION Normal file
View File

@@ -0,0 +1,40 @@
4
Fixes:
- "nhcommit -a" has been fixed
- NHDT was hardwired in places
- no longer complain about a missing dat directory outside of the
NetHack source tree
- make update of gitinfo atomic
- Replace some hardwired directory separators with OS-dependent constructs
Backwards Incompatibilities:
- NH_DATESUB's DATE() is now Date() to match the other variables
- MSYS2 requires an additional Perl package - the MSYS2 docs have
been updated
New Help System:
- git nhhelp
This command mirrors "git help" for nh* commands.
- See git nhhelp nhsub for general help on substitution variables
New Substitution Variables:
-Brev()
An aBREViation of $PREFIX-Branch$:$PREFIX-Revision$ - this
may help get line length under control in file headers.
-Assert(TYPE=VALUE)
If TYPE does not match VALUE, do not substitute on this line.
TYPE P checks VALUE against nethack.substprefix
-Project(arg)
Returns nethack.projectname if there is no arg and an uppercase
version if arg is uc.
Other New Features:
- Add nethack.projectname
- Documentation updates - see "git nhhelp nhsub"
- On checkout or merge of a branch, check for nhgitset version updates
- Move NH_DATESUB substitutions here from cron job to keep dates in sync
- PREFIX-* keywords now available in NH_DATESUB templates
- Support use of nhgitset.pl from a different repo; note that update
checks will be dependent on keeping the original source repo up-to-date
and in the same location.

View File

@@ -12,11 +12,32 @@ die "Bad subcommand '$ARGV[0]'" unless $ok{$ARGV[0]};
# we won't fail on a failure, so just system()
$rv = system('.git/hooks/nhsub',"--$ARGV[0]",@ARGV[1..$#ARGV]);
if($rv){
print "warning: nhsub failed: $rv $!\n";
print "warning: nhsub failed: $rv $!\n";
}
if(length $ENV{GIT_PREFIX}){
chdir($ENV{GIT_PREFIX}) or die "Can't chdir $ENV{GIT_PREFIX}: $!";
chdir($ENV{GIT_PREFIX}) or die "Can't chdir $ENV{GIT_PREFIX}: $!";
}
exec "git", @ARGV or die "Can't exec git: $!";
__END__
=for nhgitset nhadd Add file contents to the index with NetHack additions
=for nhgitset nhcommit Record changes to the repository with NetHack additions
=head1 NAME
C<NHadd> - NetHack internal common code for nhadd and nhcommit
=head1 SYNOPSIS
C<git nhadd E<lt>git add optionsE<gt>>
C<git nhcommit E<lt>git add optionsE<gt>>
=head1 DESCRIPTION
Run nhsub with the given arguments, then run C<git add> or C<git commit>
with the given arguments. Note that only basic arguments for those commands
are understood; more complex situations may be handled by running C<git nhsub>
manually before running C<git add> or C<git commit>.

View File

@@ -16,9 +16,11 @@ my $tracefile = "/tmp/nhgitt.$$";
# OS hackery
my $DS = quotemeta('/');
my $PDS = '/';
if ($^O eq "MSWin32")
{
$DS = quotemeta('\\');
$PDS = '\\';
}
our %saved_env;
@@ -26,25 +28,23 @@ our @saved_argv;
our $saved_input;
sub saveSTDIN {
@saved_input = <STDIN>;
@saved_input = <STDIN>;
if($trace){
print TRACE "STDIN:\n";
print TRACE $saved_input;
print TRACE "ENDSTDIN\n";
}
if($trace){
print TRACE "STDIN:\n";
print TRACE $saved_input;
print TRACE "ENDSTDIN\n";
}
tie *STDIN, 'NHIO::STDIN', @saved_input;
tie *STDIN, 'NHIO::STDIN', @saved_input;
}
# XXX this needs a re-write (don't tie and untie, just set NEXT=0)
# (the sensitive thing is @foo = <STDIN> )
sub resetSTDIN{
my $x = tied(*STDIN);
my %x = %$x;
my $data = @$x{DATA};
untie *STDIN;
tie *STDIN, 'NHIO::STDIN', $data;
my $x = tied(*STDIN);
my %x = %$x;
my $data = @$x{DATA};
untie *STDIN;
tie *STDIN, 'NHIO::STDIN', $data;
}
# don't need this now
@@ -55,21 +55,142 @@ sub resetSTDIN{
#}
sub PRE {
&do_hook("PRE");
&do_hook("PRE");
}
sub POST {
&do_hook("POST");
&do_hook("POST");
}
###
### versioning for nhgitset and friends
###
# values of nethack.setupversion and DEVEL/VERSION:
# 1 is reserved for repos checked out before versioning was added
# 2 used clean/smudge filter, poorly
# 3 was first production version
# 4 added the version file and version checking; nhhelp, NH_DATESUB support, etc.
sub version_in_devel {
# (1) check for a non-null nethack.setuppath - this handles
# any repo that has already been set up (but NOT checking
# out <v4 over >=v4 since nethack.setuppath will exist but
# DEVEL/VERSION will not).
# XXX if the source repo has been removed, we'll fall back to
# the third case - hopefully that's ok.
# XXX there's no way to recover from a missing source repo
# without editing .git/config.
my $path = `git config --local nethack.setuppath`;
chomp $path;
$path =~ s/DEVEL$//; # NOP if config not set
# (2) else check the local directory; that will be correct for NHsource.
if(0 == length $path){
$path = `git rev-parse --show-toplevel`;
chomp $path;
$path = '' unless(-d "$path${PDS}DEVEL");
}
# (3) If that doesn't exist, check using the invocation path; that will be
# correct for other repos during nhgitset (but will also fail for
# checking out 3 over 4).
if(0 == length $path){
# strip out "DEVEL"
$path = ($0 =~ m!^(.*)${PDS}DEVEL${PDS}.*?(*nla:DEVEL)!)[0];
}
# Uh oh?
if(0==length($path) or (! -d "$path${PDS}DEVEL")){
die "Can't locate DEVEL directory in '$path'.";
}
# Handle checking out version <4 over version >=4. If
# this seems to be the situation, don't revert the code.
return 0 if(! -f "$path${PDS}DEVEL${PDS}VERSION");
my $version;
my $verfile = "$path${PDS}DEVEL${PDS}VERSION";
open VERFH,"<",$verfile or die "xCan't open $verfile: $!";
$version = 0+<VERFH>;
my $message = join('',<VERFH>);
close VERFH;
die "Valid version not found in $verfile" unless($version >= 4);
return ($version,$message) if($version > 0);
return 0;
}
sub version_in_git {
my $vtemp = `git config --local --get nethack.setupversion`;
chomp($vtemp);
return $vtemp if($vtemp > 0);
return 0;
}
sub version_set_git {
my $version_new = $_[0];
system("git config nethack.setupversion $version_new");
if($?){
die "Can't set nethack.setupversion $version_new: $?,$!\n";
}
}
###
### store githash and gitbranch in dat/gitinfo.txt
###
# CAUTION! This is run not just from git hooks, but also from
# sys/unix/gitinfo.sh
sub nhversioning {
use strict;
use warnings;
# See if we're (probably) in a "git pull", in which case we need to
# check for upgrades.
my $check_upgrade = 1 if($_[0]);
# Check for pre-v4 source repo.
my $is_sourcerepo;
{
chomp($is_sourcerepo = `git config --type=int --get nethack.is-sourcerepo`);
if(0 == length $is_sourcerepo){ # not set - assume old repo
$is_sourcerepo = 1;
}elsif($is_sourcerepo==1){
;
}elsif($is_sourcerepo==0){
;
}
}
# Skip the skipping tests if we're being called directly.
# NB: post-commit has no args, but that will be caught by
# the next test for non-source repos.
if($#ARGV != -1){
# Skip this if we didn't change branches, but see if we need to warn.
if(defined($ARGV[2]) and ($ARGV[2] == 0)){
# Because we can create an out of sync state, possibly warn.
my $ref = $ARGV[1];
if($is_sourcerepo and (0 != 0+`git diff --name-only $ref $ref^ |grep ^DEVEL|wc -l`)){
warn "WARNING: DEVEL directory changed. Versioning may be inconsistent\n";
}
return
}
}
if($check_upgrade){
my $current_version = version_in_git();
my($new_version,$message) = version_in_devel();
if($new_version > $current_version){
warn "nhgitset.pl and/or related programs have changed.\n";
warn "Please re-run nhgitset.pl to update from version $current_version to $new_version.\n";
if(length $message){
warn "Additional information\n$message\n";
}
}
}
# Skip versioning if we aren't in a source repo.
return if(0==$is_sourcerepo);
my $git_sha = `git rev-parse HEAD`;
$git_sha =~ s/\s+//g;
my $git_branch = `git rev-parse --abbrev-ref HEAD`;
@@ -77,7 +198,14 @@ sub nhversioning {
die "git rev-parse failed" unless(length $git_sha and length $git_branch);
my $exists = 0;
if (open my $fh, '<', 'dat/gitinfo.txt') {
no strict 'refs';
no strict 'subs';
my $file_gitinfo = "dat${PDS}gitinfo.txt";
my $file_gittemp = "dat${PDS}TMPgitinfo.txt";
use strict 'subs';
use strict 'refs';
if (open my $fh, '<', $file_gitinfo) {
$exists = 1;
my $hashok = 0;
my $branchok = 0;
@@ -91,61 +219,71 @@ sub nhversioning {
}
close $fh;
if ($hashok && $branchok) {
print "dat/gitinfo.txt unchanged, githash=".$git_sha."\n";
print "$file_gitinfo unchanged, githash=".$git_sha."\n";
return;
}
} else {
print "WARNING: Can't find dat directory\n" unless(-d "dat");
warn "WARNING: Can't find dat directory\n" unless(-d "dat");
return;
}
if (open my $fh, '>', 'dat/gitinfo.txt') {
if (open my $fh, '>', $file_gittemp) {
my $how = ($exists ? "updated" : "created");
print $fh 'githash='.$git_sha."\n";
print $fh 'gitbranch='.$git_branch."\n";
print "dat/gitinfo.txt ".$how.", githash=".$git_sha."\n";
print "$file_gitinfo ".$how.", githash=".$git_sha."\n";
if(close($fh)){
if(rename($file_gittemp, $file_gitinfo)){
; # all ok
} else {
warn "WARNING: Can't rename $file_gittemp -> $file_gitinfo";
}
} else {
warn "WARNING: Can't close temp file: $!";
}
} else {
print "WARNING: Unable to open dat/gitinfo.txt: $!\n";
warn "WARNING: Unable to open $file_gitinfo: $!\n";
}
}
# PRIVATE
sub do_hook {
my($p) = @_;
my $hname = $0;
$hname =~ s!^((.*$DS)|())(.*)!$1$p-$4!;
if(-x $hname){
print TRACE "START $p: $hname\n" if($trace);
my($p) = @_;
my $hname = $0;
$hname =~ s!^((.*$DS)|())(.*)!$1$p-$4!;
if(-x $hname){
print TRACE "START $p: $hname\n" if($trace);
open TOHOOK, "|-", $hname or die "open $hname: $!";
print TOHOOK <STDIN>;
close TOHOOK or die "close $hname: $! $?";
open TOHOOK, "|-", $hname or die "open $hname: $!";
print TOHOOK <STDIN>;
close TOHOOK or die "close $hname: $! $?";
print TRACE "END $p\n" if($trace);
}
print TRACE "END $p\n" if($trace);
}
}
sub trace_start {
return unless($trace);
my $self = shift;
open TRACE, ">>", $tracefile;
print TRACE "START CLIENT PID:$$ ARGV:\n";
print TRACE "CWD: " . cwd() . "\n";
print TRACE "[0] $0\n";
my $x1;
for(my $x=0;$x<scalar @ARGV;$x++){
$x1 = $x+1;
print TRACE "[$x1] $ARGV[$x]\n";
}
print TRACE "ENV:\n";
foreach my $k (sort keys %ENV){
next unless ($k =~ m/(^GIT_)|(^NH)/);
print TRACE " $k => $ENV{$k}\n";
}
return unless($trace);
my $self = shift;
open TRACE, ">>", $tracefile;
print TRACE "START CLIENT PID:$$ ARGV:\n";
print TRACE "CWD: " . cwd() . "\n";
print TRACE "[0] $0\n";
my $x1;
for(my $x=0;$x<scalar @ARGV;$x++){
$x1 = $x+1;
print TRACE "[$x1] $ARGV[$x]\n";
}
print TRACE "ENV:\n";
foreach my $k (sort keys %ENV){
next unless ($k =~ m/(^GIT_)|(^NH)/);
print TRACE " $k => $ENV{$k}\n";
}
}
BEGIN {
%saved_env = %ENV;
@saved_argv = @ARGV;
&trace_start;
%saved_env = %ENV;
@saved_argv = @ARGV;
&trace_start;
}
###
@@ -153,42 +291,41 @@ BEGIN {
###
package NHIO::STDIN;
sub TIEHANDLE {
my $class = shift;
my %fh;
# XXX yuck
if(ref @_[0]){
$fh{DATA} = @_[0];
} else {
$fh{DATA} = \@_;
}
$fh{NEXT} = 0;
return bless \%fh, $class;
my $class = shift;
my %fh;
if(ref @_[0]){
$fh{DATA} = @_[0];
} else {
$fh{DATA} = \@_;
}
$fh{NEXT} = 0;
return bless \%fh, $class;
}
sub READLINE {
my $self = shift;
return undef if($self->{EOF});
if(wantarray){
my $lim = $#{$self->{DATA}};
my @ary = @{$self->{DATA}}[$self->{NEXT}..$lim];
my @rv = @ary[$self->{NEXT}..$#ary];
$self->{EOF} = 1;
return @rv;
} else{
my $rv = $self->{DATA}[$self->{NEXT}];
if(length $rv){
$self->{NEXT}++;
return $rv;
} else {
$self->{EOF} = 1;
return undef;
}
}
my $self = shift;
return undef if($self->{EOF});
if(wantarray){
my $lim = $#{$self->{DATA}};
my @ary = @{$self->{DATA}}[$self->{NEXT}..$lim];
my @rv = @ary[$self->{NEXT}..$#ary];
$self->{EOF} = 1;
return @rv;
} else{
my $rv = $self->{DATA}[$self->{NEXT}];
if(length $rv){
$self->{NEXT}++;
return $rv;
} else {
$self->{EOF} = 1;
return undef;
}
}
}
sub EOF {
$self = shift;
return $self->{EOF};
$self = shift;
return $self->{EOF};
}
1;
@@ -223,11 +360,20 @@ NHgithook - common code for NetHack git hooks (and other git bits)
(core hook code)
&NHgithook::POST;
__END__
=for nhgitset NHgithook Infrastructure for NetHack git hooks.
=head1 DESCRIPTION
Perl module for infrastructure of NetHack Git hooks.
Buffers call information so multiple independent actions may be coded for
Git hooks and similar Git callouts.
Maintains C<dat/gitinfo.txt>.
Common routines for dealing with nethack.setupversion git config variable.
=head1 SETUP
Changing the C<$trace> and C<$tracefile> variables requires editing the
@@ -247,6 +393,9 @@ may be useful since multiple processes may be live at the same time.
Some features not well tested, especially under Windows.
Not well documented, but almost no one needs to change (or even call)
this code.
=head1 AUTHOR
Kenneth Lorber (keni@his.com)

View File

@@ -17,24 +17,24 @@ my $dbgfile = ($^O eq "MSWin32") ? "$ENV{TEMP}.$$" : "/tmp/trace.$$";
open TRACE, ">>", $rawin?"/dev/tty":(($debug==0)? $sink : $dbgfile);
print TRACE "TEST TRACE\n";
if($debug){
print TRACE "START CLIENT ARGV:\n";
print TRACE "[0] $0\n";
my $x1;
for(my $x=0;$x<scalar @ARGV;$x++){
$x1 = $x+1;
print TRACE "[$x1] $ARGV[$x]\n";
}
print TRACE "ENV:\n";
foreach my $k (sort keys %ENV){
next unless ($k =~ m/^GIT_/);
print TRACE " $k => $ENV{$k}\n";
}
print TRACE "CWD: " . `pwd`;
&dumpfile($ARGV[0], "[0O]");
&dumpfile($ARGV[1], "[1A]");
&dumpfile($ARGV[2], "[2B]");
print TRACE "L=$ARGV[3]\n";
print TRACE "END\n";
print TRACE "START CLIENT ARGV:\n";
print TRACE "[0] $0\n";
my $x1;
for(my $x=0;$x<scalar @ARGV;$x++){
$x1 = $x+1;
print TRACE "[$x1] $ARGV[$x]\n";
}
print TRACE "ENV:\n";
foreach my $k (sort keys %ENV){
next unless ($k =~ m/^GIT_/);
print TRACE " $k => $ENV{$k}\n";
}
print TRACE "CWD: " . `pwd`;
&dumpfile($ARGV[0], "[0O]");
&dumpfile($ARGV[1], "[1A]");
&dumpfile($ARGV[2], "[2B]");
print TRACE "L=$ARGV[3]\n";
print TRACE "END\n";
}
my $mark_len = $ARGV[3];
@@ -47,37 +47,37 @@ my $mark_end = '>' x $mark_len;
my $PREFIX;
# pick up the prefix for substitutions in this repo
if($rawin){
$PREFIX = "TEST";
$PREFIX = "TEST";
} else {
$PREFIX = `git config --local --get nethack.substprefix`;
chomp($PREFIX);
$PREFIX = `git config --local --get nethack.substprefix`;
chomp($PREFIX);
}
my @out;
my $cntout;
if($rawin){
@out = <STDIN>;
@out = <STDIN>;
} else {
#system "git merge-file -p .... > temp
my $tags = "-L CURRENT -L ANCESTOR -L OTHER"; # XXX should "CURRENT" be "MINE"?
@out = `git merge-file -p $tags $ARGV[1] $ARGV[0] $ARGV[2]`;
#system "git merge-file -p .... > temp
my $tags = "-L CURRENT -L ANCESTOR -L OTHER"; # XXX should "CURRENT" be "MINE"?
@out = `git merge-file -p $tags $ARGV[1] $ARGV[0] $ARGV[2]`;
#NB: we don't check the exit value because it's useless
print TRACE "MERGE-FILE START\n".join("",@out)."MERGE-FILE END\n";
print TRACE "MERGE-FILE START\n".join("",@out)."MERGE-FILE END\n";
}
($cntout,@out) = &edit_merge(@out);
if($rawin){
print "COUNT: $cntout\n";
print @out;
print "COUNT: $cntout\n";
print @out;
} else {
# spit @out to $ARGV[1] (careful: what about EOL character?)
open OUT, ">$ARGV[1]" or die "Can't open $ARGV[1]";
print OUT @out;
close OUT;
# spit @out to $ARGV[1] (careful: what about EOL character?)
open OUT, ">$ARGV[1]" or die "Can't open $ARGV[1]";
print OUT @out;
close OUT;
print TRACE "WRITING START ($ARGV[1])\n".join("",@out)."WRITING END\n";
&dumpfile($ARGV[1], "READBACK");
print TRACE "WRITING START ($ARGV[1])\n".join("",@out)."WRITING END\n";
&dumpfile($ARGV[1], "READBACK");
}
print TRACE "COUNT: $cntout\n";
@@ -95,37 +95,37 @@ exit( ($cntout>0) ? 1 : 0);
# keep failing so we don't need to keep changing the setup while building this script
sub dumpfile {
my($file, $tag) = @_;
print TRACE "FILE $tag START\n";
print TRACE `hexdump -C $file`;
print TRACE "FILE END\n";
my($file, $tag) = @_;
print TRACE "FILE $tag START\n";
print TRACE `hexdump -C $file`;
print TRACE "FILE END\n";
}
sub edit_merge {
my(@input) = @_;
# $::count is a bit ugly XXX
local $::count = 0; # we need the number of conflicts for exit()
my @out;
my(@input) = @_;
# $::count is a bit ugly XXX
local $::count = 0; # we need the number of conflicts for exit()
my @out;
local $_;
while($_ = shift @input){
if(m/^$mark_start /){
print TRACE "FOUND A CONFLICT\n";
my @conflict;
push(@conflict, $_);
while($_ = shift @input){
push(@conflict, $_);
if(m/^$mark_end /){
last;
}
}
push(@out, &edit_conflict(@conflict));
} else {
push(@out, $_);
local $_;
while($_ = shift @input){
if(m/^$mark_start /){
print TRACE "FOUND A CONFLICT\n";
my @conflict;
push(@conflict, $_);
while($_ = shift @input){
push(@conflict, $_);
if(m/^$mark_end /){
last;
}
}
push(@out, &edit_conflict(@conflict));
} else {
push(@out, $_);
}
print TRACE "RETURN count=$::count\n";
return($::count, @out);
}
print TRACE "RETURN count=$::count\n";
return($::count, @out);
}
sub edit_conflict {
@@ -305,41 +305,41 @@ print TRACE "MVM: -$varname-$oursval-$theirval-\n";
package PREFIX;
# Resolve the conflict of a single var's 2 values. Return undef to leave the conflict.
sub Date {
my($PREFIX, $varname, $mine, $theirs) = @_;
my $m = ($mine =~ m/(\d+)/)[0];
my $t = ($theirs =~ m/(\d+)/)[0];
return undef unless ($m>0) && ($t>0);
my($PREFIX, $varname, $mine, $theirs) = @_;
my $m = ($mine =~ m/(\d+)/)[0];
my $t = ($theirs =~ m/(\d+)/)[0];
return undef unless ($m>0) && ($t>0);
return "\$$PREFIX-$varname: " . (($m>$t)?$mine:$theirs) .' $';
return "\$$PREFIX-$varname: " . (($m>$t)?$mine:$theirs) .' $';
}
#sub Header {
#sub Author {
sub Branch {
my($PREFIX, $varname, $mine, $theirs) = @_;
$mine =~ s/^\s+//; $mine =~ s/\s+$//;
$theirs =~ s/^\s+//; $theirs =~ s/\s+$//;
return "\$$PREFIX-$varname: $mine \$" if(length $mine);
return "\$$PREFIX-$varname: $theirs \$" if(length $theirs);
return "\$$PREFIX-$varname\$" if(length $theirs);
my($PREFIX, $varname, $mine, $theirs) = @_;
$mine =~ s/^\s+//; $mine =~ s/\s+$//;
$theirs =~ s/^\s+//; $theirs =~ s/\s+$//;
return "\$$PREFIX-$varname: $mine \$" if(length $mine);
return "\$$PREFIX-$varname: $theirs \$" if(length $theirs);
return "\$$PREFIX-$varname\$" if(length $theirs);
}
sub Revision {
my($PREFIX, $varname, $mine, $theirs) = @_;
my($m) = ($mine =~ m/1.(\d+)/);
my($t) = ($theirs =~ m/1.(\d+)/);
if($m > 0 && $t > 0){
my $q = ($m > $t) ? $m : $t;
return "\$$PREFIX-$varname: 1.$q \$";
}
if($m > 0){
return "\$$PREFIX-$varname: 1.$m \$";
}
if($t > 0){
return "\$$PREFIX-$varname: 1.$t \$";
}
return "\$$PREFIX-$varname\$";
my($PREFIX, $varname, $mine, $theirs) = @_;
my($m) = ($mine =~ m/1.(\d+)/);
my($t) = ($theirs =~ m/1.(\d+)/);
if($m > 0 && $t > 0){
my $q = ($m > $t) ? $m : $t;
return "\$$PREFIX-$varname: 1.$q \$";
}
if($m > 0){
return "\$$PREFIX-$varname: 1.$m \$";
}
if($t > 0){
return "\$$PREFIX-$varname: 1.$t \$";
}
return "\$$PREFIX-$varname\$";
}
__END__
@@ -396,3 +396,17 @@ TEST 8:
===
/* NetHack 3.7 objnam.c $TEST-Date: 1426977394 2015/03/21 22:36:34 $ $TEST-Branch: master $:$TEST-Revision: 1.108 $ */
>>> d3
=for nhgitset NHsubst NetHack merge driver
=head1 NAME
C<NHsubst> - NetHack merge driver
=head1 SYNOPSIS
(called from C<git>, do not invoke directly)
=head1 DESCRIPTION
This is invoked by git through .git/config.

View File

@@ -3,6 +3,8 @@
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed. See license for details.
# Not in use as of v3, but could come back in the future.
# clean/smudge filter for handling substitutions
use strict;
@@ -54,9 +56,9 @@ if($ARGV[0] eq "--clean"){
exit 1;
}
# XXX for now, there isn't any - if we get called, we subst. No options for now.
# XX for now, there isn't any - if we get called, we subst. No options for now.
# get relevant config info
#XXX
#XX
#git check-attr -a $ARGV[1]
# Process stdin to stdout.
@@ -109,7 +111,7 @@ sub Date {
my($val, $mode, $submode) = @_;
if($mode eq "c"){
if($submode==0){
# we add this to make merge easier for now XXX
# we add this to make merge easier for now XX
my $now = time; # not %s below - may not be portable
# YYYY/MM/DD HH:MM:SS
$val = "$now " . strftime("%Y/%m/%d %H:%M:%S", gmtime($now));

79
DEVEL/hooksdir/nhhelp Normal file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/perl
# $NHDT-Date: 1730238507 2024/10/29 21:48:27 $ $NHDT-Brev: keni-gitset:1.0 $
# Copyright (c) 2024 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed. See license for details.
# This deals with a git problem: there is no way to do:
# git help alias-name
# (yes, that will show the definition of the alias, but not show an actual
# help document).
#
# So we implement this:
# nhhelp
# With no arguments, run perldoc on this file.
# nhhelp FOO
# Run perldoc on .git/hooks/FOO (if it exists).
if($#ARGV == -1){
system("perldoc $0")==0 or die "perldoc error: $!\n";
exit 0;
}
if($#ARGV == 0){
if($ARGV[0] eq "-a"){
&listhelp;
exit 0;
}
chomp(my $target = `git config nethack.aliashelp.$ARGV[0]`);
my $file = ".git/hooks/$target";
if(-f $file){
system("perldoc $file")==0 or die "perldoc error: $!\n";
} else {
print "Unknown name '$ARGV[0]'\n";
&usage;
}
exit 0;
}
&usage;
exit 0;
sub usage {
print <<E_O_M;
usage: git nhhelp [<nhcmd>|-a]
E_O_M
}
sub listhelp {
print "nhhelp is available for:\n";
my @namelist = `git config --name-only --get-regexp 'nethack.aliashelp.*'`;
print "NAMELIST $?\n" if($?);
@namelist = map {
if(m/^nethack.aliashelp.(.*)/){
chomp(my $x = `git config 'nethack.aliasdesc.$1'`);
sprintf("%-12s %s",$1,$x);
}
} sort @namelist;
print " " . join("\n ", @namelist)."\n";
exit 0;
}
__END__
=for nhgitset nhhelp Help on NetHack git commands
=head1 NAME
C<nhhelp> - NetHack git command for help on NetHack git commands
=head1 SYNOPSIS
C<git nhhelp [nhcmd|-a]>
=head1 DESCRIPTION
With no arguments, print this message.
With one argument matching a NetHack git command, print the
documentation for that command.
With the argument C<-a>, show all available nhhelp topics with one line
summaries.

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
#!/usr/bin/perl
# $NHDT-Date: 1524689631 2018/04/25 20:53:51 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.1 $
# NetHack 3.7 post-applypatch $NHDT-Date: 1524689631 2018/04/25 20:53:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1 $
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed. See license for details.
@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -24,10 +24,15 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;
&NHgithook::nhversioning;
eval { &NHgithook::nhversioning unless($nogithook) };
warn "nhversioning failed: $@" if($@);
&NHgithook::POST;
exit 0;

View File

@@ -24,10 +24,17 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;
&NHgithook::nhversioning;
eval { &NHgithook::nhversioning unless($nogithook) };
warn "nhversioning failed: $@" if($@);
&NHgithook::POST;
exit 0;

View File

@@ -25,10 +25,15 @@ BEGIN {
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;
&NHgithook::nhversioning;
eval { &NHgithook::nhversioning(1) unless($nogithook) };
warn "nhversioning failed: $@" if($@);
&NHgithook::POST;
exit 0;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::saveSTDIN;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::saveSTDIN;

View File

@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -1,5 +1,5 @@
#!/usr/bin/perl
# $NHDT-Date: 1524689633 2018/04/25 20:53:53 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.1 $
# NetHack 3.7 prepare-commit-msg $NHDT-Date: 1524689633 2018/04/25 20:53:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1 $
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed. See license for details.
@@ -24,7 +24,11 @@ BEGIN {
chomp $gitdir;
push(@INC, $gitdir.$PDS."hooks");
}
use NHgithook;
eval {use NHgithook;};
if($@){
warn "loading NHgithook failed: $@";
$nogithook = 1;
}
#STARTUP-END
&NHgithook::PRE;

View File

@@ -3,32 +3,29 @@
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
# NetHack may be freely redistributed. See license for details.
# value of nethack.setupversion we will end up with when this is done
# version 1 is reserved for repos checked out before versioning was added
my $version_new = 3;
my $version_old = 0; # current version, if any (0 is no entry ergo new repo)
use Cwd;
use Getopt::Std;
# Activestate Perl doesn't include File::Spec. Grr.
BEGIN {
eval "require File::Spec::Functions";
if($@){
die <<E_O_M;
eval "require File::Spec::Functions";
if($@){
die <<E_O_M;
File::Spec not found. (If you are running ActiveState Perl please run:
cpan File::Spec
and re-run this program.
cpan File::Spec
then re-run this program.
E_O_M
}
File::Spec::Functions->import;
}
File::Spec::Functions->import;
}
exit 1 unless(getopts('nvf')); # TODO: this can probably have better output
# OS hackery
my $DS = quotemeta('/'); # Directory Separator (for regex)
my $DSP = '/'; # ... for printing
BEGIN {
# OS hackery
$DS = quotemeta('/'); # Directory Separator (for regex)
$PDS = '/'; # ... for printing
# Temporarily disabled; there's something weird about msys
# msys: POSIXish over a Windows filesystem (so / not \ but \r\n not \n).
#if($^O eq "msys"){
@@ -37,78 +34,129 @@ my $DSP = '/'; # ... for printing
# # NB: We don't need to do anything about File::Spec. It doesn't know
# # about msys but it defaults to Unix, so we'll be ok.
#}
if($^O eq "MSWin32"){
if($^O eq "MSWin32"){
$DS = quotemeta('\\');
$DSP = '\\';
$PDS = '\\';
}
# Fix @INC so we can 'use NHgithook' before it's installed.
# Set $is_sourcerepo while we're at it - same logic.
{
# Special case for running nhgitset against a different repo.
# Must preceed the normal case!
# NB: we use $DEVhooksdir later in the program
$DEVhooksdir = ($0 =~ m!^(.*)$DS!)[0];
chomp($DEVhooksdir);
$DEVhooksdir .= $PDS."hooksdir";
push(@INC, $DEVhooksdir) if(-d $DEVhooksdir);
# This one is for the normal case (in NHsource)
my $topdir = `git rev-parse --show-toplevel`;
chomp $topdir;
$topdir .= "${PDS}DEVEL${PDS}hooksdir";
push(@INC, $topdir) if(-d $topdir);
$is_sourcerepo = 0;
$is_sourcerepo = 1 if(-d $topdir);
}
}
use NHgithook;
# current (installed) version, if any (0 is no entry ergo new repo)
my $version_old = NHgithook::version_in_git;
# version this program will install
my($version_new,$message_new) = NHgithook::version_in_devel;
if(0==$version_new and !opt_f){
# Edge case: this repo has been set up using version >= 4, but now we're running
# nhgitset after checking out DEVEL supporting version <4.
# Use -f to recover from broken DEVEL code.
print STDERR "DEVEL has version <4 code but version >=4 code already installed. Stopping.\n";
print STDERR "(If you need to reinstall the old code, rerun with -f\n";
exit 0;
}
die "Valid version not found in DEVEL/VERSION" unless(0==$version_new or $version_new >= 4);
# make sure we're at the top level of a repo
if(! -d ".git"){
die "This is not the top level of a git repository.\n";
die "This is not the top level of a git repository.\n";
}
my $vtemp = `git config --local --get nethack.setupversion`;
chomp($vtemp);
if($vtemp > 0){
$version_old = 0+$vtemp;
if($version_old != $version_new){
print STDERR "Migrating from setup version $version_old to $version_new\n" if($opt_v);
}
if($version_old >= $version_new and !opt_f){
print STDERR "Nothing to do.\n";
exit 0;
}
# legacy check:
if(length $vtemp == 0){
if(`git config --get merge.NHsubst.name` =~ m/^Net/){
$version_old = 1;
print STDERR "Migrating to setup version 1\n" if($opt_v);
if($version_old > 0){
if($version_old != $version_new){
print STDERR "Migrating from setup version $version_old to $version_new\n";
if(length $message_new){
print STDERR "Additional information:\n$message_new\n";
}
}
}
# legacy check:
if(length $version_old == 0){
if(`git config --get merge.NHsubst.name` =~ m/^Net/){
$version_old = 1;
print STDERR "Migrating to setup version 1\n" if($opt_v);
}
}
my $gitadddir = `git config --get nethack.gitadddir`;
chomp($gitadddir);
if(length $gitadddir){
if(! -d $gitadddir){
die "nethack.gitadddir has invalid value '$gitadddir'\n";
}
if(! -d $gitadddir){
die "nethack.gitadddir has invalid value '$gitadddir'\n";
}
}
print STDERR "nethack.gitadddir=$gitadddir\n" if($opt_v);
# This is (relatively) safe because we know we're at R in R/DEVEL/nhgitset.pl
my $srcdir = ($0 =~ m!^(.*)$DS!)[0];
#XXX do I really want a full path for srcdir? how badly?
if(! -f catfile($srcdir, 'nhgitset.pl')){
die "I can't find myself in '$srcdir'\n";
die "I can't find myself in '$srcdir'\n";
}
print STDERR "Copying from: $srcdir\n" if($opt_v);
if($opt_f || $version_old==0){
print STDERR "Configuring line endings\n" if($opt_v);
unlink catfile('.git','index') unless($opt_n);
system("git reset") unless($opt_n);
system("git config --local core.safecrlf true") unless($opt_n);
system("git config --local core.autocrlf false") unless($opt_n);
print STDERR "Configuring line endings\n" if($opt_v);
system("git reset") unless($opt_n);
&add_config('core.safecrlf', 'true') unless($opt_n);
&add_config('core.autocrlf', 'false') unless($opt_n);
} elsif($version_old <2){
my $xx = `git config --get --local core.safecrlf`;
if($xx !~ m/true/){
print STDERR "\nNeed to 'rm .git${DSP}index;git reset'.\n";
print STDERR " When ready to proceed, re-run with -f flag.\n";
exit 2;
}
my $xx = `git config --get --local core.safecrlf`;
if($xx !~ m/true/){
print STDERR "\nNeed to 'rm .git${PDS}index;git reset'.\n";
print STDERR " When ready to proceed, re-run with -f flag.\n";
exit 2;
}
}
print STDERR "Installing aliases\n" if($opt_v);
$addpath = catfile(curdir(),'.git','hooks','NHadd');
&add_alias('nhadd', "!$addpath add");
&add_help('nhadd', 'NHadd');
&add_alias('nhcommit', "!$addpath commit");
&add_help('nhcommit', 'NHadd');
my $nhsub = catfile(curdir(),'.git','hooks','nhsub');
&add_alias('nhsub', "!$nhsub");
&add_help('nhsub', 'nhsub');
&add_alias('nhhelp', '!'.catfile(curdir(),'.git','hooks','nhhelp'));
&add_help('nhhelp', 'nhhelp');
&add_help('NHsubst', 'NHsubst');
&add_help('NHgithook', 'NHgithook.pm');
print STDERR "Installing filter/merge\n" if($opt_v);
# XXXX need it in NHadd to find nhsub???
# removed at version 3
#print STDERR "Installing filter/merge\n" if($opt_v);
#if($^O eq "MSWin32"){
# $cmd = '.git\\\\hooks\\\\NHtext';
#} else {
@@ -117,170 +165,183 @@ print STDERR "Installing filter/merge\n" if($opt_v);
#&add_config('filter.NHtext.clean', "$cmd --clean %f");
#&add_config('filter.NHtext.smudge', "$cmd --smudge %f");
if($version_old == 1 or $version_old == 2){
print STDERR "Removing filter.NHtext\n" if($opt_v);
system('git','config','--unset','filter.NHtext.clean') unless($opt_n);
system('git','config','--unset','filter.NHtext.smudge') unless($opt_n);
system('git','config','--remove-section','filter.NHtext') unless($opt_n);
print STDERR "Removing filter.NHtext\n" if($opt_v);
system('git','config','--unset','filter.NHtext.clean') unless($opt_n);
system('git','config','--unset','filter.NHtext.smudge') unless($opt_n);
system('git','config','--remove-section','filter.NHtext') unless($opt_n);
print STDERR "Removing NHtext\n" if($opt_v);
unlink catfile(curdir(),'.git','hooks','NHtext') unless($opt_n);
print STDERR "Removing NHtext\n" if($opt_v);
unlink catfile(curdir(),'.git','hooks','NHtext') unless($opt_n);
}
&add_config('nethack.setuppath',$srcdir);
&add_config('nethack.is-sourcerepo',0+$is_sourcerepo);
$cmd = catfile(curdir(),'.git','hooks','NHsubst');
&add_config('merge.NHsubst.name', 'NetHack Keyword Substitution');
&add_config('merge.NHsubst.driver', "$cmd %O %A %B %L");
print STDERR "Running directories\n" if($opt_v);
foreach my $dir ( glob("$srcdir$DS*") ){
next unless(-d $dir);
# copy directories into .git (right now that's just hooks
my @gitadd = length($gitadddir)?glob("$gitadddir$DS*"):undef;
foreach my $dir ( (glob("$srcdir$DS*"), @gitadd) ){
next unless(-d $dir);
my $target = catfile($dir, 'TARGET');
next unless(-f $target);
my $target = catfile($dir, 'TARGET');
next unless(-f $target);
open TARGET, '<', $target or die "$target: $!";
my $targetpath = <TARGET>;
# still have to eat all these line endings under msys, so instead of chomp use this:
$targetpath =~ s![\r\n]!!g;
close TARGET;
print STDERR "Directory $dir -> $targetpath\n" if($opt_v);
open TARGET, '<', $target or die "$target: $!";
my $targetpath = <TARGET>;
# still have to eat all these line endings under msys, so instead of chomp use this:
$targetpath =~ s![\r\n]!!g;
close TARGET;
print STDERR "Directory $dir -> $targetpath\n" if($opt_v);
my $enddir = $dir;
$enddir =~ s!.*$DS!!;
if(! &process_override($enddir, "INSTEAD")){
&process_override($enddir, "PRE");
my $fnname = "do_dir_$enddir";
if(defined &$fnname){
&$fnname($dir, $targetpath);
}
&process_override($enddir, "POST");
my $enddir = $dir;
$enddir =~ s!.*$DS!!;
if(! &process_override($enddir, "INSTEAD")){
&process_override($enddir, "PRE");
my $fnname = "do_dir_$enddir";
if(defined &$fnname){
&$fnname($dir, $targetpath);
}
&process_override($enddir, "POST");
}
}
&check_prefix; # for variable substitution
&check_gitvars; # for variable substitution
if($version_old != $version_new){
print STDERR "Setting version to $version_new\n" if($opt_v);
if(! $opt_n){
system("git config nethack.setupversion $version_new");
if($?){
die "Can't set nethack.setupversion $version_new: $?,$!\n";
}
}
if($version_old != $version_new or $opt_f){
print STDERR "Setting version to $version_new\n" if($opt_v);
NHgithook::version_set_git($version_new) if(! $opt_n);
}
exit 0;
sub process_override {
my($srcdir, $plname) = @_;
return 0 unless(length $gitadddir);
sub add_help {
my($cmd, $file) = @_;
my $plpath = catfile($gitadddir, $srcdir, $plname);
#print STDERR " ",catfile($srcdir, $plname),"\n"; # save this for updating docs - list of overrides
return 0 unless(-x $plpath);
print STDERR "Running $plpath\n" if($opt_v);
# current directory is top of target repo
unless($opt_n){
system("$plpath $opt_v") and die "Callout $plpath failed: $?\n";
&add_config("nethack.aliashelp.$cmd", $file);
# pull out =for nhgitset CMD description...
my $desc = '';
open my $fh, "<", "$DEVhooksdir/$file";
if($fh){
while(<$fh>){
m/^=for\s+nhgitset\s+\Q$cmd\E\s+(.*)/ && do {
$desc = $1;
last;
}
}
return 1;
close $fh;
} else {
warn "Can't open: '$DEVhooksdir/$file' ($!)\n";
}
if(length $desc){
&add_config("nethack.aliasdesc.$cmd", $desc);
} else {
&add_config("nethack.aliasdesc.$cmd", "(no description available)");
}
}
sub process_override {
my($srcdir, $plname) = @_;
return 0 unless(length $gitadddir);
my $plpath = catfile($gitadddir, $srcdir, $plname);
return 0 unless(-x $plpath);
print STDERR "RunningOverride $plpath\n" if($opt_v);
# current directory is top of target repo
unless($opt_n){
system("$plpath $opt_v") and die "Callout $plpath failed: $?\n";
}
return 1;
}
sub add_alias {
my($name, $def) = @_;
&add_config("alias.$name",$def);
my($name, $def) = @_;
&add_config("alias.$name",$def);
}
sub add_config {
my($name, $val) = @_;
system('git', 'config', '--local', $name, $val) unless($opt_n);
my($name, $val) = @_;
system('git', 'config', '--local', $name, $val) unless($opt_n);
}
sub check_gitvars {
&check_prefix("substprefix");
&check_prefix("projectname");
}
sub check_prefix {
my $lcl = `git config --local --get nethack.substprefix`;
chomp($lcl);
if(0==length $lcl){
my $other = `git config --get nethack.substprefix`;
chomp($other);
if(0==length $other){
print STDERR "ERROR: nethack.substprefix is not set anywhere. Set it and re-run.\n";
exit 2;
} else {
&add_config('nethack.substprefix', $other);
print STDERR "Copying prefix '$other' to local repository.\n" if($opt_v);
}
$lcl = $other; # for display below
my $which = $_[0];
my $lcl = `git config --local --get nethack.$which`;
chomp($lcl);
if(0==length $lcl){
my $other = `git config --get nethack.$which`;
chomp($other);
if(0==length $other){
print STDERR "ERROR: nethack.$which is not set anywhere. Set it and re-run.\n";
exit 2;
} else {
&add_config('nethack.$which', $other);
print STDERR "Copying prefix '$other' to local repository.\n" if($opt_v);
}
print "\n\nUsing prefix '$lcl' - PLEASE MAKE SURE THIS IS CORRECT\n\n";
$lcl = $other; # for display below
}
print "Using $which '$lcl' - PLEASE MAKE SURE THIS IS CORRECT\n";
}
sub do_dir_DOTGIT {
if(1){
# We are NOT going to mess with config now.
return;
} else {
my($srcdir, $targetdir) = @_;
#warn "do_dir_DOTGIT($srcdir, $targetdir)\n";
my $cname = "$srcdir/config";
if(-e $cname){
print STDERR "Appending to .git/config\n" if($opt_v);
open CONFIG, ">>.git/config" or die "open .git/config: $!";
open IN, "<", $cname or die "open $cname: $!";
my @data = <IN>;
print CONFIG @data;
close IN;
close CONFIG;
} else {
print STDERR " Nothing to add to .git/config\n" if($opt_v);
}
# XXX are there other files in .git that we might want to handle?
# So just in case:
for my $file ( glob("$srcdir/*") ){
next if( $file =~ m!.*/TARGET$! );
next if( $file =~ m!.*/config$! );
die "ERROR: no handler for $file\n";
}
}
my($srcdir, $targetdir) = @_;
# not currently in use so just bail
return;
# are there other files in .git that we might want to handle?
# So just in case:
for my $file ( glob("$srcdir/*") ){
next if( $file =~ m!.*/TARGET$! );
next if( $file =~ m!.*/config$! );
die "ERROR: no handler for $file\n";
}
}
sub do_dir_hooksdir {
my($srcdir, $targetdir) = @_;
my($srcdir, $targetdir) = @_;
unless (-d $targetdir){
unless (-d $targetdir){
# Older versions of git, when cloning a repo and
# the expected source templates directory does not
# exist, does not create .git/hooks. So do it here.
mkdir $targetdir;
print STDERR "WARNING: .git/hooks had to be created.\n";
print STDERR " You may want to update git.\n";
mkdir $targetdir;
print STDERR "WARNING: .git/hooks had to be created.\n";
print STDERR " You may want to update git.\n";
}
for my $path ( glob("$srcdir$DS*") ){
next if( $path =~ m!.*${DS}TARGET$! );
my $file = $path;
$file =~ s!.*$DS!!;
$file = catfile($targetdir, $file);
next if($opt_n);
open IN, "<", $path or die "Can't open $path: $!";
open OUT, ">", "$file" or die "Can't open $file: $!";
while(<IN>){
print OUT;
}
close OUT;
close IN;
for my $path ( glob("$srcdir$DS*") ){
next if( $path =~ m!.*${DS}TARGET$! );
my $file = $path;
$file =~ s!.*$DS!!;
$file = catfile($targetdir, $file);
next if($opt_n);
open IN, "<", $path or die "Can't open $path: $!";
open OUT, ">", "$file" or die "Can't open $file: $!";
while(<IN>){
print OUT;
}
close OUT;
close IN;
if(! -x $file){
chmod 0755 ,$file;
}
if(! -x $file){
chmod 0755 ,$file;
}
}
}
__END__
@@ -308,11 +369,29 @@ nhgitset.pl).
The following options are available:
B<-f> Force. Do not use this unless the program requests it.
=over
B<-n> Make no changes.
=item B<-f>
B<-v> Verbose output.
Force. Do not use this unless the program requests it or the hooks are broken.
=back
=over
=item B<-n>
Dry-run - make no changes.
=back
=over
=item B<-v>
Verbose output.
=back
=head1 CONFIG
@@ -329,8 +408,35 @@ nethack.gitadddir
nethack.setupversion
The version for nhgitset.pl and friends; has no relationship
to NetHack version numbers.
nethack.substprefix
The prefix this repo uses for variable substitution.
nethack.projectname
The name of the game being built - see C<Project()>.
nethack.is-sourcerepo
Does this repo contain NetHack source code? (1 = yes, 0 = no)
nethack.setuppath
Path to (and including) the DEVEL directory used including the
copy of nhgitset.pl used to set up this repo.
nethack.aliashelp.*
The last element of the variable is the name used with C<git nhhelp>
and the value is the name of a file to display with C<perldoc>.
nethack.aliasdesc.*
The last element of the variable is the name used with C<git nhhelp>
and the value is short help displayed with C<git nhhelp -a>.
=head1 EXIT STATUS

View File

@@ -1,4 +1,4 @@
.\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.574 $ $NHDT-Date: 1711040379 2024/03/21 16:59:39 $
.\" $NHDT-Branch: keni-gitset $:$NHDT-Revision: 1.593 $ $NHDT-Date: 1730681007 2024/11/04 00:43:27 $
.\"
.\" This is an excerpt from the 'roff' man page from the 'groff' package.
.\"+--
@@ -46,8 +46,8 @@
.ds vr NetHack 3.7.0
.ds f0 \*(vr
.ds f1 \" empty
.\"DO NOT REMOVE NH_DATESUB .ds f2 DATE(%B %-d, %Y)
.ds f2 September 13, 2024
.\"DO NOT REMOVE NH_DATESUB .ds f2 Date(%B %-d, %Y)
.ds f2 November 4, 2024
.
.\" A note on some special characters:
.\" \(lq = left double quote
@@ -6675,3 +6675,4 @@ Izchak Miller Mike Stephenson
.sm "Brand and product names are trademarks or registered trademarks \
of their respective holders."
.\"EOF
changes

View File

@@ -47,7 +47,7 @@
%.au
\author{Original version - Eric S. Raymond\\
(Edited and expanded for 3.7.0 by Mike Stephenson and others)}
%DO NOT REMOVE NH_DATESUB \date{DATE(%B %-d, %Y)}
%DO NOT REMOVE NH_DATESUB \date{Date(%B %-d, %Y)}
\date{September 13, 2024}
\maketitle

View File

@@ -1,16 +1,16 @@
.\" $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.12 $ $NHDT-Date: 1693253316 2023/08/28 20:08:36 $
.\"DO NOT REMOVE NH_DATESUB .TH DLB 6 "DATE(%-d %B %Y)" NETHACK
.TH DLB 6 "8 February 2022" NETHACK
.\" $NHDT-Branch: keni-gitset $:$NHDT-Revision: 1.13 $ $NHDT-Date: 1730949315 2024/11/06 22:15:15 $
.\"DO NOT REMOVE NH_DATESUB .TH DLB 6 "DATE(%-d %B %Y)" Project(uc)
.TH DLB 6 "DATE(%-d %B %Y)" NETHACK
.\"DO NOT REMOVE NH_DATESUB .ds Nd DATE(%Y)
.ds Nd 2022
.ds Nd DATE(%Y)
.de NB
.ds Nb \\$2
..
.de NR
.ds Nr \\$2
..
.NB $NHDT-Branch: NetHack-3.7 $
.NR $NHDT-Revision: 1.12 $
.NB $NHDT-Branch: keni-gitset $
.NR $NHDT-Revision: 1.13 $
.ds Na Kenneth Lorber
.SH NAME
dlb \- NetHack data librarian

View File

@@ -1,4 +1,4 @@
.\"DO NOT REMOVE NH_DATESUB .TH MAKEDEFS 6 "DATE(%-d %B %Y)" NETHACK
.\"DO NOT REMOVE NH_DATESUB .TH MAKEDEFS 6 "DATE(%-d %B %Y)" Project(uc)
.TH MAKEDEFS 6 "8 February 2022" NETHACK
.\"DO NOT REMOVE NH_DATESUB .ds Nd DATE(%Y)
.ds Nd 2022

View File

@@ -1,4 +1,4 @@
.\"DO NOT REMOVE NH_DATESUB .TH NETHACK 6 "DATE(%-d %B %Y)" NETHACK
.\"DO NOT REMOVE NH_DATESUB .TH NETHACK 6 "DATE(%-d %B %Y)" Project(uc)
.TH NETHACK 6 "21 February 2022" NETHACK
.\"DO NOT REMOVE NH_DATESUB .ds Nd DATE(%Y)
.ds Nd 2022

View File

@@ -1,4 +1,4 @@
.\"DO NOT REMOVE NH_DATESUB .TH RECOVER 6 "DATE(%-d %B %Y)" NETHACK
.\"DO NOT REMOVE NH_DATESUB .TH RECOVER 6 "DATE(%-d %B %Y)" Project(uc)
.TH RECOVER 6 "8 February 2022" NETHACK
.\"DO NOT REMOVE NH_DATESUB .ds Nd DATE(%Y)
.ds Nd 2022

View File

@@ -11,6 +11,8 @@ Prerequisite Requirements:
pacman -S make
pacman -S vim (or your editor of choice)
pacman -S man (otherwise "git help foo" will not work)
pacman -S perl-doc (otherwise "git nhhelp foo" will not work,
so only needed if you use nhgitset.pl)
o Lua
o pdcursesmod (Only required if curses interface support is desired)
Instructions for obtaining these are later in this file.