From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>,
Victoria Dye <vdye@github.com>,
Derrick Stolee <derrickstolee@github.com>,
git@vger.kernel.org
Subject: Re: What's cooking in git.git (Aug 2022, #08; Wed, 24)
Date: Thu, 25 Aug 2022 06:04:53 -0400 [thread overview]
Message-ID: <YwdJRRuST2SP8ZT7@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqa67s5275.fsf@gitster.g>
On Wed, Aug 24, 2022 at 10:20:30PM -0700, Junio C Hamano wrote:
> * sy/mv-out-of-cone (2022-08-10) 9 commits
> (merged to 'next' on 2022-08-17 at 2316d9ce4d)
> + mv: check overwrite for in-to-out move
> + advice.h: add advise_on_moving_dirty_path()
> + mv: cleanup empty WORKING_DIRECTORY
> + mv: from in-cone to out-of-cone
> + mv: remove BOTH from enum update_mode
> + mv: check if <destination> is a SKIP_WORKTREE_DIR
> + mv: free the with_slash in check_dir_in_index()
> + mv: rename check_dir_in_index() to empty_dir_has_sparse_contents()
> + t7002: add tests for moving from in-cone to out-of-cone
>
> "git mv A B" in a sparsely populated working tree can be asked to
> move a path from a directory that is "in cone" to another directory
> that is "out of cone". Handling of such a case has been improved.
>
> Will merge to 'master'.
> source: <20220809120910.2021413-1-shaoxuan.yuan02@gmail.com>
This topic (and now 'next') segfaults with SANITIZE=address in t7001.
The problem is running:
git mv path1/path2/ .
The "." in the destination is normalized to the empty string by
internal_prefix_pathspec(). But commit c08830de41 (mv: check if
<destination> is a SKIP_WORKTREE_DIR, 2022-08-09) then calls add_slash()
on the result, and it isn't prepared to see an empty string.
This makes the problem go away:
diff --git a/builtin/mv.c b/builtin/mv.c
index 11aea7b4db..6c6385dbb5 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -72,7 +72,7 @@ static const char **internal_prefix_pathspec(const char *prefix,
static const char *add_slash(const char *path)
{
size_t len = strlen(path);
- if (path[len - 1] != '/') {
+ if (len && path[len - 1] != '/') {
char *with_slash = xmalloc(st_add(len, 2));
memcpy(with_slash, path, len);
with_slash[len++] = '/';
but I didn't follow the topic well enough to know if there's anything
subtle (i.e., I'm not sure why we need the slash in the first place, and
whether "./" would be more appropriate, etc). So punting to folks who
were involved. :)
-Peff
next prev parent reply other threads:[~2022-08-25 10:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 5:20 What's cooking in git.git (Aug 2022, #08; Wed, 24) Junio C Hamano
2022-08-25 10:04 ` Jeff King [this message]
2022-08-25 22:21 ` Taylor Blau
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=YwdJRRuST2SP8ZT7@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=shaoxuan.yuan02@gmail.com \
--cc=vdye@github.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).