Skip to contentSkip to conversation

Ignore trailing slash in mkdir() on platforms that can't deal with this

PATCH In review Joachim Schmitz 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

---
 compat/mkdir.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 compat/mkdir.c
compat/mkdir.c new file +24 -0
new file mode 100644
index 0000000..9e253fb
@@ -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;
+}
Signature · 1 line
1.7.12
#1 lore raw

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.

#2 lore raw
Quoted 6 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Friday, August 24, 2012 7:44 PM
To: Joachim Schmitz
Cc: [email protected]
Subject: Re: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this

Quoted 6 lines

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

Quoted 3 lines

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