threads / patch / 595

patch, 3 partsSupport symlinks in git-ls-files --others.

Subject: [PATCH 2/3] Support symlinks in git-ls-files --others.

## tl;dr

One message between May 13, 2005 and May 13, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· May 13, 2005, 00:16 UTC · lore

It is kind of surprising that this was missed in the last round, but the work tree scanner in git-ls-files was still deliberately ignoring symlinks. This patch fixes it, so that --others will correctly report unregistered symlinks.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

cache.h | 1 + ls-files.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-)

Show changes to 2 files +6 −3

cache.h, ls-files.c

--- a/cache.h
+++ b/cache.h
@@ -27,6 +27,7 @@
 #define DT_UNKNOWN	0
 #define DT_DIR		1
 #define DT_REG		2
+#define DT_LNK		3
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
--- a/ls-files.c
+++ b/ls-files.c
@@ -109,8 +109,9 @@
 
 /*
  * Read a directory tree. We currently ignore anything but
- * directories and regular files. That's because git doesn't
- * handle them at all yet. Maybe that will change some day.
+ * directories, regular files and symlinks. That's because git
+ * doesn't handle them at all yet. Maybe that will change some
+ * day.
  *
  * Also, we currently ignore all names starting with a dot.
  * That likely will not change.
@@ -141,7 +142,7 @@
 			case DT_UNKNOWN:
 				if (lstat(fullname, &st))
 					continue;
-				if (S_ISREG(st.st_mode))
+				if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
 					break;
 				if (!S_ISDIR(st.st_mode))
 					continue;
@@ -152,6 +153,7 @@
 					       baselen + len + 1);
 				continue;
 			case DT_REG:
+			case DT_LNK:
 				break;
 			}
 			add_name(fullname, baselen + len);
------------------------------------------------

← back to recent threads