git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Schuberth <sschuberth@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH v2] Fix safe_create_leading_directories() for Windows
Date: Thu, 02 Jan 2014 21:54:25 +0100	[thread overview]
Message-ID: <52C5D201.5070008@gmail.com> (raw)
In-Reply-To: <52C5D0AB.7050309@gmail.com>

When cloning to a directory "C:\foo\bar" from Windows' cmd.exe where "foo"
does not exist yet, Git would throw an error like

fatal: could not create work tree dir 'c:\foo\bar'.: No such file or directory

Fix this by not hard-coding a platform specific directory separator into
safe_create_leading_directories().

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 sha1_file.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 760dd60..2114c58 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -110,12 +110,15 @@ int safe_create_leading_directories(char *path)
 	char *pos = path + offset_1st_component(path);
 	struct stat st;
 
-	while (pos) {
-		pos = strchr(pos, '/');
-		if (!pos)
-			break;
-		while (*++pos == '/')
-			;
+	while (*pos) {
+		while (!is_dir_sep(*pos)) {
+			++pos;
+			if (!*pos)
+				break;
+		}
+		/* skip consecutive directory separators */
+		while (is_dir_sep(*pos))
+			++pos;
 		if (!*pos)
 			break;
 		*--pos = '\0';
-- 
1.8.4.msysgit.0.1.ge705bba.dirty

  reply	other threads:[~2014-01-02 20:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02 17:22 [PATCH] Fix safe_create_leading_directories() for Windows Sebastian Schuberth
2014-01-02 17:33 ` Johannes Schindelin
2014-01-02 18:11   ` Sebastian Schuberth
2014-01-02 18:18     ` John Keeping
2014-01-02 20:37       ` Sebastian Schuberth
2014-01-02 20:46     ` Johannes Schindelin
2014-01-07 15:43       ` Erik Faye-Lund
2014-01-07 17:56         ` Johannes Schindelin
2014-01-07 21:49           ` Sebastian Schuberth
2014-01-02 19:55   ` Junio C Hamano
2014-01-02 20:42     ` Johannes Schindelin
2014-01-02 20:48     ` Sebastian Schuberth
2014-01-02 20:54       ` Sebastian Schuberth [this message]
2014-01-02 21:10         ` [PATCH v2] " Johannes Schindelin
2014-01-02 21:24         ` Junio C Hamano
2014-01-02 21:51           ` Junio C Hamano
2014-01-02 22:12             ` Junio C Hamano
2014-01-02 21:08       ` [PATCH] " Junio C Hamano
2014-01-02 21:19         ` Johannes Schindelin
2014-01-19  7:00           ` Sebastian Schuberth
2014-01-19  7:26         ` Sebastian Schuberth
2014-01-21 20:09           ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52C5D201.5070008@gmail.com \
    --to=sschuberth@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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).