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

3 messages from 2012-08-24 to 2012-08-24. Participants: Joachim Schmitz, Junio C Hamano.
Thread: https://gitlist.dev/t/31341

## Joachim Schmitz, 2012-08-24 10:31

Subject: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this
Message-ID: <003101cd81e3$90574490$b105cdb0$@schmitz-digital.de>
URL: https://gitlist.dev/e/003101cd81e3%2490574490%24b105cdb0%24%40schmitz-digital.de

```

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
---
 compat/mkdir.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 compat/mkdir.c

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, 2012-08-24 17:43

Subject: Re: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this
Message-ID: <7vr4qwyylv.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr4qwyylv.fsf%40alter.siamese.dyndns.org
In-Reply-To: <003101cd81e3$90574490$b105cdb0$@schmitz-digital.de>

```
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, 2012-08-24 18:32

Subject: RE: [PATCH 1/2] Ignore trailing slash in mkdir() on platforms that can't deal with this
Message-ID: <004701cd8226$e2534ad0$a6f9e070$@schmitz-digital.de>
URL: https://gitlist.dev/e/004701cd8226%24e2534ad0%24a6f9e070%24%40schmitz-digital.de
In-Reply-To: <7vr4qwyylv.fsf@alter.siamese.dyndns.org>

```
> 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

```
