Skip to content

Git removes existing folder when cancelling clone

Jeff King git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4t5600: fix outdated comment about unborn HEADt/t5600-clone-fail-cleanup.sh+1 -10 replies
2/4t5600: modernize stylet/t5600-clone-fail-cleanup.sh+25 -230 replies
3/4clone: factor out dir_exists() helperbuiltin/clone.c+8 -34 replies
4/4clone: do not clean up directories we didn't createbuiltin/clone.c t/t5600-clone-fail-cleanup.sh+67 -94 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] Git removes existing folder when cancelling clone
Quoted 5 lines · Jeff King

So I don't think there's an urgent data-loss bug here; we will only ever destroy an empty directory. However, the original intent was to leave the filesystem as we found it on a failed or aborted clone, and we obviously don't do that in this case. So it might be nice if we could restore it to an empty directory.

Here's a patch series to do that. The first three are just preparatory cleanups; the last one is the interesting bit.

[1/4]: t5600: fix outdated comment about unborn HEAD [2/4]: t5600: modernize style
[3/4]: clone: factor out dir_exists() helper [4/4]: clone: do not clean up directories we didn't create

 builtin/clone.c               |  31 ++++++++++---
 t/t5600-clone-fail-cleanup.sh | 100 +++++++++++++++++++++++++++++++-----------
 2 files changed, 98 insertions(+), 33 deletions(-)

-Peff