Jason Holden schrieb:
quoted hunk ↗ jump to hunk
@@ -812,6 +812,19 @@ int remove_dir_recursively(struct strbuf *path, int only_empty)
strbuf_addch(path, '/');
len = path->len;
+
+ if (keep_dot_git) {
+ char end_of_path[6]; /* enough space for ".git/"*/
+ memset(end_of_path, '\0', 6);
+ if (len >= 5) {
+ strncpy(end_of_path, path->buf + len - 5, 5);
+ if (strcmp(end_of_path, ".git/") == 0) {
+ printf("********Found .git!!!! Skipping delete\n");
I see no reason to ***shout!!!*** here. IOW:
warning("not removing %s", dir);
is enough. This also sends the text to stderr.
+ return 0;
+ }
+ }
+ }
+
while ((e = readdir(dir)) != NULL) {
struct stat st;
if (is_dot_or_dotdot(e->d_name))
I think it is even better to move the check for ".git" below this 'if'. It
should not make a difference in practice.
-- Hannes