Introduce old redir program
[lcapit-junk-code.git] / git / commit-dumper.c
blob55c4eec98b2699300b6cd1f49a985a0fe1a8a3f5
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <unistd.h>
6 #include <cache.h>
8 #define PRINT_MAX 5
10 int main(int argc, char *argv[])
12 void *buf;
13 int err;
14 unsigned long size;
15 unsigned char sha1[20];
17 if (argc != 3) {
18 printf("commit SHA1 missing?");
19 fprintf(stderr, "commit-dumper <repo> <commit>\n");
20 exit(1);
23 err = chdir(argv[1]);
24 if (err) {
25 perror("chdir()");
26 exit(1);
29 memset(sha1, 0, sizeof(sha1));
30 get_sha1(argv[2], sha1);
32 buf = read_object_with_reference(sha1, "commit", &size, NULL);
33 if (!buf) {
34 fprintf(stderr, "buf is NULL\n");
35 exit(1);
38 write(1, buf, size);
40 return 0;