Commits

Anonymous committed 7c0be4d Merge

Merge branch 'jk/maint-rmdir-fix' into maint

* jk/maint-rmdir-fix:
rm: fix bug in recursive subdirectory removal

  • Participants
  • Parent commits 738820a, 3fc0d13

Comments (0)

Files changed (2)

 		slash = dirs + (slash - name);
 		do {
 			*slash = '\0';
-		} while (rmdir(dirs) && (slash = strrchr(dirs, '/')));
+		} while (rmdir(dirs) == 0 && (slash = strrchr(dirs, '/')));
 		free(dirs);
 	}
 	return 0;

File t/t3600-rm.sh

 	test "$status" != 0
 '
 
+test_expect_success 'rm removes subdirectories recursively' '
+	mkdir -p dir/subdir/subsubdir &&
+	echo content >dir/subdir/subsubdir/file &&
+	git add dir/subdir/subsubdir/file &&
+	git rm -f dir/subdir/subsubdir/file &&
+	! test -d dir
+'
+
 test_done