Merge the new object model thing from Daniel Barkalow
authorLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 18 Apr 2005 19:12:00 +0000 (12:12 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 18 Apr 2005 19:12:00 +0000 (12:12 -0700)
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.

1  2 
Makefile
fsck-cache.c
merge-base.c

diff --cc 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
@@@ -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
@@@ -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 <commit1> <commit2>");
+       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 <commit-id> <commit-id>");
+       }
+       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;
  }