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>
Linus Torvalds committed
Apr 9, 2007 at 21:15 UTC
8d9721c86b0169c282ad1c5528317eafeb7fb0f7
2 files changed
+22
-2
builtin-fsck.c
+8
-1
@@ -253,6 +253,7 @@ static int fsck_tree(struct tree *item)
253
case S_IFREG | 0644:
254
case S_IFLNK:
255
case S_IFDIR:
256
+ case S_IFDIRLNK:
257
break;
258
/*
259
* This is nonstandard, but we had a few of these
@@ -695,8 +696,14 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
696
int i;
697
read_cache();
698
for (i = 0; i < active_nr; i++) {
698
- struct blob *blob = lookup_blob(active_cache[i]->sha1);
699
+ unsigned int mode;
700
+ struct blob *blob;
701
struct object *obj;
702
+
703
+ mode = ntohl(active_cache[i]->ce_mode);
704
+ if (S_ISDIRLNK(mode))
705
+ continue;
706
+ blob = lookup_blob(active_cache[i]->sha1);
707
if (!blob)
708
continue;
709
obj = &blob->object;
tree.c
+14
-1
@@ -143,6 +143,14 @@ struct tree *lookup_tree(const unsigned char *sha1)
143
return (struct tree *) obj;
144
}
145
146
+/*
147
+ * NOTE! Tree refs to external git repositories
148
+ * (ie gitlinks) do not count as real references.
149
+ *
150
+ * You don't have to have those repositories
151
+ * available at all, much less have the objects
152
+ * accessible from the current repository.
153
+ */
154
static void track_tree_refs(struct tree *item)
155
{
156
int n_refs = 0, i;
@@ -152,8 +160,11 @@ static void track_tree_refs(struct tree *item)
160
161
/* Count how many entries there are.. */
162
init_tree_desc(&desc, item->buffer, item->size);
155
- while (tree_entry(&desc, &entry))
163
+ while (tree_entry(&desc, &entry)) {
164
+ if (S_ISDIRLNK(entry.mode))
165
+ continue;
166
n_refs++;
167
+ }
168
169
/* Allocate object refs and walk it again.. */
170
i = 0;
@@ -162,6 +173,8 @@ static void track_tree_refs(struct tree *item)
173
while (tree_entry(&desc, &entry)) {
174
struct object *obj;
175
176
+ if (S_ISDIRLNK(entry.mode))
177
+ continue;
178
if (S_ISDIR(entry.mode))
179
obj = &lookup_tree(entry.sha1)->object;
180
else