]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Teach "fsck" not to follow subproject links
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Apr 2007 04:15:29 +0000 (21:15 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 10 Apr 2007 20:46:58 +0000 (13:46 -0700)
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>
builtin-fsck.c
tree.c

index 4d8b66c344422dd60c72c72bbfbc5aa87be7907e..f22de8deaac9b064702518cc51aa61f5d8f2ac92 100644 (file)
@@ -253,6 +253,7 @@ static int fsck_tree(struct tree *item)
                case S_IFREG | 0644:
                case S_IFLNK:
                case S_IFDIR:
+               case S_IFDIRLNK:
                        break;
                /*
                 * This is nonstandard, but we had a few of these
@@ -695,8 +696,14 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
                int i;
                read_cache();
                for (i = 0; i < active_nr; i++) {
-                       struct blob *blob = lookup_blob(active_cache[i]->sha1);
+                       unsigned int mode;
+                       struct blob *blob;
                        struct object *obj;
+
+                       mode = ntohl(active_cache[i]->ce_mode);
+                       if (S_ISDIRLNK(mode))
+                               continue;
+                       blob = lookup_blob(active_cache[i]->sha1);
                        if (!blob)
                                continue;
                        obj = &blob->object;
diff --git a/tree.c b/tree.c
index d188c0fbaee110a17ca7a0d16dcc979091f44ded..dbb63fc52543c06cfd24f7858bbad490c700c5ed 100644 (file)
--- 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