From: Johannes Sixt <j6t@kdbg.org>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org, gitster@pobox.com, Duy Nguyen <pclouds@gmail.com>
Subject: [PATCH mm/mv-file-to-no-such-dir-with-slash] mv: let 'git mv file no-such-dir/' error out on Windows, too
Date: Wed, 08 Jan 2014 17:33:44 +0100 [thread overview]
Message-ID: <52CD7DE8.6070101@kdbg.org> (raw)
In-Reply-To: <1386059524-14442-1-git-send-email-Matthieu.Moy@imag.fr>
The previous commit c57f628 (mv: let 'git mv file no-such-dir/' error out)
relies on that rename("src", "dst/") fails if directory dst does not
exist (note the trailing slash). This does not work as expected on Windows:
This rename() call is successful. Insert an explicit check for this case.
This changes the error message from
$ git mv file no-such-dir/
fatal: renaming 'file' failed: Not a directory
to
$ git mv file no-such-dir/
fatal: destination directory does not exist, source=file, destination=no-such-dir/
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
builtin/mv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/builtin/mv.c b/builtin/mv.c
index 08fbc03..21c46d1 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -214,6 +214,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
}
} else if (string_list_has_string(&src_for_dst, dst))
bad = _("multiple sources for the same target");
+ else if (is_dir_sep(dst[strlen(dst) - 1]))
+ bad = _("destination directory does not exist");
else
string_list_insert(&src_for_dst, dst);
--
1.8.5.2.1473.g6546919
next prev parent reply other threads:[~2014-01-08 16:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 8:32 [PATCH] mv: let 'git mv file no-such-dir/' error out Matthieu Moy
2013-12-03 10:06 ` Duy Nguyen
2013-12-04 8:44 ` Matthieu Moy
2013-12-04 13:10 ` Duy Nguyen
2013-12-04 17:37 ` [PATCH v2] " Matthieu Moy
2013-12-04 17:44 ` [PATCH] " Junio C Hamano
2013-12-04 17:48 ` Matthieu Moy
2014-01-08 16:33 ` Johannes Sixt [this message]
2014-01-09 22:42 ` [PATCH mm/mv-file-to-no-such-dir-with-slash] mv: let 'git mv file no-such-dir/' error out on Windows, too Junio C Hamano
2014-01-10 19:21 ` Johannes Sixt
2014-01-10 19:30 ` Junio C Hamano
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=52CD7DE8.6070101@kdbg.org \
--to=j6t@kdbg.org \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.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).