aboutsummaryrefslogtreecommitdiff
path: root/abspath.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-09-25 09:39:24 -0700
committerShawn O. Pearce <spearce@spearce.org>2008-09-25 09:39:24 -0700
commit1ad6d46235d135582d5cbb91ec0186b485c7b5c1 (patch)
treee4a98d08b88862305d9f13ccef82180de33e8bcc /abspath.c
parent6ef1daf77202aee71056771d91dd12121c6061fd (diff)
parentd79796bcf05b89774671a75b3285000c43129823 (diff)
downloadgit-1ad6d46235d135582d5cbb91ec0186b485c7b5c1.tar.gz
git-1ad6d46235d135582d5cbb91ec0186b485c7b5c1.tar.xz
Merge branch 'jc/alternate-push'
* jc/alternate-push: push: receiver end advertises refs from alternate repositories push: prepare sender to receive extended ref information from the receiver receive-pack: make it a builtin is_directory(): a generic helper function
Diffstat (limited to 'abspath.c')
-rw-r--r--abspath.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/abspath.c b/abspath.c
index 0d561246e..8194ce125 100644
--- a/abspath.c
+++ b/abspath.c
@@ -1,5 +1,16 @@
#include "cache.h"
+/*
+ * Do not use this for inspecting *tracked* content. When path is a
+ * symlink to a directory, we do not want to say it is a directory when
+ * dealing with tracked content in the working tree.
+ */
+int is_directory(const char *path)
+{
+ struct stat st;
+ return (!stat(path, &st) && S_ISDIR(st.st_mode));
+}
+
/* We allow "recursive" symbolic links. Only within reason, though. */
#define MAXDEPTH 5
@@ -17,7 +28,7 @@ const char *make_absolute_path(const char *path)
die ("Too long path: %.*s", 60, path);
while (depth--) {
- if (stat(buf, &st) || !S_ISDIR(st.st_mode)) {
+ if (!is_directory(buf)) {
char *last_slash = strrchr(buf, '/');
if (last_slash) {
*last_slash = '\0';