From: Johannes Sixt Date: Tue, 30 Jun 2009 06:48:09 GMT Subject: Re: [PATCH 1/2] Add option to not delete a .git directory in remove_dir_recursively() Message-ID: <4A49B529.7030900@viscovery.net> In-Reply-To: <1246327845-22718-2-git-send-email-jason.k.holden@gmail.com> Jason Holden schrieb: > @@ -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