# git status and empty directories

3 messages from 2006-05-18 to 2006-05-18. Participants: Matthias Lederhofer, Linus Torvalds.
Thread: https://gitlist.dev/t/4195

## Matthias Lederhofer, 2006-05-18 17:57

Subject: git status and empty directories
Message-ID: <E1Fgmkh-0000ur-Hn@moooo.ath.cx>
URL: https://gitlist.dev/e/E1Fgmkh-0000ur-Hn%40moooo.ath.cx

```
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, 2006-05-18 18:12

Subject: Re: git status and empty directories
Message-ID: <Pine.LNX.4.64.0605181112040.10823@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0605181112040.10823%40g5.osdl.org
In-Reply-To: <E1Fgmkh-0000ur-Hn@moooo.ath.cx>

```


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, 2006-05-18 18:29

Subject: Re: git status and empty directories
Message-ID: <E1FgnFV-0002FV-39@moooo.ath.cx>
URL: https://gitlist.dev/e/E1FgnFV-0002FV-39%40moooo.ath.cx
In-Reply-To: <Pine.LNX.4.64.0605181112040.10823@g5.osdl.org>

```
> 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.

```
