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

Re: Adding empty directory gives bogus error message

From
Jeff King <peff@peff.net>
Date
Jun 11, 2007, 12:30 UTC
Message-ID
<20070611123045.GA28814@coredump.intra.peff.net>
In-Reply-To
<20070610204648.GA32214@diku.dk>
On Sun, Jun 10, 2007 at 10:46:48PM +0200, Jonas Fonseca wrote:
Show 14 quoted lines
> 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/

Urgh, that's ugly. The problem is that git-add sticks assumed-to-be-ignored stuff back into the list of files found by read_directory, but with some special ignored flags (which aren't used anywhere else!). When the assumption is wrong (because the path is _actually_ just empty), you get the bogus message, and when you try to force it, you get an error from elsewhere in the code.

Patch series will be out momentarily.
-Peff
Previous: Jonas FonsecaNext: Jeff King
Message 2 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.