summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2007-04-09 21:15:29 -0700
committerJunio C Hamano <junkio@cox.net>2007-04-10 13:46:58 -0700
commit8d9721c86b0169c282ad1c5528317eafeb7fb0f7 (patch)
treecbf3c5aa5deaa1f8fb07961c8bcebf90d41382fe /tree.c
parent9eec4795d44439cd170fb52c73827c728252648d (diff)
downloadgit-8d9721c86b0169c282ad1c5528317eafeb7fb0f7.tar.gz
Teach "fsck" not to follow subproject links
Since the subprojects don't necessarily even exist in the current tree, much less in the current git repository (they are totally independent repositories), we do not want to try to follow the chain from one git repository to another through a gitlink. This involves teaching fsck to ignore references to gitlink objects from a tree and from the current index. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/tree.c b/tree.c
index d188c0fbae..dbb63fc525 100644
--- a/tree.c
+++ b/tree.c
@@ -143,6 +143,14 @@ struct tree *lookup_tree(const unsigned char *sha1)
return (struct tree *) obj;
}
+/*
+ * NOTE! Tree refs to external git repositories
+ * (ie gitlinks) do not count as real references.
+ *
+ * You don't have to have those repositories
+ * available at all, much less have the objects
+ * accessible from the current repository.
+ */
static void track_tree_refs(struct tree *item)
{
int n_refs = 0, i;
@@ -152,8 +160,11 @@ static void track_tree_refs(struct tree *item)
/* Count how many entries there are.. */
init_tree_desc(&desc, item->buffer, item->size);
- while (tree_entry(&desc, &entry))
+ while (tree_entry(&desc, &entry)) {
+ if (S_ISDIRLNK(entry.mode))
+ continue;
n_refs++;
+ }
/* Allocate object refs and walk it again.. */
i = 0;
@@ -162,6 +173,8 @@ static void track_tree_refs(struct tree *item)
while (tree_entry(&desc, &entry)) {
struct object *obj;
+ if (S_ISDIRLNK(entry.mode))
+ continue;
if (S_ISDIR(entry.mode))
obj = &lookup_tree(entry.sha1)->object;
else