summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b452cc1)
raw | patch | inline | side by side (parent: b452cc1)
author | Matthieu Moy <Matthieu.Moy@imag.fr> | |
Thu, 19 Feb 2009 12:54:18 +0000 (13:54 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Feb 2009 07:22:57 +0000 (23:22 -0800) |
Just saying that index.lock exists doesn't tell the user _what_ to do
to fix the problem. We should give an indication that it's normally
safe to delete index.lock after making sure git isn't running here.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to fix the problem. We should give an indication that it's normally
safe to delete index.lock after making sure git isn't running here.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-update-index.c | patch | blob | history | |
cache.h | patch | blob | history | |
lockfile.c | patch | blob | history |
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 65d5775107f9013526cc5b288a80a00b449e8814..daca0f775e4b49f2576a7c444895146d05b7022c 100644 (file)
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
if (newfd < 0) {
if (refresh_flags & REFRESH_QUIET)
exit(128);
- die("unable to create '%s.lock': %s",
- get_index_file(), strerror(lock_error));
+ unable_to_lock_index_die(get_index_file(), lock_error);
}
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock_file))
index 3a33b1e82b0db66fad1e0ce45380c8b847aad15f..0e2f219b2b4d9ff5944e68dbaf2338c76055161f 100644 (file)
--- a/cache.h
+++ b/cache.h
};
#define LOCK_DIE_ON_ERROR 1
#define LOCK_NODEREF 2
+extern NORETURN void unable_to_lock_index_die(const char *path, int err);
extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
extern int hold_lock_file_for_append(struct lock_file *, const char *path, int);
extern int commit_lock_file(struct lock_file *);
diff --git a/lockfile.c b/lockfile.c
index 8589155532da9eb7f42a1e9c3132fcf42b1b9275..8e556ff8c9671864db44dc8b6f4a861bd35142a6 100644 (file)
--- a/lockfile.c
+++ b/lockfile.c
return lk->fd;
}
+
+NORETURN void unable_to_lock_index_die(const char *path, int err)
+{
+ if (errno == EEXIST) {
+ die("Unable to create '%s.lock': %s.\n\n"
+ "If no other git process is currently running, this probably means a\n"
+ "git process crashed in this repository earlier. Make sure no other git\n"
+ "process is running and remove the file manually to continue.",
+ path, strerror(err));
+ } else {
+ die("Unable to create '%s.lock': %s", path, strerror(err));
+ }
+}
+
int hold_lock_file_for_update(struct lock_file *lk, const char *path, int flags)
{
int fd = lock_file(lk, path, flags);
if (fd < 0 && (flags & LOCK_DIE_ON_ERROR))
- die("unable to create '%s.lock': %s", path, strerror(errno));
+ unable_to_lock_index_die(path, errno);
return fd;
}