Skip to content

Commit a8c37a0

Browse files
moygitster
authored andcommitted
lockfile: show absolute filename in unable_to_lock_message
When calling a git command from a subdirectory and a file locking fails, the user will get a path relative to the root of the worktree, which is invalid from the place where the command is ran. Make it easy for the user to know which file it is. Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0def5b6 commit a8c37a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lockfile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ static char *unable_to_lock_message(const char *path, int err)
164164
"If no other git process is currently running, this probably means a\n"
165165
"git process crashed in this repository earlier. Make sure no other git\n"
166166
"process is running and remove the file manually to continue.",
167-
path, strerror(err));
167+
make_nonrelative_path(path), strerror(err));
168168
} else
169-
strbuf_addf(&buf, "Unable to create '%s.lock': %s", path, strerror(err));
169+
strbuf_addf(&buf, "Unable to create '%s.lock': %s",
170+
make_nonrelative_path(path), strerror(err));
170171
return strbuf_detach(&buf, NULL);
171172
}
172173

0 commit comments

Comments
 (0)