From: Linus Torvalds Date: Mon, 18 Apr 2005 19:12:00 +0000 (-0700) Subject: Merge the new object model thing from Daniel Barkalow X-Git-Tag: v0.99~833 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b51ad4314078298194d23d46e2b4473ffd32a88a;p=git.git Merge the new object model thing from Daniel Barkalow This was a real git merge with conflicts. I'll commit the scripts I used to do the merge next. Not pretty, but it's half-way functional. --- b51ad4314078298194d23d46e2b4473ffd32a88a diff --cc Makefile index 76c4f7ca4,0c3ba2eb8..f446a1f9c --- a/Makefile +++ b/Makefile @@@ -64,12 -64,9 +64,12 @@@ check-files: check-files.o read-cache. ls-tree: ls-tree.o read-cache.o $(CC) $(CFLAGS) -o ls-tree ls-tree.o read-cache.o $(LIBS) - merge-base: merge-base.o read-cache.o - $(CC) $(CFLAGS) -o merge-base merge-base.o read-cache.o $(LIBS) + merge-base: merge-base.o read-cache.o object.o commit.o tree.o blob.o + $(CC) $(CFLAGS) -o merge-base merge-base.o read-cache.o object.o commit.o tree.o blob.o $(LIBS) +merge-cache: merge-cache.o read-cache.o + $(CC) $(CFLAGS) -o merge-cache merge-cache.o read-cache.o $(LIBS) + read-cache.o: cache.h show-diff.o: cache.h diff --cc fsck-cache.c index b8b66d7d1,b59e1b959..edaf9e460 --- a/fsck-cache.c +++ b/fsck-cache.c @@@ -186,7 -149,10 +149,9 @@@ int main(int argc, char **argv continue; } if (!get_sha1_hex(argv[i], head_sha1)) { - mark_reachable(lookup_rev(head_sha1, "commit"), REACHABLE); - struct object *obj = - &lookup_commit(head_sha1)->object; ++ struct object *obj = &lookup_commit(head_sha1)->object; + obj->used = 1; + mark_reachable(obj, REACHABLE); heads++; continue; } diff --cc merge-base.c index dac5e4b5e,0b99598f3..ac1153bc5 --- a/merge-base.c +++ b/merge-base.c @@@ -32,23 -74,22 +74,19 @@@ struct commit *common_ancestor(struct c int main(int argc, char **argv) { - unsigned char rev1[20], rev2[20]; - struct revision *common; - - if (argc != 3 || get_sha1_hex(argv[1], rev1) || get_sha1_hex(argv[2], rev2)) - usage("merge-base "); + struct commit *rev1, *rev2, *ret; + unsigned char rev1key[20], rev2key[20]; - /* - * We will eventually want to include a revision cache file - * that "rev-tree.c" has generated, since this is going to - * otherwise be quite expensive for big trees.. - * - * That's some time off, though, and in the meantime we know - * that we have a solution to the eventual expense. - */ - common = common_parent(parse_commit(rev1), parse_commit(rev2)); - if (!common) - die("no common parent found"); - printf("%s\n", sha1_to_hex(common->sha1)); + if (argc != 3 || + get_sha1_hex(argv[1], rev1key) || + get_sha1_hex(argv[2], rev2key)) { + usage("merge-base "); + } + rev1 = lookup_commit(rev1key); + rev2 = lookup_commit(rev2key); + ret = common_ancestor(rev1, rev2); - if (ret) { - printf("%s\n", sha1_to_hex(ret->object.sha1)); - return 0; - } else { ++ if (!ret) + return 1; - } - ++ printf("%s\n", sha1_to_hex(ret->object.sha1)); + return 0; }