From: Sergey Vlasov <vsu@altlinux.ru>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH] git-mv: search more precisely for source directory in index
Date: Sun, 3 Dec 2006 23:04:18 +0300 [thread overview]
Message-ID: <20061203200418.GC7971@procyon.home> (raw)
In-Reply-To: <Pine.LNX.4.63.0612032036030.28348@wbgn013.biozentrum.uni-wuerzburg.de>
[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]
On Sun, Dec 03, 2006 at 08:42:47PM +0100, Johannes Schindelin wrote:
>
> A move of a directory should find the entries in the index by
> searching for the name _including_ the slash. Otherwise, the
> directory can be shadowed by a file when it matches the prefix
> and is lexicographically smaller, e.g. "ab.c" shadows "ab/".
Thanks - seems to work now, and the existing tests are not broken.
> Noticed by Sergey Vlasov.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> ---
>
> Good catch. Thanks!
>
> builtin-mv.c | 11 +++++++----
> 1 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/builtin-mv.c b/builtin-mv.c
> index 54dd3bf..d14a4a7 100644
> --- a/builtin-mv.c
> +++ b/builtin-mv.c
> @@ -146,21 +146,24 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
> && lstat(dst, &st) == 0)
> bad = "cannot move directory over file";
> else if (src_is_dir) {
> + const char *src_w_slash = add_slash(src);
> + int len_w_slash = length + 1;
> int first, last;
>
> modes[i] = WORKING_DIRECTORY;
>
> - first = cache_name_pos(src, length);
> + first = cache_name_pos(src_w_slash, len_w_slash);
> if (first >= 0)
> - die ("Huh? %s/ is in index?", src);
> + die ("Huh? %.*s is in index?",
> + len_w_slash, src_w_slash);
>
> first = -1 - first;
> for (last = first; last < active_nr; last++) {
> const char *path = active_cache[last]->name;
> - if (strncmp(path, src, length)
> - || path[length] != '/')
> + if (strncmp(path, src_w_slash, len_w_slash))
> break;
> }
> + free((char *)src_w_slash);
>
> if (last - first < 1)
> bad = "source directory is empty";
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2006-12-03 20:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-03 13:57 [BUG] git-mv fails with "source directory is empty" when it should not Sergey Vlasov
2006-12-03 19:42 ` [PATCH] git-mv: search more precisely for source directory in index Johannes Schindelin
2006-12-03 20:04 ` Sergey Vlasov [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061203200418.GC7971@procyon.home \
--to=vsu@altlinux.ru \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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.
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 NNTP newsgroup(s).