Download raw body.
got rm trim dirs
Hello,
Does it make sense to trim directories during a 'got rm -R .'
opperation? I'm constantly forgetting to remove empty directories
afterwards.
Ok?
--
Tracey Emery
diff ee85c5e898e10f72841c918d9f453a6526ef7e2e /home/basepr1me/src/got
blob - 0e0bef70fa58ed856ec28833fae027d8744acaae
file + lib/worktree.c
--- lib/worktree.c
+++ lib/worktree.c
@@ -3039,6 +3039,16 @@ schedule_for_deletion(void *arg, unsigned char status,
err = got_error_from_errno2("unlink", ondisk_path);
goto done;
}
+ char *parent = dirname(ondisk_path);
+ while (parent && strcmp(parent, a->worktree->root_path) != 0) {
+ if (rmdir(parent) == -1) {
+ if (errno != ENOTEMPTY)
+ err = got_error_from_errno2("rmdir",
+ parent);
+ break;
+ }
+ parent = dirname(parent);
+ }
}
got_fileindex_entry_mark_deleted_from_disk(ie);
blob - 9ea8be8b1e091a6c1974b3a81b2f05a550bcd266
file + regress/cmdline/rm.sh
--- regress/cmdline/rm.sh
+++ regress/cmdline/rm.sh
@@ -239,6 +239,18 @@ function test_rm_directory {
return 1
fi
+ (cd $testroot/wt && ls -l > $testroot/stdout)
+
+ echo -n '' > $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
test_done "$testroot" "$ret"
}
got rm trim dirs