threads / discuss / 4195

git status and empty directories

Subject: git status and empty directories

## tl;dr

3 messages between May 18, 2006 and May 18, 2006.

replies: 2people: 2as markdown or json

Matthias Lederhofer· May 18, 2006, 17:57 UTC · lore

Today I've been working on some source with many empty directories. git-status shows all empty directories under "Untracked files: (use "git add" to add to commit)" but adding is impossible. And if it would be possible to add the directory, because a new file exists in the directory, it still shows up in the same place, indistinguishable from the empty directories.

Things I could think of to solve this:
- hide empty directories if the user does not ask explicitly for them
  with a command line option
- vice versa: add a command line option to hide empty directories
(I'd prefer the first one)

Another category in git-status for empty directories which cannot be added could be interesting too because the comment 'use "git add" to add to commit' is quite misleading.

Perhaps there should also be another option to show files in untracked directories.

Any comments? If a patch would be accepted I'll take a look at writing one. Adding the correct options to git-ls-files seems quite trivial.

Linus Torvalds· May 18, 2006, 18:12 UTC · re: Matthias Lederhofer · lore

Re: git status and empty directories

On Thu, 18 May 2006, Matthias Lederhofer wrote:
>
> - hide empty directories if the user does not ask explicitly for them
>   with a command line option
Like this?
Makes sense to me, although I didn't add the option to disable it.
		Linus
---
diff --git a/git-commit.sh b/git-commit.sh
index 6ef1a9d..ed00b5c 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -136,11 +136,11 @@ #'
 
 	if test -f "$GIT_DIR/info/exclude"
 	then
-	    git-ls-files -z --others --directory \
+	    git-ls-files -z --others --directory --no-empty-directory \
 		--exclude-from="$GIT_DIR/info/exclude" \
 		--exclude-per-directory=.gitignore
 	else
-	    git-ls-files -z --others --directory \
+	    git-ls-files -z --others --directory --no-empty-directory \
 		--exclude-per-directory=.gitignore
 	fi |
 	perl -e '$/ = "\0";
Matthias Lederhofer· May 18, 2006, 18:29 UTC · re: Linus Torvalds · lore

Re: git status and empty directories

> Like this?

This is exactly the patch I'm using at the moment and I don't really need an option to unhide empty directories. Maybe someone else complains for some reason but git clean -d -n shows empty directories too.

An option to show untracked files instead of untracked directories like

> git-ls-files -z --others --exclude-per-directory=.gitignore

would be interesting to see what would be added instead of doing ls manually.

← back to recent threads