summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmos Waterland <apw@rossby.metr.ou.edu>2005-09-01 14:13:50 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-09-02 04:45:00 (GMT)
commit89bc8c785e20258efba3b2b5ffc26098fa0b8bc8 (patch)
tree3260ded767eb47cfa959cdc46d35ef9e4b6d1a16
parenta1d4aa742416953a3ac9be9154c55e90a4193cd6 (diff)
downloadgit-89bc8c785e20258efba3b2b5ffc26098fa0b8bc8.zip
git-89bc8c785e20258efba3b2b5ffc26098fa0b8bc8.tar.gz
git-89bc8c785e20258efba3b2b5ffc26098fa0b8bc8.tar.bz2
[PATCH] Explain what went wrong on update-cache of new file
If somebody tries to run `git update-cache foo', where foo is a new file, git dies with a rather cryptic error message: fatal: Unable to add foo to database This trivial patch makes git explain what probably went wrong. It is not a perfect diagnosis of all error paths, but for 90% of the cases it should provide the user with the clue they need. [jc: I ended up wording slightly differently, and fixed another confusing error message I noticed while reviewing the code.] Signed-off-by: Amos Waterland <apw@rossby.metr.ou.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--update-cache.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/update-cache.c b/update-cache.c
index 63815ed..3d1fd2b 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -53,7 +53,11 @@ static int add_file_to_cache(char *path)
if (allow_remove)
return remove_file_from_cache(path);
}
- return error("open(\"%s\"): %s", path, strerror(errno));
+ if (0 == status)
+ return error("%s: is a directory", path);
+ else
+ return error("lstat(\"%s\"): %s", path,
+ strerror(errno));
}
namelen = strlen(path);
size = cache_entry_size(namelen);
@@ -393,7 +397,7 @@ int main(int argc, char **argv)
continue;
}
if (add_file_to_cache(path))
- die("Unable to add %s to database", path);
+ die("Unable to add %s to database; maybe you want to use --add option?", path);
}
if (write_cache(newfd, active_cache, active_nr) ||
commit_index_file(&cache_file))