Code

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
index 76c4f7ca4f56e7c9a508fc5c6216db56a22a56c4,0c3ba2eb8bda000f1062414de093dd9aa7a240d9..f446a1f9cfd1e4db51e8125cbb1e447d7a298a62
+++ 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 b8b66d7d1d5cd4d1795e53a0ff04ae1693498eab,b59e1b959c5d4cf54253534bb726442baf537949..edaf9e46000197de66b2afb98a01358375b92e37
@@@ -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 dac5e4b5e0da239dccc0ee1d43ffc6fb35e1a817,0b99598f305593de5d48e6cbafcbdea359349c45..ac1153bc5646cb2d515ff206b759f4a79e90273a
@@@ -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;
  }