Merge branch 'sg/mailmap-self'
[gitweb.git] / abspath.c
index 1d56f5ed9f95002d018458c907625fff27472231..2f0c26e0e2cbee88aa671f3960d21720e4307aba 100644 (file)
--- a/abspath.c
+++ b/abspath.c
@@ -62,7 +62,9 @@ static void get_root_part(struct strbuf *resolved, struct strbuf *remaining)
 }
 
 /* We allow "recursive" symbolic links. Only within reason, though. */
-#define MAXSYMLINKS 5
+#ifndef MAXSYMLINKS
+#define MAXSYMLINKS 32
+#endif
 
 /*
  * Return the real path (i.e., absolute path, with symlinks resolved
@@ -139,6 +141,8 @@ char *strbuf_realpath(struct strbuf *resolved, const char *path,
                        strbuf_reset(&symlink);
 
                        if (num_symlinks++ > MAXSYMLINKS) {
+                               errno = ELOOP;
+
                                if (die_on_error)
                                        die("More than %d nested symlinks "
                                            "on path '%s'", MAXSYMLINKS, path);
@@ -235,6 +239,13 @@ const char *absolute_path(const char *path)
        return sb.buf;
 }
 
+char *absolute_pathdup(const char *path)
+{
+       struct strbuf sb = STRBUF_INIT;
+       strbuf_add_absolute_path(&sb, path);
+       return strbuf_detach(&sb, NULL);
+}
+
 /*
  * Unlike prefix_path, this should be used if the named file does
  * not have to interact with index entry; i.e. name of a random file