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

Re: [PATCH/RFC] git-svn: New flag to add a file in empty directories

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
May 18, 2011, 07:22 UTC
Message-ID
<4DD373CD.6010607@alum.mit.edu>
In-Reply-To
<1305669635-10861-1-git-send-email-rchen@cs.umd.edu>
On 05/18/2011 12:00 AM, Ray Chen wrote:
Show 27 quoted lines
> Adds the --preserve-empty-dirs flag to the clone and fetch operations that
> will detect empty SVN directories, and create a placeholder file within them.
> This allows "empty" directories to exist in the history of a Git repository.
> 
> Also adds the --placeholder-file flag to control the name of any placeholder
> files created.  Default value is ".gitignore".
> 
> Signed-off-by: Ray Chen <rchen@cs.umd.edu>
> ---
> 
> I needed this functionality when I was migrating a repository from SVN to
> Git.  It seems well known that Git only tracks files, not directories, so
> any revision I checked out would be missing the empty directories that
> existed in the SVN repository.
> 
> My knowledge of SVN is limited, so I'm not sure how correct this patch is.
> I created a little test SVN repo, and `git svn clone --preserve-empty-dirs`
> did the right thing, but that's hardly a complete test.
> 
> Specifically, I experimentally noticed that my patch worked with lines 4532
> and 4533 commented out.  I'm not sure what problems might occur when adding
> a file Git without associated SVN properties.
> 
> Finally, I added the --preserve-empty-dirs and --placeholder-file only to
> the clone and fetch operations.  Is that appropriate?  The functionality
> is really only applicable to full migrations.  I'm not sure that the fetch
> operation should have it.

I'm not familiar enough with the code to critique your code, but I have some questions/comments about the feature's intended behavior:

1. What happens if a previously empty directory is deleted from
Subversion?  It seems to me that consistency would demand that the
placeholder file be deleted so that git also forgets about the
directory.  On the other hand, if the user has edited the placeholder
file since it was created, it might be advisable to emit a warning or error.
2. What happens if, in Subversion, content is added to a previously
empty directory?  Is the placeholder left around?
3. I believe that this feature would be useful to people who are
tracking a Subversion repository over time (not just for full
migrations).  What happens if the user sometimes uses the new options
and sometimes not?  Are the missing directories that have "accumulated"
since the last invocation with --preserve-empty-dirs all added in the
first commit resulting from a later use of --preserve-empty-directories,
or are they skipped forever?  I'm talking about this scenario:
Subversion                   git
----------                   ---
Add empty directory "a"
                             git svn fetch --preserve-empty-dirs
Add empty directory "b"
                             git svn fetch
Add empty directory "c"
                             git svn fetch --preserve-empty-dirs

After the third "git svn fetch", does the git repository contain directory "b"?

4. If it is a goal to support long-term tracking of a Subversion
repository, then it would be good to add a config option to turn on this
feature permanently for a git-svn repository, so that the user doesn't
have to enter the extra options with each command invocation.
5. It might be useful to allow the placeholder files to be committed to
Subversion, so that other git-svn users based off the same Subversion
repository don't have to worry about empty directories.  This would
typically be something that people would want to do semi-manually in
specific Subversion commits.  To support this user case, one could add a
similar option to "git svn mkdirs" that causes the placeholder files to
be created in the working copy but not committed.  Then the user could
review the suggested changes, perhaps add lines to the .gitignore files,
commit to git, then dcommit to Subversion.
6. Documentation patches would also be required.
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Ray ChenNext: Eric Wong
Message 2 of 11 in “git-svn: New flag to add a file in empty directories”
  1. git-svn: New flag to add a file in empty directoriesRay Chen, May 17, 2011
  2. Michael HaggertyMay 18, 2011
  3. Eric WongMay 18, 2011
  4. Michael J GruberMay 18, 2011
  5. Ray ChenMay 18, 2011
  6. Ray ChenMay 18, 2011
  7. Eric WongMay 18, 2011
  8. Michael HaggertyMay 19, 2011
  9. Ray ChenMay 18, 2011
  10. Eric WongMay 18, 2011
  11. GaffneyJul 23, 2014

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.