bug: delete_extras_walk unconditionally calls rmdir on directories #43
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In src/shared/utils.c:84-121, the delete_extras_walk function has a bug in directory handling:
The
rmdir(abs_path)at the end is called unconditionally for every directory, including:If the directory still contains files (matched by manifest), rmdir will fail with ENOTEMPTY but the error is not checked. This is likely the intended behavior (failing silently for directories with preserved files), but it should at least log a debug message.
More critically, the root destination directory is always passed to rmdir after processing, which will always fail (since it contains preserved files).
Fix: Only call rmdir if the directory no longer contains any files after deletion processing, or at minimum check the return value.
Severity: medium