From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Robert P. J. Day" <rpjday@crashcourse.ca>,
Stephan Janssen <sjanssen@you-get.com>,
"git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH 4/4] clone: do not clean up directories we didn't create
Date: Thu, 04 Jan 2018 15:48:38 -0800 [thread overview]
Message-ID: <xmqq7esxdw2x.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20180102211139.GD22556@sigill.intra.peff.net> (Jeff King's message of "Tue, 2 Jan 2018 16:11:39 -0500")
Jeff King <peff@peff.net> writes:
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 04b0d7283f..284651797e 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -502,12 +504,12 @@ static void remove_junk(void)
>
> if (junk_git_dir) {
> strbuf_addstr(&sb, junk_git_dir);
> - remove_dir_recursively(&sb, 0);
> + remove_dir_recursively(&sb, junk_git_dir_flags);
> strbuf_reset(&sb);
> }
> if (junk_work_tree) {
> strbuf_addstr(&sb, junk_work_tree);
> - remove_dir_recursively(&sb, 0);
> + remove_dir_recursively(&sb, junk_work_tree_flags);
> }
> strbuf_release(&sb);
> }
> @@ -972,14 +974,24 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> if (safe_create_leading_directories_const(work_tree) < 0)
> die_errno(_("could not create leading directories of '%s'"),
> work_tree);
> - if (!dest_exists && mkdir(work_tree, 0777))
> + if (dest_exists)
> + junk_work_tree_flags |= REMOVE_DIR_KEEP_TOPLEVEL;
> + else if (mkdir(work_tree, 0777))
> die_errno(_("could not create work tree dir '%s'"),
> work_tree);
> junk_work_tree = work_tree;
> set_git_work_tree(work_tree);
> }
>
> - junk_git_dir = real_git_dir ? real_git_dir : git_dir;
> + if (real_git_dir) {
> + if (dir_exists(real_git_dir))
> + junk_git_dir_flags |= REMOVE_DIR_KEEP_TOPLEVEL;
> + junk_git_dir = real_git_dir;
> + } else {
> + if (dest_exists)
> + junk_git_dir_flags |= REMOVE_DIR_KEEP_TOPLEVEL;
> + junk_git_dir = git_dir;
> + }
> if (safe_create_leading_directories_const(git_dir) < 0)
> die(_("could not create leading directories of '%s'"), git_dir);
The changes all look reasonable.
Thanks.
prev parent reply other threads:[~2018-01-04 23:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 11:10 Git removes existing folder when cancelling clone Stephan Janssen
2018-01-02 11:12 ` Robert P. J. Day
2018-01-02 20:04 ` Jeff King
2018-01-02 21:07 ` [PATCH 0/4] " Jeff King
2018-01-02 21:08 ` [PATCH 1/4] t5600: fix outdated comment about unborn HEAD Jeff King
2018-01-02 21:09 ` [PATCH 2/4] t5600: modernize style Jeff King
2018-01-02 21:10 ` [PATCH 3/4] clone: factor out dir_exists() helper Jeff King
2018-01-04 23:47 ` Junio C Hamano
2018-01-04 23:54 ` Jeff King
2018-01-05 0:22 ` Jeff King
2018-01-05 19:19 ` Junio C Hamano
2018-01-02 21:11 ` [PATCH 4/4] clone: do not clean up directories we didn't create Jeff King
2018-01-02 22:49 ` Eric Sunshine
2018-01-02 23:39 ` Jeff King
2018-01-05 18:50 ` Junio C Hamano
2018-01-04 23:48 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7esxdw2x.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=rpjday@crashcourse.ca \
--cc=sjanssen@you-get.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).