1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 00:36:07 +02:00

Fix rev-list when showing objects involving submodules

The function mark_tree_uninteresting() assumed that the tree entries
are blob when they are not trees.  This is not so.  Since we do
not traverse into submodules (yet), the gitlinks should be ignored.

In general, we should try to start moving away from using the
"S_ISLNK()" like things for internal git state. It was a mistake to
just assume the numbers all were same across all systems in the first
place.  This implementation converts to the "object_type", and then
uses a case statement.

Noticed by Ilari on IRC.
Test script taken from an earlier version by Dscho.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Linus Torvalds 2007-11-11 23:35:23 +00:00 committed by Junio C Hamano
parent fb5fd01148
commit 4d1012c370
4 changed files with 59 additions and 3 deletions

View 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;
}

View File

@ -65,10 +65,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;
}
}
/*

42
t/t6008-rev-list-submodule.sh Executable file
View File

@ -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

View 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;