X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=dir.c;h=d0999ba055367c31571b251fb34bb46ed6c7051d;hb=39c448c19de7269e6130b6e183645c5b9afe0579;hp=e05b850acf69867f2b931e7ca2f7430a9e7fc22d;hpb=6517452d7a4269e9a34648a28b8931640299f458;p=git.git diff --git a/dir.c b/dir.c index e05b850ac..d0999ba05 100644 --- a/dir.c +++ b/dir.c @@ -861,12 +861,20 @@ int is_empty_dir(const char *path) return ret; } -int remove_dir_recursively(struct strbuf *path, int only_empty) +int remove_dir_recursively(struct strbuf *path, int flag) { - DIR *dir = opendir(path->buf); + DIR *dir; struct dirent *e; int ret = 0, original_len = path->len, len; + int only_empty = (flag & REMOVE_DIR_EMPTY_ONLY); + unsigned char submodule_head[20]; + if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) && + !resolve_gitlink_ref(path->buf, "HEAD", submodule_head)) + /* Do not descend and nuke a nested git work tree. */ + return 0; + + dir = opendir(path->buf); if (!dir) return -1; if (path->buf[original_len - 1] != '/')