git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] lockfile: show absolute filename in unable_to_lock_message.

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jan 7, 2010, 14:54 UTC
Message-ID
<1262876050-345-1-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<4B44DB6A.2050804@kdbg.org>

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 <Matthieu.Moy@imag.fr>
---
> Since these are merely informative, wouldn't it be more suitable to
> use make_nonrelative_path()?
Sensible, yes.
 lockfile.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lockfile.c b/lockfile.c
index 6851fa5..b0d74cd 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -164,9 +164,10 @@ static char *unable_to_lock_message(const char *path, int err)
 		    "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));
+			    make_nonrelative_path(path), strerror(err));
 	} else
-		strbuf_addf(&buf, "Unable to create '%s.lock': %s", path, strerror(err));
+		strbuf_addf(&buf, "Unable to create '%s.lock': %s",
+			    make_nonrelative_path(path), strerror(err));
 	return strbuf_detach(&buf, NULL);
 }
 
-- 
1.6.6.81.gda96d0
Previous: Johannes SixtNext: Matthieu Moy
Message 3 of 5 in “lockfile: show absolute filename in unable_to_lock_message.”
  1. lockfile: show absolute filename in unable_to_lock_message.Matthieu Moy, Jan 6, 2010
  2. Johannes SixtJan 6, 2010
  3. lockfile: show absolute filename in unable_to_lock_message.Matthieu Moy, Jan 7, 2010
  4. Matthieu MoyJan 12, 2010
  5. Junio C HamanoJan 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.