* Problem pushing to a Novell share
@ 2012-02-02 22:54 Rüdiger Kessel
2012-02-02 23:45 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Rüdiger Kessel @ 2012-02-02 22:54 UTC (permalink / raw)
To: git
Hi
a push to an .git-repository on a Novell network-share using msysgit
fails with the following error message:
error: unable to create temporary sha1 filename : File exists
The problem has been found in git version 1.7.9
The problem is caused by a non-existing sub-directory in the file path
which is not automatically created on Novell shares.
A quick fix is to improve the create_tmpfile() function in sha1_file.c:
static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
{
static struct stat sb;
int fd, dirlen = directory_size(filename);
if (dirlen + 20 > bufsiz) {
errno = ENAMETOOLONG;
return -1;
}
memcpy(buffer, filename, dirlen);
buffer[dirlen-1] = 0;
if (stat(buffer, &sb) != 0 && errno == ENOENT) {
if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
return -1;
}
memcpy(buffer, filename, dirlen);
strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
fd = git_mkstemp_mode(buffer, 0444);
return fd;
}
The function will create one missing directory level if it does not
exist prior to creating the tmp-file.
This method seems to work, but it works only if one directory level is
missing which might not be the case in general. A better solution
would be to create the whole directory tree if needed.
The best solution would be if MINGW would handle this issue.
I recommend including this patch into GIT since it does no harm on
posix systems but it improves compatibility on others.
Rüdiger
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem pushing to a Novell share
2012-02-02 22:54 Problem pushing to a Novell share Rüdiger Kessel
@ 2012-02-02 23:45 ` Junio C Hamano
[not found] ` <CAJ4nRM1K=sCy8_0PG-NADVn4T0XG1ELC7AvtQyW-Dc1cUMzEXQ@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2012-02-02 23:45 UTC (permalink / raw)
To: Rüdiger Kessel; +Cc: git
Rüdiger Kessel <ruediger.kessel@gmail.com> writes:
> A quick fix is to improve the create_tmpfile() function in sha1_file.c:
>
> static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
> {
> static struct stat sb;
> int fd, dirlen = directory_size(filename);
>
> if (dirlen + 20 > bufsiz) {
> errno = ENAMETOOLONG;
> return -1;
> }
>
> memcpy(buffer, filename, dirlen);
> buffer[dirlen-1] = 0;
> if (stat(buffer, &sb) != 0 && errno == ENOENT) {
> if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
> return -1;
> }
>
> memcpy(buffer, filename, dirlen);
> strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
> fd = git_mkstemp_mode(buffer, 0444);
> return fd;
> }
>
> The function will create one missing directory level if it does not
> exist prior to creating the tmp-file.
Please remove your modification above, and follow the code we have. We
try git_mkstemp_mode() first, because it is more common than not having
the leading directory and we do not want to waste an extra stat() every
tie we come here. Only when the first attempt fails by returning error
(i.e. fd < 0 and errno == ENOENT), we try mkdir() and then try again.
If you see "missing directory", it would be because on your system the
code somehow does not notice the failure from the first attempt. Why?
The breakage you are seeing could come from either:
- git_mkstemp_mode(), more specifically, the underlying mkstemp(), not
returning negative when it fails for some reason; or
- when the above fails, it fails to set errno to ENOENT.
and *that* is what needs to be fixed.
I think pessimizing create_tmpfile() like you did is not a fix; it is
sweeping the real problem under the rug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-03 19:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 22:54 Problem pushing to a Novell share Rüdiger Kessel
2012-02-02 23:45 ` Junio C Hamano
[not found] ` <CAJ4nRM1K=sCy8_0PG-NADVn4T0XG1ELC7AvtQyW-Dc1cUMzEXQ@mail.gmail.com>
2012-02-03 1:28 ` Junio C Hamano
[not found] ` <CAJ4nRM3xazYuNyDNE_Ff9ueGPCuH_dRtaE9s-8sLj+hhDFTY2w@mail.gmail.com>
[not found] ` <CAJ4nRM2+u9OcLgJBN7+_rv1OiXETGNhozAfvYtj=hVNTfCMxhQ@mail.gmail.com>
2012-02-03 19:33 ` Junio C Hamano
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).