diff options
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c index 12be17b5da..70ff904717 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -99,7 +99,11 @@ int safe_create_leading_directories(char *path) pos = strchr(pos, '/'); if (!pos) break; - *pos = 0; + while (*++pos == '/') + ; + if (!*pos) + break; + *--pos = '\0'; if (!stat(path, &st)) { /* path exists */ if (!S_ISDIR(st.st_mode)) { @@ -2145,7 +2149,9 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len, */ int move_temp_to_file(const char *tmpfile, const char *filename) { - int ret = link(tmpfile, filename); + int ret = 0; + if (link(tmpfile, filename)) + ret = errno; /* * Coda hack - coda doesn't like cross-directory links, |