7 void show_commit(struct commit *commit)
12 strcpy(hex, sha1_to_hex(commit->object.sha1));
13 printf("Id: %s\n", hex);
15 sprintf(cmdline, "cat-file commit %s", hex);
17 if (commit->parents) {
18 char *against = sha1_to_hex(commit->parents->item->object.sha1);
19 printf("\n\n======== diff against %s ========\n", against);
21 sprintf(cmdline, "diff-tree -r -z %s %s | xargs -0 gitdiff-do %s %s", against, hex, against, hex);
24 printf("======== end ========\n\n");
28 * Show all unseen commits, depth-first
30 void show_unseen(struct commit *top)
32 struct commit_list *parents;
34 if (top->object.flags & 2)
36 top->object.flags |= 2;
37 parents = top->parents;
39 show_unseen(parents->item);
40 parents = parents->next;
45 void export(struct commit *top, struct commit *base)
47 mark_reachable(&top->object, 1);
49 mark_reachable(&base->object, 2);
53 struct commit *get_commit(unsigned char *sha1)
55 struct commit *commit = lookup_commit(sha1);
56 if (!commit->object.parsed) {
57 struct commit_list *parents;
59 if (parse_commit(commit) < 0)
60 die("unable to parse commit %s", sha1_to_hex(sha1));
61 parents = commit->parents;
63 get_commit(parents->item->object.sha1);
64 parents = parents->next;
70 int main(int argc, char **argv)
72 unsigned char base_sha1[20];
73 unsigned char top_sha1[20];
75 if (argc < 2 || argc > 4 ||
76 get_sha1_hex(argv[1], top_sha1) ||
77 (argc == 3 && get_sha1_hex(argv[2], base_sha1)))
78 usage("git-export top [base]");
79 export(get_commit(top_sha1), argc==3 ? get_commit(base_sha1) : NULL);