{"thread":{"id":"579","subject":"[PATCH] Support symlinks in git-ls-files --others.","startedAt":"2005-05-12T07:48:18Z","lastAt":"2005-05-12T07:48:18Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3121","messageId":"7v1x8ckhq5.fsf@assigned-by-dhcp.cox.net","threadId":"579","inReplyTo":null,"subject":"[PATCH] Support symlinks in git-ls-files --others.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-12T07:48:18Z","receivedAt":"2005-05-12T07:48:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It is kind of surprising that this was missed in the last round,\nbut the work tree scanner in git-ls-files is still deliberately\nignoring symlinks.  This patch fixes it.\n\nThis depends on the test suite infrastructure I sent in earlier.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\nPetr, I am not CCing Linus and you know what I mean by it ;-).\n\ncache.h             |    1 +\nls-files.c          |    8 +++++---\nt/t0400-ls-files.sh |   29 +++++++++++++++++++++++++++++\n3 files changed, 35 insertions(+), 3 deletions(-)\nt/t0400-ls-files.sh (. --> 100755)\n\n--- a/cache.h\n+++ b/cache.h\n@@ -27,6 +27,7 @@\n #define DT_UNKNOWN\t0\n #define DT_DIR\t\t1\n #define DT_REG\t\t2\n+#define DT_LNK\t\t3\n #define DTYPE(de)\tDT_UNKNOWN\n #endif\n \n--- a/ls-files.c\n+++ b/ls-files.c\n@@ -109,8 +109,9 @@\n \n /*\n  * Read a directory tree. We currently ignore anything but\n- * directories and regular files. That's because git doesn't\n- * handle them at all yet. Maybe that will change some day.\n+ * directories, regular files and symlinks. That's because git\n+ * doesn't handle them at all yet. Maybe that will change some\n+ * day.\n  *\n  * Also, we currently ignore all names starting with a dot.\n  * That likely will not change.\n@@ -141,7 +142,7 @@\n \t\t\tcase DT_UNKNOWN:\n \t\t\t\tif (lstat(fullname, &st))\n \t\t\t\t\tcontinue;\n-\t\t\t\tif (S_ISREG(st.st_mode))\n+\t\t\t\tif (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))\n \t\t\t\t\tbreak;\n \t\t\t\tif (!S_ISDIR(st.st_mode))\n \t\t\t\t\tcontinue;\n@@ -152,6 +153,7 @@\n \t\t\t\t\t       baselen + len + 1);\n \t\t\t\tcontinue;\n \t\t\tcase DT_REG:\n+\t\t\tcase DT_LNK:\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tadd_name(fullname, baselen + len);\n--- a/t/t0400-ls-files.sh\n+++ b/t/t0400-ls-files.sh\n@@ -0,0 +1,29 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+. ./test-lib.sh\n+test_description \"$@\" 'git-ls-files test.\n+\n+This test runs git-ls-files --others with the following on the\n+filesystem.\n+\n+    path0       - a file\n+    path1\t- a symlink\n+    path2/file2 - a file in a directory\n+'\n+\n+date >path0\n+ln -s xyzzy path1\n+mkdir path2\n+date >path2/file2\n+git-ls-files --others >.output\n+cat >.expected <<EOF\n+path0\n+path1\n+path2/file2\n+EOF\n+\n+test_expect_success 'diff .output .expected'\n+test_done\n------------------------------------------------\n\nCompilation finished at Thu May 12 00:43:56\n\n"}]}