aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-10 21:31:19 -0800
committerJunio C Hamano <gitster@pobox.com>2009-02-10 21:31:19 -0800
commitf1c8a48a2de69bfc9837c53f2c52ffbe7239dc3e (patch)
treedbf5e4b02e89a51e9bd00cea133c105a51e86302 /tree.c
parent8c5514906a532f154aa0db1199f46bbdeeffb0ad (diff)
parentd3bee161fef7820e83b44b899c531228a5546e87 (diff)
downloadgit-f1c8a48a2de69bfc9837c53f2c52ffbe7239dc3e.tar.xz
Merge branch 'lh/submodule-tree-traversal' (early part)
* 'lh/submodule-tree-traversal' (early part): tree.c: allow read_tree_recursive() to traverse gitlink entries
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tree.c b/tree.c
index 03e782a9ca..dfe4d5f303 100644
--- a/tree.c
+++ b/tree.c
@@ -131,6 +131,34 @@ int read_tree_recursive(struct tree *tree,
if (retval)
return -1;
continue;
+ } else if (S_ISGITLINK(entry.mode)) {
+ int retval;
+ struct strbuf path;
+ unsigned int entrylen;
+ struct commit *commit;
+
+ entrylen = tree_entry_len(entry.path, entry.sha1);
+ strbuf_init(&path, baselen + entrylen + 1);
+ strbuf_add(&path, base, baselen);
+ strbuf_add(&path, entry.path, entrylen);
+ strbuf_addch(&path, '/');
+
+ commit = lookup_commit(entry.sha1);
+ if (!commit)
+ die("Commit %s in submodule path %s not found",
+ sha1_to_hex(entry.sha1), path.buf);
+
+ if (parse_commit(commit))
+ die("Invalid commit %s in submodule path %s",
+ sha1_to_hex(entry.sha1), path.buf);
+
+ retval = read_tree_recursive(commit->tree,
+ path.buf, path.len,
+ stage, match, fn, context);
+ strbuf_release(&path);
+ if (retval)
+ return -1;
+ continue;
}
}
return 0;