summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-12-21 18:03:10 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-12-21 18:03:10 -0700
commit72c2a54e118ea98657933e7f2dfcbd1b2c8c0bfd (patch)
treef97dedb4e71edb5ba53ed5c8f4609a74f35ebb81
parentf4cd792bd4f017b5febb12fe7c86a03de639b605 (diff)
downloaddotfiles-72c2a54e118ea98657933e7f2dfcbd1b2c8c0bfd.tar.gz
update $commitdir right after the command that might invalidate it
-rwxr-xr-xbin/annex-to-annex12
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/annex-to-annex b/bin/annex-to-annex
index 259a1d55..31fe0ab5 100755
--- a/bin/annex-to-annex
+++ b/bin/annex-to-annex
@@ -55,6 +55,7 @@ my @sources = map rel2abs($_), @ARGV;
# entry in @sources will lie in the same annex
foreach my $source (@sources) {
my $dir = dirname($source);
+ my $commit_dir = $dir;
`git -C "$dir" annex status`;
die "$source does not appear to lie within an annex\n" unless $? eq 0;
die "$source does not exist\n" unless -e $source;
@@ -136,17 +137,12 @@ foreach my $source (@sources) {
}
system('git', '-C', $dir, 'rm', $File::Find::name)
unless -d $File::Find::name;
+ # $commit_dir may no longer exist, as if it was empty,
+ # `git rm` will have removed it
+ $commit_dir = dirname($commit_dir) until -d $commit_dir;
},
$source
);
- # $dir may no longer exist, as if it was empty, `git rm` will have
- # removed it
- my $commit_dir = $dir;
- $commit_dir = dirname($commit_dir) until -d $commit_dir;
-
- # DEBUG
- say "$commit_dir exists";
-
system('git', '-C', $commit_dir, 'commit', '-m',
"migrated by annex-to-annex")
if $do_commit;