Permalink
Browse files

fix handling of submodules that live in subdirectories

If the diff includes a submodule that lives in a subdirectory of
the project, the script fails with "No such file or directory".

For example, if a submodule is located at '<repo root>/lib/sub',
the script fails when it tries to write the submodule SHA1 to
'/tmp/.../lib/sub' because the 'lib' directory does not exist.

This commit teaches diffall to create the subdirectory path in the
tmp location prior to writing the submodule file.

This closes #21 on GitHub

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
  • Loading branch information...
1 parent 762871a commit 1969dfe1cc540bb8b8c20b252a8a7009859fd636 @thenigan committed Apr 3, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 git-diffall.perl
View
@@ -113,11 +113,19 @@ sub setup_dir_diff
# change in the recorded SHA1 for the submodule.
foreach my $path (keys %submodule) {
if (defined $submodule{$path}{left}) {
+ my $dir = dirname($path);
+ unless (-d "$ldir/$dir") {
+ mkpath("$ldir/$dir") or die $!;
+ }
open(my $fh, ">", "$ldir/$path") or die $!;
print($fh "Subproject commit $submodule{$path}{left}");
close($fh);
}
if (defined $submodule{$path}{right}) {
+ my $dir = dirname($path);
+ unless (-d "$rdir/$dir") {
+ mkpath("$rdir/$dir") or die $!;
+ }
open(my $fh, ">", "$rdir/$path") or die $!;
print($fh "Subproject commit $submodule{$path}{right}");
close($fh);

0 comments on commit 1969dfe

Please sign in to comment.