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 *.suo
*.pdb *.pdb
*.ilk *.ilk
*.aps
/Release /Release
/wadsrc_wad /wadsrc_wad
*.user *.user

View File

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

View File

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

View File

@ -14,6 +14,11 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif
// Used to strip newline characters from lines read by fgets. // Used to strip newline characters from lines read by fgets.
void stripnl(char *str) void stripnl(char *str)
{ {
@ -29,17 +34,16 @@ void stripnl(char *str)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char *name; char vertag[64], lastlog[64], lasthash[64], *hash = NULL;
char vertag[64], lastlog[64], lasthash[64], run[256], *hash = NULL;
FILE *stream = NULL; FILE *stream = NULL;
int gotrev = 0, needupdate = 1; int gotrev = 0, needupdate = 1;
vertag[0] = '\0'; vertag[0] = '\0';
lastlog[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; 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 // on a tag, it returns that tag. Otherwise it returns <most recent tag>-<number of
// commits since the tag>-<short hash>. // 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. // 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]); stream = popen("git describe --tags && git log -1 --format=%ai*%H", "r");
if ((name = tempnam(NULL, "gitout")) != NULL)
if (NULL != stream)
{ {
#ifdef __APPLE__ if (fgets(vertag, sizeof vertag, stream) == vertag &&
// 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) fgets(lastlog, sizeof lastlog, stream) == lastlog)
{ {
stripnl(vertag); stripnl(vertag);
stripnl(lastlog); stripnl(lastlog);
gotrev = 1; gotrev = 1;
} }
}
if (stream != NULL) pclose(stream);
{
fclose(stream);
remove(name);
}
if (name != NULL)
{
free(name);
} }
if (gotrev) if (gotrev)
@ -95,7 +85,7 @@ int main(int argc, char **argv)
hash = lastlog + 1; hash = lastlog + 1;
} }
stream = fopen (argv[2], "r"); stream = fopen (argv[1], "r");
if (stream != NULL) if (stream != NULL)
{ {
if (!gotrev) if (!gotrev)
@ -119,7 +109,7 @@ int main(int argc, char **argv)
if (needupdate) if (needupdate)
{ {
stream = fopen (argv[2], "w"); stream = fopen (argv[1], "w");
if (stream == NULL) if (stream == NULL)
{ {
return 1; return 1;
@ -135,11 +125,11 @@ int main(int argc, char **argv)
"#define GIT_TIME \"%s\"\n", "#define GIT_TIME \"%s\"\n",
hash, vertag, hash, lastlog); hash, vertag, hash, lastlog);
fclose(stream); 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 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; return 0;

View File

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