add more informative error messages to git-mktag
[debian-git.git] / get-tar-commit-id.c
blob416629035c1515ae123920563fcacfa10d5f0a66
1 /*
2 * Copyright (C) 2005 Rene Scharfe
3 */
4 #include <stdio.h>
5 #include <string.h>
6 #include <unistd.h>
8 #define HEADERSIZE 1024
10 int main(int argc, char **argv)
12 char buffer[HEADERSIZE];
13 ssize_t n;
15 n = read(0, buffer, HEADERSIZE);
16 if (n < HEADERSIZE) {
17 fprintf(stderr, "read error\n");
18 return 3;
20 if (buffer[156] != 'g')
21 return 1;
22 if (memcmp(&buffer[512], "52 comment=", 11))
23 return 1;
24 n = write(1, &buffer[523], 41);
25 if (n < 41) {
26 fprintf(stderr, "write error\n");
27 return 2;
29 return 0;