updaterevision/updaterevision.c

changeset 123
ad33901eb4f6
parent 118
e3361cf7cbf4
child 135
8b9132fea327
equal deleted inserted replaced
122:4ef6734f09ff 123:ad33901eb4f6
104 // what we've got, then we don't need to modify it and can avoid rebuilding 104 // what we've got, then we don't need to modify it and can avoid rebuilding
105 // dependant files. 105 // dependant files.
106 if (fgets(lasthash, sizeof lasthash, stream) == lasthash) 106 if (fgets(lasthash, sizeof lasthash, stream) == lasthash)
107 { 107 {
108 stripnl(lasthash); 108 stripnl(lasthash);
109 if (strcmp(hash, lasthash + 3) == 0) 109 if (strncmp(hash, lasthash + 3, 40) == 0 &&
110 strcmp(branch, lasthash + 44) == 0)
110 { 111 {
111 needupdate = 0; 112 needupdate = 0;
112 } 113 }
113 } 114 }
114 fclose (stream); 115 fclose (stream);
120 if (stream == NULL) 121 if (stream == NULL)
121 { 122 {
122 return 1; 123 return 1;
123 } 124 }
124 fprintf(stream, 125 fprintf(stream,
125 "// %s\n" 126 "// %s %s\n"
126 "//\n" 127 "//\n"
127 "// This file was automatically generated by the\n" 128 "// This file was automatically generated by the\n"
128 "// updaterevision tool. Do not edit by hand.\n" 129 "// updaterevision tool. Do not edit by hand.\n"
129 "\n" 130 "\n"
130 "#define GIT_DESCRIPTION \"%s\"\n" 131 "#define GIT_DESCRIPTION \"%s\"\n"
131 "#define GIT_HASH \"%s\"\n" 132 "#define GIT_HASH \"%s\"\n"
132 "#define GIT_TIME \"%s\"\n" 133 "#define GIT_TIME \"%s\"\n"
133 "#define GIT_BRANCH \"%s\"\n", 134 "#define GIT_BRANCH \"%s\"\n",
134 hash, vertag, hash, lastlog, branch); 135 hash, branch, vertag, hash, lastlog, branch);
135 fclose(stream); 136 fclose(stream);
136 fprintf(stderr, "%s updated to commit %s.\n", argv[1], vertag); 137 fprintf(stderr, "%s updated to commit %s (%s).\n", argv[1], vertag, branch);
137 } 138 }
138 else 139 else
139 { 140 {
140 fprintf (stderr, "%s is up to date at commit %s.\n", argv[1], vertag); 141 fprintf (stderr, "%s is up to date at commit %s (%s).\n", argv[1], vertag, branch);
141 } 142 }
142 143
143 return 0; 144 return 0;
144 } 145 }

mercurial