summaryrefslogtreecommitdiff
path: root/tree-walk.h
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2015-05-20 13:03:38 -0400
committerJunio C Hamano <gitster@pobox.com>2015-05-20 13:45:49 -0700
commit275721c2671800a905e873e58be2f1c2f313bf88 (patch)
tree562325f6f6376c088ca6d91511a1e7961800453f /tree-walk.h
parent8440f74997cf7958c7e8ec853f590828085049b8 (diff)
downloadgit-275721c2671800a905e873e58be2f1c2f313bf88.tar.gz
tree-walk: learn get_tree_entry_follow_symlinks
Add a new function, get_tree_entry_follow_symlinks, to tree-walk.[ch]. The function is not yet used. It will be used to implement git cat-file --batch --follow-symlinks. The function locates an object by path, following symlinks in the repository. If the symlinks lead outside the repository, the function reports this to the caller. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree-walk.h')
-rw-r--r--tree-walk.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/tree-walk.h b/tree-walk.h
index ae7fb3a824..3b2f7bf17d 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -40,6 +40,24 @@ struct traverse_info;
typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info);
+enum follow_symlinks_result {
+ FOUND = 0, /* This includes out-of-tree links */
+ MISSING_OBJECT = -1, /* The initial symlink is missing */
+ DANGLING_SYMLINK = -2, /*
+ * The initial symlink is there, but
+ * (transitively) points to a missing
+ * in-tree file
+ */
+ SYMLINK_LOOP = -3,
+ NOT_DIR = -4, /*
+ * Somewhere along the symlink chain, a path is
+ * requested which contains a file as a
+ * non-final element.
+ */
+};
+
+enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_sha1, const char *name, unsigned char *result, struct strbuf *result_path, unsigned *mode);
+
struct traverse_info {
struct traverse_info *prev;
struct name_entry name;