threads / patch / 31341

patch, 2 partsIgnore trailing slash in mkdir() on platforms that can't deal with this

Subject: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this

## tl;dr

3 messages between Aug 24, 2012 and Aug 24, 2012. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Joachim Schmitz· Aug 24, 2012, 10:31 UTC · lore
Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
---
 compat/mkdir.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 compat/mkdir.c
Show changes to compat/mkdir.c +24 −0
diff --git a/compat/mkdir.c b/compat/mkdir.c
new file mode 100644
index 0000000..9e253fb
--- /dev/null
+++ b/compat/mkdir.c
@@ -0,0 +1,24 @@
+#include "../git-compat-util.h"
+#undef mkdir
+
+/* for platforms that can't deal with a trailing '/' */
+int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
+{
+	int retval;
+	char *tmp_dir = NULL;
+	size_t len = strlen(dir);
+
+	if (len && dir[len-1] == '/') {
+		if ((tmp_dir = strdup(dir)) == NULL)
+			return -1;
+		tmp_dir[len-1] = '\0';
+	}
+	else
+		tmp_dir = (char *)dir;
+
+	retval = mkdir(tmp_dir, mode);
+	if (tmp_dir != dir)
+		free(tmp_dir);
+
+	return retval;
+}
-- 
1.7.12
Junio C Hamano· Aug 24, 2012, 17:43 UTC · re: Joachim Schmitz · lore

Re: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this

As the compat/mkdir.c file includes git-compat-util.h and expects the declaration of the new function to be found in it, it does not make any sense to have this as two patches. I'll squash them into one for now, but it would have been even more complete to have an update to the Makefile to actually compile these files in the same change. These things go together.

The other itimer set shares the same issue. I've queued mkdir and itimer series as one patch each; please check the result in 'pu' after I push it out.

Thanks.
Joachim Schmitz· Aug 24, 2012, 18:32 UTC · re: Junio C Hamano · lore

RE: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this

Show 12 quoted lines
> From: Junio C Hamano [mailto:gitster@pobox.com]
> Sent: Friday, August 24, 2012 7:44 PM
> To: Joachim Schmitz
> Cc: git@vger.kernel.org
> Subject: Re: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this
> 
> As the compat/mkdir.c file includes git-compat-util.h and expects
> the declaration of the new function to be found in it, it does not
> make any sense to have this as two patches.  I'll squash them into
> one for now, but it would have been even more complete to have an
> update to the Makefile to actually compile these files in the same
> change.  These things go together.
A changed Makefile is in the pipeline, but right now it is pretty NonStop specific, 
while I tried to keep compat/itimer.cm compat/mkdir.c and git-compat-util.h 
as NonStop independent as I possible could.
That Makefile also depends on the outcome of the discussion about my 
NonStop specific changed in git-compat.util.h
 
> The other itimer set shares the same issue.  I've queued mkdir and
> itimer series as one patch each; please check the result in 'pu'
> after I push it out.
 
Thanks. What does 'pu' stand for?
Bye, Jojo

← back to recent threads