threads / discuss / 46705

Empty directories in Git: Current guidance for historical commits?

Subject: Empty directories in Git: Current guidance for historical commits?

## tl;dr

4 messages between Sep 5, 2017 and Sep 6, 2017.

replies: 3people: 3as markdown or json

wafflecode@openmail.cc· Sep 5, 2017, 12:47 UTC · lore
Hello,

Per the FAQ it's clear that Git (by current design) does not track empty directories: https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F

That's fine and I can fix that for my code going forward via the build system, as needed.

However I'm looking to import a fairly deep (10k+ commits) svn history in to Git and I'm wondering what the current best practices are for dealing with empty folders? Meaning to say, I'd like to be able to check out an older revision of the code and have it build correctly using the older build system which expects certain folders to exist.

There are a few different answers floating around the net, so I figured I'd confirm via the mailing list.

Is just dropping a ".gitignore" or "README" file in the empty directories during conversion still the most reasonable approach? If so, is there a way to do this automatically during the conversion using "git svn" or the like?

Thank you David

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands! $24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options!

Torsten Bögershausen· Sep 5, 2017, 17:58 UTC · re: wafflecode@openmail.cc · lore

Re: Empty directories in Git: Current guidance for historical commits?

On 2017-09-05 14:47, wafflecode@openmail.cc wrote:
Show 21 quoted lines
> 
> Hello,
> 
> Per the FAQ it's clear that Git (by current design) does not track empty
> directories: 
> https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F
> 
> That's fine and I can fix that for my code going forward via the build system,
> as needed.
> 
> However I'm looking to import a fairly deep (10k+ commits) svn history in to Git
> and I'm wondering what the current best practices are for dealing with empty
> folders?   Meaning to say, I'd like to be able to check out an older revision of
> the code and have it build correctly using the older build system which expects
> certain folders to exist.
> 
> There are a few different answers floating around the net, so I figured I'd
> confirm via the mailing list.
> 
> Is just dropping a ".gitignore" or "README" file in the empty directories during
> conversion still the most reasonable approach? 

A .gitignore will, but may cost 0.001% CPU time when running "git status". I have seen systems that create a file called ".empty" in every directory.

> If so, is there a way to do this
> automatically during the conversion using "git svn" or the like?

Not what I am aware of. And even if, the .empty files need to be removed, once the directory is removed. And we don't have logic for that, as far as I know.

That would be by suggestion: convert the repo "as is", with the tools we have.

If you need to continue to work on an old branch (or the master branch), add the .empty file, where needed, and continue to work in Git, on a branch as usual.

Show 5 quoted lines
> 
> 
> Thank you
> David
>
wafflecode@openmail.cc· Sep 5, 2017, 22:17 UTC · re: Torsten Bögershausen · lore

Re: Empty directories in Git: Current guidance for historical commits?

Quoting Torsten Bögershausen <tboegi@web.de>:
Show 15 quoted lines
>> Is just dropping a ".gitignore" or "README" file in the empty  
>> directories during
>> conversion still the most reasonable approach?
>
> A .gitignore will, but may cost 0.001% CPU time when running "git status".
> I have seen systems that create a file called ".empty" in every directory.
>
>> If so, is there a way to do this
>> automatically during the conversion using "git svn" or the like?
>
> Not what I am aware of.
> And even if, the .empty files need to be removed, once the directory is
> removed.
> And we don't have logic for that, as far as I know.
>

So upon re-reading the git-svn docs, there apparently _are_ "--preserve-empty-dirs" and "--placeholder-filename=<filename>" options.

I'm not sure how I missed these.  :-/

If I understand correctly, it sounds like exactly what I want. i.e. a placeholder file being added (and tracked) to each empty folder. Are there known issues or limitations to be aware of?

Thank you, David

-------------------------------------------------

ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands! $24.95 ONETIME Lifetime accounts with Privacy Features! 15GB disk! No bandwidth quotas! Commercial and Bulk Mail Options!

Jeff King· Sep 5, 2017, 20:31 UTC · re: wafflecode@openmail.cc · lore

Re: Empty directories in Git: Current guidance for historical commits?

On Tue, Sep 05, 2017 at 12:47:43PM +0000, wafflecode@openmail.cc wrote:
> Is just dropping a ".gitignore" or "README" file in the empty directories
> during conversion still the most reasonable approach?
Yes, I think so.
> If so, is there a way
> to do this automatically during the conversion using "git svn" or the like?
I haven't used git-svn in years, but the manpage says:
  --preserve-empty-dirs
      Create a placeholder file in the local Git repository for each
      empty directory fetched from Subversion. This includes directories
      that become empty by removing all entries in the Subversion
      repository (but not the directory itself). The placeholder files
      are also tracked and removed when no longer necessary.
-Peff

← back to recent threads