This commit is contained in:
Christoph Oelckers 2013-06-25 09:23:11 +02:00
commit 93e040b322
5 changed files with 29 additions and 38 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.suo
*.pdb
*.ilk
*.aps
/Release
/wadsrc_wad
*.user

View file

@ -505,7 +505,7 @@ endif( BACKPATCH )
get_target_property( UPDATEREVISION_EXE updaterevision LOCATION )
add_custom_target( revision_check ALL
COMMAND ${UPDATEREVISION_EXE} . src/gitinfo.h
COMMAND ${UPDATEREVISION_EXE} src/gitinfo.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS updaterevision )

View file

@ -859,10 +859,10 @@ static void ChangeSpy (int changespy)
// Otherwise, cycle to the next player.
bool checkTeam = !demoplayback && deathmatch;
int pnum = int(players[consoleplayer].camera->player - players);
if (changespy == SPY_CANCEL) {
pnum = consoleplayer;
} else {
int pnum = consoleplayer;
if (changespy != SPY_CANCEL)
{
pnum = int(players[consoleplayer].camera->player - players);
int step = (changespy == SPY_NEXT) ? 1 : -1;
do

View file

@ -14,6 +14,11 @@
#include <ctype.h>
#include <errno.h>
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif
// Used to strip newline characters from lines read by fgets.
void stripnl(char *str)
{
@ -29,17 +34,16 @@ void stripnl(char *str)
int main(int argc, char **argv)
{
char *name;
char vertag[64], lastlog[64], lasthash[64], run[256], *hash = NULL;
char vertag[64], lastlog[64], lasthash[64], *hash = NULL;
FILE *stream = NULL;
int gotrev = 0, needupdate = 1;
vertag[0] = '\0';
lastlog[0] = '\0';
if (argc != 3)
if (argc != 2)
{
fprintf(stderr, "Usage: %s <repository directory> <path to gitinfo.h>\n", argv[0]);
fprintf(stderr, "Usage: %s <path to gitinfo.h>\n", argv[0]);
return 1;
}
@ -47,33 +51,19 @@ int main(int argc, char **argv)
// on a tag, it returns that tag. Otherwise it returns <most recent tag>-<number of
// commits since the tag>-<short hash>.
// Use git log to get the time of the latest commit in ISO 8601 format and its full hash.
sprintf(run, "git describe --tags && git log -1 --format=%%ai*%%H", argv[1]);
if ((name = tempnam(NULL, "gitout")) != NULL)
stream = popen("git describe --tags && git log -1 --format=%ai*%H", "r");
if (NULL != stream)
{
#ifdef __APPLE__
// tempnam will return errno of 2 even though it is successful for our purposes.
errno = 0;
#endif
if((stream = freopen(name, "w+b", stdout)) != NULL &&
system(run) == 0 &&
errno == 0 &&
fseek(stream, 0, SEEK_SET) == 0 &&
fgets(vertag, sizeof vertag, stream) == vertag &&
fgets(lastlog, sizeof lastlog, stream) == lastlog)
if (fgets(vertag, sizeof vertag, stream) == vertag &&
fgets(lastlog, sizeof lastlog, stream) == lastlog)
{
stripnl(vertag);
stripnl(lastlog);
gotrev = 1;
}
}
if (stream != NULL)
{
fclose(stream);
remove(name);
}
if (name != NULL)
{
free(name);
pclose(stream);
}
if (gotrev)
@ -95,7 +85,7 @@ int main(int argc, char **argv)
hash = lastlog + 1;
}
stream = fopen (argv[2], "r");
stream = fopen (argv[1], "r");
if (stream != NULL)
{
if (!gotrev)
@ -119,7 +109,7 @@ int main(int argc, char **argv)
if (needupdate)
{
stream = fopen (argv[2], "w");
stream = fopen (argv[1], "w");
if (stream == NULL)
{
return 1;
@ -135,11 +125,11 @@ int main(int argc, char **argv)
"#define GIT_TIME \"%s\"\n",
hash, vertag, hash, lastlog);
fclose(stream);
fprintf(stderr, "%s updated to commit %s.\n", argv[2], vertag);
fprintf(stderr, "%s updated to commit %s.\n", argv[1], vertag);
}
else
{
fprintf (stderr, "%s is up to date at commit %s.\n", argv[2], vertag);
fprintf (stderr, "%s is up to date at commit %s.\n", argv[1], vertag);
}
return 0;

View file

@ -29,7 +29,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -152,7 +152,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -265,7 +265,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"
@ -372,7 +372,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Checking gitinfo.h..."
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src src/gitinfo.h"
CommandLine="&quot;$(OutDir)\updaterevision.exe&quot; src/gitinfo.h"
/>
<Tool
Name="VCCustomBuildTool"