aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-11-09 09:40:59 -0800
committerJunio C Hamano <junkio@cox.net>2006-11-09 09:40:59 -0800
commit6a96b32d3b045c6e8d1b553fd6b64e03db9b0e45 (patch)
tree84cc69c74c96960d6315eadd0412daf18319d8dd /sha1_file.c
parent1c791cfbf843fee5c72b5b23c0c3ca8550e15c08 (diff)
parent916d081bbaa40617643b09b6dc9c6760993cf6ed (diff)
downloadgit-6a96b32d3b045c6e8d1b553fd6b64e03db9b0e45.tar.gz
git-6a96b32d3b045c6e8d1b553fd6b64e03db9b0e45.tar.xz
Merge branch 'maint'
* maint: Nicer error messages in case saving an object to db goes wrong
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6ea59b558..09456d23f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1455,8 +1455,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
unlink(tmpfile);
if (ret) {
if (ret != EEXIST) {
- fprintf(stderr, "unable to write sha1 filename %s: %s\n", filename, strerror(ret));
- return -1;
+ return error("unable to write sha1 filename %s: %s\n", filename, strerror(ret));
}
/* FIXME!!! Collision check here ? */
}
@@ -1566,16 +1565,17 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
}
if (errno != ENOENT) {
- fprintf(stderr, "sha1 file %s: %s\n", filename, strerror(errno));
- return -1;
+ return error("sha1 file %s: %s\n", filename, strerror(errno));
}
snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
fd = mkstemp(tmpfile);
if (fd < 0) {
- fprintf(stderr, "unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
- return -1;
+ if (errno == EPERM)
+ return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
+ else
+ return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
}
/* Set it up */
@@ -1690,9 +1690,12 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
snprintf(tmpfile, sizeof(tmpfile), "%s/obj_XXXXXX", get_object_directory());
local = mkstemp(tmpfile);
- if (local < 0)
- return error("Couldn't open %s for %s",
- tmpfile, sha1_to_hex(sha1));
+ if (local < 0) {
+ if (errno == EPERM)
+ return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
+ else
+ return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
+ }
memset(&stream, 0, sizeof(stream));