From 275721c2671800a905e873e58be2f1c2f313bf88 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 20 May 2015 13:03:38 -0400 Subject: 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 Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- tree-walk.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tree-walk.h') 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; -- cgit v1.2.3