updaterevision/updaterevision.c

Sat, 12 Jul 2014 23:04:46 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 12 Jul 2014 23:04:46 +0300
changeset 133
dbbdb870c835
parent 123
ad33901eb4f6
child 135
8b9132fea327
permissions
-rw-r--r--

- changed all source files to use my correct legal name instead of my calling name

82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /* updaterevision.c
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 *
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Public domain. This program uses git commands command to get
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 * various bits of repository status for a particular directory
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * and writes it into a header file so that it can be used for a
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * project's versioning.
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
7 *
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
8 * 2014-03-30: [crimsondusk] added GIT_BRANCH, doubled buffer sizes
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 */
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 #define _CRT_SECURE_NO_DEPRECATE
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 #include <stdio.h>
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 #include <stdlib.h>
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 #include <string.h>
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 #include <ctype.h>
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 #include <errno.h>
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #ifdef _WIN32
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #define popen _popen
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #define pclose _pclose
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #endif
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 // Used to strip newline characters from lines read by fgets.
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 void stripnl(char *str)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 if (*str != '\0')
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 size_t len = strlen(str);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 if (str[len - 1] == '\n')
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 str[len - 1] = '\0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 int main(int argc, char **argv)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 {
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
39 char vertag[128], lastlog[128], lasthash[128], branch[128], *hash = NULL;
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 FILE *stream = NULL;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 int gotrev = 0, needupdate = 1;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 vertag[0] = '\0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 lastlog[0] = '\0';
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
45 branch[0] = '\0';
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 if (argc != 2)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 fprintf(stderr, "Usage: %s <path to gitinfo.h>\n", argv[0]);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 return 1;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 // Use git describe --tags to get a version string. If we are sitting directly
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 // on a tag, it returns that tag. Otherwise it returns <most recent tag>-<number of
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 // commits since the tag>-<short hash>.
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 // Use git log to get the time of the latest commit in ISO 8601 format and its full hash.
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
57 // [crimsondusk] Use git rev-parse --abbrev-ref HEAD to get the branch.
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
58 stream = popen("git describe --tags && git log -1 --format=%ai*%H && git rev-parse --abbrev-ref HEAD", "r");
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 if (NULL != stream)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 if (fgets(vertag, sizeof vertag, stream) == vertag &&
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
63 fgets(lastlog, sizeof lastlog, stream) == lastlog &&
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
64 fgets(branch, sizeof branch, stream) == branch)
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 stripnl(vertag);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 stripnl(lastlog);
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
68 stripnl(branch);
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 gotrev = 1;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 pclose(stream);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 if (gotrev)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 hash = strchr(lastlog, '*');
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 if (hash != NULL)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 *hash = '\0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 hash++;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 if (hash == NULL)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 fprintf(stderr, "Failed to get commit info: %s\n", strerror(errno));
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 strcpy(vertag, "<unknown version>");
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 lastlog[0] = '\0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 lastlog[1] = '0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 lastlog[2] = '\0';
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 hash = lastlog + 1;
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
92 strcpy(branch, "<unknown branch>");
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 stream = fopen (argv[1], "r");
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 if (stream != NULL)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 if (!gotrev)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99 { // If we didn't get a revision but the file does exist, leave it alone.
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 fclose (stream);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 return 0;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 // Read the revision that's in this file already. If it's the same as
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 // what we've got, then we don't need to modify it and can avoid rebuilding
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 // dependant files.
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 if (fgets(lasthash, sizeof lasthash, stream) == lasthash)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108 stripnl(lasthash);
123
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
109 if (strncmp(hash, lasthash + 3, 40) == 0 &&
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
110 strcmp(branch, lasthash + 44) == 0)
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 needupdate = 0;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 fclose (stream);
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 if (needupdate)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 stream = fopen (argv[1], "w");
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 if (stream == NULL)
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 {
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 return 1;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 fprintf(stream,
123
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
126 "// %s %s\n"
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 "//\n"
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 "// This file was automatically generated by the\n"
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 "// updaterevision tool. Do not edit by hand.\n"
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 "\n"
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 "#define GIT_DESCRIPTION \"%s\"\n"
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 "#define GIT_HASH \"%s\"\n"
118
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
133 "#define GIT_TIME \"%s\"\n"
e3361cf7cbf4 - doubled the buffer sizes of updaterevision to prevent GIT_BRANCH from being cut short and added GIT_BRANCH.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
134 "#define GIT_BRANCH \"%s\"\n",
123
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
135 hash, branch, vertag, hash, lastlog, branch);
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 fclose(stream);
123
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
137 fprintf(stderr, "%s updated to commit %s (%s).\n", argv[1], vertag, branch);
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 else
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 {
123
ad33901eb4f6 - added the branch name to the first line of the generated gitinfo.h to trigger regeneration on branch switch
Teemu Piippo <crimsondusk64@gmail.com>
parents: 118
diff changeset
141 fprintf (stderr, "%s is up to date at commit %s (%s).\n", argv[1], vertag, branch);
82
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 }
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 return 0;
841562f5a32f - added the public-domain updaterevision so I can have access to git stuff
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 }

mercurial