git-svn: Create leading directories in create-ignore

Since SVN tracks empty directories and git does not, we can not assume
that the directory exists when creating .gitignore files.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
Brian Gernhardt 2009-02-19 13:08:04 -05:00 committed by Eric Wong
parent 2d602e9179
commit 7d9fd459f1

View File

@ -670,7 +670,11 @@ sub cmd_create_ignore {
$gs->prop_walk($gs->{path}, $r, sub {
my ($gs, $path, $props) = @_;
# $path is of the form /path/to/dir/
my $ignore = '.' . $path . '.gitignore';
$path = '.' . $path;
# SVN can have attributes on empty directories,
# which git won't track
mkpath([$path]) unless -d $path;
my $ignore = $path . '.gitignore';
my $s = $props->{'svn:ignore'} or return;
open(GITIGNORE, '>', $ignore)
or fatal("Failed to open `$ignore' for writing: $!");