git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Adding empty directory gives bogus error message

From
Jonas Fonseca <fonseca@diku.dk>
Date
Jun 10, 2007, 20:46 UTC
Message-ID
<20070610204648.GA32214@diku.dk>
Hello,

During a talk with madduck on #git today, we stumbled upon this confusing error message:

  $ mkdir repo
  $ cd repo/
  $ git init
  Initialized empty Git repository in .git/
  $ mkdir empty
  $ git add empty/
  The following paths are ignored by one of your .gitignore files:
  empty/ (directory)
  Use -f if you really want to add them.
  $ git add -f empty/
  fatal: unable to index file empty/

First, it misleads the user by assuming that something was added to .gitignore or another exclude file, and the second error message is not very helpful.

Looking at the code, I am not sure how this can be fixed. Simply printing a warning when finding "some" empty directory might do, but it is not the best way to help somebody new to git. Refusing to add anything when finding an empty directory deep in some hierarchy is not a good option either.

Git 1.4 silently did nothing, so 1.5 at least tries to be more clueful. Anyway, I thought I would mention it and see what happens. ;)

-- 
Jonas Fonseca
Next: Jeff King
Message 1 of 16 in “Adding empty directory gives bogus error message”
  1. Jonas FonsecaJun 10, 2007
  2. Jeff KingJun 11, 2007
  3. 1/3 refactor dir_add_nameJeff King, Jun 11, 2007
  4. Johannes SchindelinJun 11, 2007
  5. Junio C HamanoJun 11, 2007
  6. Jeff KingJun 11, 2007
  7. Junio C HamanoJun 12, 2007
  8. Jeff KingJun 12, 2007
  9. Jonas FonsecaJun 12, 2007
  10. 2/3 dir_struct: add collect_ignored optionJeff King, Jun 11, 2007
  11. 3/3 builtin-add: simplify (and increase accuracy of) exclude handlingJeff King, Jun 11, 2007
  12. Jonas FonsecaJun 11, 2007
  13. Jeff KingJun 11, 2007
  14. Jonas FonsecaJun 11, 2007
  15. Jeff KingJun 11, 2007
  16. Jonas FonsecaJun 12, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.