diff options
| author | Junio C Hamano <gitster@pobox.com> | 2009-08-16 04:13:13 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2009-08-16 04:13:13 -0700 |
| commit | 14683af812ee0b19c416223287c6e330dbdc9ffc (patch) | |
| tree | 8f6aba92fa7a9e1f088129b1ebc4f6082d4c8d31 /dir.c | |
| parent | b21f9e7f860620571667fba33ed511bed59dfb14 (diff) | |
| parent | a0f4afbe87ddda7902e36350d163dea146166550 (diff) | |
| download | git-14683af812ee0b19c416223287c6e330dbdc9ffc.tar.xz | |
Merge branch 'jc/maint-clean-nested-dir-safety'
* jc/maint-clean-nested-dir-safety:
clean: require double -f options to nuke nested git repository and work tree
Diffstat (limited to 'dir.c')
| -rw-r--r-- | dir.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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] != '/') |
