From: Clemens Buchacher <drizzd@aon.at>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH v2] ignore trailing slashes when creating leading directories
Date: Tue, 2 Sep 2008 22:07:59 +0200 [thread overview]
Message-ID: <20080902200759.GA13451@localhost> (raw)
In-Reply-To: <20080902191322.GA11172@localhost>
Currently, create_leading_directories() will interpret all parts of
paths like 'a/b/c/' as "leading directories". A subsequent call to mkdir
for the tail of the path will fail, because the "File already exists."
This makes sure trailing slashes are ignored.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
Applies to next. Passes regression tests.
sha1_file.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 9ee1ed1..dcb3d22 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -93,12 +93,19 @@ static inline int offset_1st_component(const char *path)
int safe_create_leading_directories(char *path)
{
char *pos = path + offset_1st_component(path);
+ char *next;
struct stat st;
while (pos) {
pos = strchr(pos, '/');
if (!pos)
break;
+ next = pos + 1;
+ while (*next == '/')
+ next++;
+ if (!*next)
+ break;
+
*pos = 0;
if (!stat(path, &st)) {
/* path exists */
--
1.6.0.1.275.gc88b6
next prev parent reply other threads:[~2008-09-02 20:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-02 8:19 [PATCH] ignore trailing slash when creating leading directories Clemens Buchacher
2008-09-02 18:38 ` Junio C Hamano
2008-09-02 19:13 ` Clemens Buchacher
2008-09-02 20:07 ` Clemens Buchacher [this message]
2008-09-02 20:36 ` Junio C Hamano
2008-09-02 21:10 ` Junio C Hamano
2008-09-03 19:02 ` Clemens Buchacher
2008-09-03 18:55 ` [PATCH] clone: fix creation of explicitly named target directory Clemens Buchacher
2008-09-03 19:24 ` 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=20080902200759.GA13451@localhost \
--to=drizzd@aon.at \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.