summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6bbfd1f)
raw | patch | inline | side by side (parent: 6bbfd1f)
author | Miklos Vajna <vmiklos@frugalware.org> | |
Sat, 26 Sep 2009 23:15:09 +0000 (01:15 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 29 Sep 2009 15:14:47 +0000 (08:14 -0700) |
Previously the old error message just told the user that it was not
possible to delete the ref from the packed-refs file. Give instructions
on how to resolve the problem.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
possible to delete the ref from the packed-refs file. Give instructions
on how to resolve the problem.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
cache.h | patch | blob | history | |
lockfile.c | patch | blob | history | |
refs.c | patch | blob | history |
index 1a6412dfd65e6a2cc733f07a335d8b6b88b4264e..a5eeead1e275523fbc7bc192a836193720370991 100644 (file)
--- a/cache.h
+++ b/cache.h
};
#define LOCK_DIE_ON_ERROR 1
#define LOCK_NODEREF 2
+extern int unable_to_lock_error(const char *path, int err);
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);
diff --git a/lockfile.c b/lockfile.c
index eb931eded5a6ed20f1d80dadf08cbb8009d85767..6851fa55a503bd24dd204934d7433e306996ce09 100644 (file)
--- a/lockfile.c
+++ b/lockfile.c
return lk->fd;
}
-
-NORETURN void unable_to_lock_index_die(const char *path, int err)
+static char *unable_to_lock_message(const char *path, int err)
{
+ struct strbuf buf = STRBUF_INIT;
+
if (err == EEXIST) {
- die("Unable to create '%s.lock': %s.\n\n"
+ strbuf_addf(&buf, "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));
- }
+ } else
+ strbuf_addf(&buf, "Unable to create '%s.lock': %s", path, strerror(err));
+ return strbuf_detach(&buf, NULL);
+}
+
+int unable_to_lock_error(const char *path, int err)
+{
+ char *msg = unable_to_lock_message(path, err);
+ error("%s", msg);
+ free(msg);
+ return -1;
+}
+
+NORETURN void unable_to_lock_index_die(const char *path, int err)
+{
+ die("%s", unable_to_lock_message(path, err));
}
int hold_lock_file_for_update(struct lock_file *lk, const char *path, int flags)
index 24865cf5a6c937834b2a98ccd8d80a652ae5541e..808f56bb27b6ece616f400154fe98c9cef12f8ba 100644 (file)
--- a/refs.c
+++ b/refs.c
if (!found)
return 0;
fd = hold_lock_file_for_update(&packlock, git_path("packed-refs"), 0);
- if (fd < 0)
+ if (fd < 0) {
+ unable_to_lock_error(git_path("packed-refs"), errno);
return error("cannot delete '%s' from packed refs", refname);
+ }
for (list = packed_ref_list; list; list = list->next) {
char line[PATH_MAX + 100];