Skip to contentSkip to conversation

ls-files --others --directory: give trailing slash

PATCH In review Junio C Hamano 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 ls-files --others --directory: give trailing slash

This adds a trailing slash to directory names in the output when "--others --directory" option shows only untracked directories and not their contents, to make them stand out.

---

* Likes, dislikes? This suits better for *my* purpose of calling this from git-status, but it might be undesirable for your Porcelain.

 ls-files.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

02e90a13cce6041263ec90da77f2ba929055b448

ls-files.c +3 -1
index cc5b32e..7e2fdea 100644
@@ -294,8 +294,10 @@ static void read_directory(const char *p
 			case DT_DIR:
 				memcpy(fullname + baselen + len, "/", 2);
 				if (show_other_directories &&
-				    !dir_exists(fullname, baselen + len + 1))
+				    !dir_exists(fullname, baselen + len + 1)) {
+					len++;
 					break;
+				}
 				read_directory(fullname, fullname,
 					       baselen + len + 1);
 				continue;
Signature · 1 line
1.0.7-g0263
#1 lore raw
Quoted 4 lines · Junio C Hamano

* Likes, dislikes? This suits better for *my* purpose of calling this from git-status, but it might be undesirable for your Porcelain.

+1 likes.

--
Darrin

#2 lore raw
In reply to Junio C Hamano
Quoted 4 lines · Junio C Hamano

* Likes, dislikes? This suits better for *my* purpose of calling this from git-status, but it might be undesirable for your Porcelain.

Likes.

However, I'd re-write it as just

	memcpy(fullname + baselen + len, "/", 2);
	len++;
	if (show_other_directories &&
	    !dir_exists(fullname, baselen + len))
		break;
	read_directory(fullname, fullname, baselen + len);

because let's face it, every user wants the "+1", so just do it once up-front instead of adding one in three different places.

Linus