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

Re: why still no empty directory support in git

From
Asheesh Laroia <asheesh@asheesh.org>
Date
Dec 30, 2008, 08:58 UTC
Message-ID
<alpine.DEB.2.00.0812300346040.19911@vellum.laroia.net>
In-Reply-To
<9b18b3110812300043l55a42f6sd995f36bf857543e@mail.gmail.com>
On Tue, 30 Dec 2008, demerphq wrote:
> 2008/12/30 Asheesh Laroia <asheesh@asheesh.org>:
Show 6 quoted lines
>> I ask about this because I'm using git to track email in Maildir 
>> repositories, and in that vein I'm getting bitten by git's removal of 
>> empty directories.
>
> Add a .exists to each directory.  There is precedent for such an 
> approach in other systems.

Delivering mail into a Maildir is a three-step process. Let's say we are delivering to a Maildir spool stored in ~/Maildir.

(1)
The message is written out to ~/Maildir/tmp/some_filename.
(2)

When the message is complete, it is rename()d to ~/Maildir/new/some_name.

(3)

When a mail user agent reads the Maildir spool, it checks new/ for new mail. If there is a message there, it renames it to ~/Maildir/cur/some_other_filename and announces to the user, "You've got mail!"

So, let's say I take your suggestion.

$ touch ~/Maildir/new/.exists $ git add ~/Maildir/new/.exists && git commit -m "La di da"

Now a spec-compliant Maildir user agent will attempt to deliver this new "email message" of zero bytes into the mail spool and assign it a message UID. Doing so will remove it from Maildir/new.

Then I do "git pull" to get the new messages from my mail server's Maildir repository for my email. This causes git read-tree to eventually be run. If the new tree has no unprocessed email, git runs rmdir() on ~/Maildir/new/.

Now if I want to write a new email to ~/Maildir/ (such as due to copying an email from another folder), the Maildir user agent suddenly finds itself in a strange place: new/ does not exist, violating the definition of a Maildir. This breaks mail processing for that ~/Maildir/ folder.

This is because git is removing these directories. There is a strict incompatibility between git rmdir()ing empty directories behind my back and Maildir systems.

I hope that explains the issue I face, both to Junio and to Yves.

Note that for me, there is no issue with how to handle merging of empty directories, or what happens if these empty directories become files, or which empty directories to keep around; if git just never rmdir()s any directories for me, and otherwise acts identically to now, that would solve my problem. I can look into preparing an RFC patch that creates a mode like that.

-- Asheesh.
-- 
You will be the last person to buy a Chrysler.
Previous: demerphqNext: David Brown
Message 9 of 18 in “why still no empty directory support in git”
  1. Ping YinDec 30, 2008
  2. Asheesh LaroiaDec 30, 2008
  3. Jeff WhitesideDec 30, 2008
  4. Robin RosenbergDec 30, 2008
  5. Junio C HamanoDec 30, 2008
  6. Ping YinDec 30, 2008
  7. Asheesh LaroiaDec 30, 2008
  8. demerphqDec 30, 2008
  9. Asheesh LaroiaDec 30, 2008
  10. David BrownDec 31, 2008
  11. Jeff KingJan 1, 2009
  12. Johannes SchindelinJan 2, 2009
  13. Asheesh LaroiaJan 2, 2009
  14. Asheesh LaroiaJan 8, 2009
  15. Liu YubaoDec 30, 2008
  16. Anatol PomozovJan 1, 2009
  17. Johannes SchindelinDec 30, 2008
  18. Michael GaberDec 30, 2008

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.