summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2014-12-02 21:27:34 -0800
committerJunio C Hamano <gitster@pobox.com>2014-12-03 14:45:03 -0800
commit2692890c9015d93311f01c4d0a74a5e16ac610da (patch)
treeffea03cb666253107e9dc0a288ba8ed03211692b
parentbd3c760bf47b68b5361fd6c602984015e4057d4c (diff)
downloadgit-jn/copy-errno.tar.gz
lockfile: make 'unable_to_lock_message' privatejn/copy-errno
The old external callers now use the message passed back by hold_lock_file_for_update / hold_lock_file_for_append instead of trying to interpret errno. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--lockfile.c42
-rw-r--r--lockfile.h2
2 files changed, 21 insertions, 23 deletions
diff --git a/lockfile.c b/lockfile.c
index 8d8d5ed4b2..7121370e6d 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -98,6 +98,27 @@ static void resolve_symlink(struct strbuf *path)
strbuf_reset(&link);
}
+static void unable_to_lock_message(const char *path, int flags, int err,
+ struct strbuf *buf)
+{
+ if (err != EEXIST) {
+ strbuf_addf(buf, "Unable to create '%s.lock': %s",
+ absolute_path(path), strerror(err));
+ } else if (flags & LOCK_OUTSIDE_REPOSITORY) {
+ strbuf_addf(buf, "Unable to create '%s.lock': %s.\n\n"
+ "If no other git process is currently running, this probably means\n"
+ "another git process crashed earlier. Make sure no other git process\n"
+ "is running and remove the file manually to continue.",
+ absolute_path(path), strerror(err));
+ } else {
+ 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.",
+ absolute_path(path), strerror(err));
+ }
+}
+
static int lock_file(struct lock_file *lk, const char *path,
int flags, struct strbuf *err)
{
@@ -149,27 +170,6 @@ static int lock_file(struct lock_file *lk, const char *path,
return lk->fd;
}
-void unable_to_lock_message(const char *path, int flags, int err,
- struct strbuf *buf)
-{
- if (err != EEXIST) {
- strbuf_addf(buf, "Unable to create '%s.lock': %s",
- absolute_path(path), strerror(err));
- } else if (flags & LOCK_OUTSIDE_REPOSITORY) {
- strbuf_addf(buf, "Unable to create '%s.lock': %s.\n\n"
- "If no other git process is currently running, this probably means\n"
- "another git process crashed earlier. Make sure no other git process\n"
- "is running and remove the file manually to continue.",
- absolute_path(path), strerror(err));
- } else {
- 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.",
- absolute_path(path), strerror(err));
- }
-}
-
int hold_lock_file_for_update(struct lock_file *lk, const char *path,
int flags, struct strbuf *err)
{
diff --git a/lockfile.h b/lockfile.h
index b4d29a3930..02e26fed85 100644
--- a/lockfile.h
+++ b/lockfile.h
@@ -71,8 +71,6 @@ struct lock_file {
#define LOCK_NO_DEREF 1
#define LOCK_OUTSIDE_REPOSITORY 2
-extern void unable_to_lock_message(const char *path, int, int err,
- struct strbuf *buf);
extern int hold_lock_file_for_update(struct lock_file *, const char *path,
int, struct strbuf *err);
extern int hold_lock_file_for_append(struct lock_file *, const char *path,