mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-11 11:42:15 +00:00
- update revision via popen() (via GZDoom OS X)
This commit is contained in:
parent
394f21f71e
commit
e989e11f5c
1 changed files with 8 additions and 23 deletions
|
@ -29,8 +29,7 @@ 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;
|
||||||
|
|
||||||
|
@ -47,33 +46,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)
|
||||||
|
|
Loading…
Reference in a new issue