diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-12-21 15:29:45 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-12-21 15:29:45 -0800 |
| commit | 504683162642c0db86c844ea37cad339f928ea9c (patch) | |
| tree | 8f4e299d182bb887caf3c07a8f8fce23b3128011 /builtin/prune.c | |
| parent | The fourth batch (diff) | |
| parent | tmp-objdir: disable ref updates when replacing the primary odb (diff) | |
| download | git-504683162642c0db86c844ea37cad339f928ea9c.tar.gz git-504683162642c0db86c844ea37cad339f928ea9c.zip | |
Merge branch 'ns/tmp-objdir' into en/remerge-diff
* ns/tmp-objdir:
tmp-objdir: disable ref updates when replacing the primary odb
tmp-objdir: new API for creating temporary writable databases
Diffstat (limited to 'builtin/prune.c')
| -rw-r--r-- | builtin/prune.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/builtin/prune.c b/builtin/prune.c index 485c9a3c56..c2bcdc07db 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -26,10 +26,22 @@ static int prune_tmp_file(const char *fullpath) return error("Could not stat '%s'", fullpath); if (st.st_mtime > expire) return 0; - if (show_only || verbose) - printf("Removing stale temporary file %s\n", fullpath); - if (!show_only) - unlink_or_warn(fullpath); + if (S_ISDIR(st.st_mode)) { + if (show_only || verbose) + printf("Removing stale temporary directory %s\n", fullpath); + if (!show_only) { + struct strbuf remove_dir_buf = STRBUF_INIT; + + strbuf_addstr(&remove_dir_buf, fullpath); + remove_dir_recursively(&remove_dir_buf, 0); + strbuf_release(&remove_dir_buf); + } + } else { + if (show_only || verbose) + printf("Removing stale temporary file %s\n", fullpath); + if (!show_only) + unlink_or_warn(fullpath); + } return 0; } |
