diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-11-19 03:16:37 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-11-19 03:16:37 +0300 |
commit | 5d3d1cacc139194672a6a184509bb620a19b2497 (patch) | |
tree | 872d798fe9d07c32ff768ca83a5df1450f09a212 | |
parent | d577bc58a3424f4d0d7f7c8094753b92cb7cb823 (diff) | |
parent | 4d1012c3709e356107d0fb0e3bf5a39e0d5c209d (diff) |
Merge branch 'lt/rev-list-gitlink'
* lt/rev-list-gitlink:
Fix rev-list when showing objects involving submodules
-rw-r--r-- | builtin-pack-objects.c | 2 | ||||
-rw-r--r-- | revision.c | 11 | ||||
-rwxr-xr-x | t/t6008-rev-list-submodule.sh | 42 | ||||
-rw-r--r-- | tree-walk.h | 7 |
4 files changed, 59 insertions, 3 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 545ece5da7..4f446588ac 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -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; } diff --git a/revision.c b/revision.c index 8f0287fcc0..2a59035192 100644 --- a/revision.c +++ b/revision.c @@ -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 index 0000000000..88e96fb91b --- /dev/null +++ b/t/t6008-rev-list-submodule.sh @@ -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 diff --git a/tree-walk.h b/tree-walk.h index db0fbdc701..903a7b0f48 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -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; |