]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'lt/rev-list-gitlink'
authorJunio C Hamano <gitster@pobox.com>
Mon, 19 Nov 2007 00:16:37 +0000 (16:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Nov 2007 00:16:37 +0000 (16:16 -0800)
* lt/rev-list-gitlink:
  Fix rev-list when showing objects involving submodules

builtin-pack-objects.c
revision.c
t/t6008-rev-list-submodule.sh [new file with mode: 0755]
tree-walk.h

index 545ece5da75672f435d018ccb534bc8c342bbf3d..4f446588ac9ce9d8aa50d0c288817a16855422e6 100644 (file)
@@ -990,7 +990,7 @@ static void add_pbase_object(struct tree_desc *tree,
                        return;
                if (name[cmplen] != '/') {
                        add_object_entry(entry.sha1,
-                                        S_ISDIR(entry.mode) ? OBJ_TREE : OBJ_BLOB,
+                                        object_type(entry.mode),
                                         fullname, 1);
                        return;
                }
index 8f0287fcc0ff4409afa1c16774cfb6086c48ae8f..2a59035192baec8265acccf8b5d00aa7b2db4dd7 100644 (file)
@@ -67,10 +67,17 @@ void mark_tree_uninteresting(struct tree *tree)
 
        init_tree_desc(&desc, tree->buffer, tree->size);
        while (tree_entry(&desc, &entry)) {
-               if (S_ISDIR(entry.mode))
+               switch (object_type(entry.mode)) {
+               case OBJ_TREE:
                        mark_tree_uninteresting(lookup_tree(entry.sha1));
-               else
+                       break;
+               case OBJ_BLOB:
                        mark_blob_uninteresting(lookup_blob(entry.sha1));
+                       break;
+               default:
+                       /* Subproject commit - not in this repository */
+                       break;
+               }
        }
 
        /*
diff --git a/t/t6008-rev-list-submodule.sh b/t/t6008-rev-list-submodule.sh
new file mode 100755 (executable)
index 0000000..88e96fb
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Johannes E. Schindelin
+#
+
+test_description='git rev-list involving submodules that this repo has'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       : > file &&
+       git add file &&
+       test_tick &&
+       git commit -m initial &&
+       echo 1 > file &&
+       test_tick &&
+       git commit -m second file &&
+       echo 2 > file &&
+       test_tick &&
+       git commit -m third file &&
+
+       rm .git/index &&
+
+       : > super-file &&
+       git add super-file &&
+       git submodule add . sub &&
+       git symbolic-ref HEAD refs/heads/super &&
+       test_tick &&
+       git commit -m super-initial &&
+       echo 1 > super-file &&
+       test_tick &&
+       git commit -m super-first super-file &&
+       echo 2 > super-file &&
+       test_tick &&
+       git commit -m super-second super-file
+'
+
+test_expect_success "Ilari's test" '
+       git rev-list --objects super master ^super^
+'
+
+test_done
index db0fbdc701f1ef63cdc1a8b7d5c5e72322f91426..903a7b0f483fec5cbb6c6b372ab49cc28b655e75 100644 (file)
@@ -7,6 +7,13 @@ struct name_entry {
        unsigned int mode;
 };
 
+static inline enum object_type object_type(unsigned int mode)
+{
+       return S_ISDIR(mode) ? OBJ_TREE :
+               S_ISGITLINK(mode) ? OBJ_COMMIT :
+               OBJ_BLOB;
+}
+
 struct tree_desc {
        const void *buffer;
        struct name_entry entry;