{"thread":{"id":"22105","subject":"[RFC/PATCH] lockfile: show absolute filename in unable_to_lock_message.","startedAt":"2010-01-06T17:01:28Z","lastAt":"2010-01-13T06:56:19Z","messageCount":5,"participants":["Matthieu Moy","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"130925","messageId":"1262797288-23004-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"22105","inReplyTo":null,"subject":"[RFC/PATCH] lockfile: show absolute filename in unable_to_lock_message.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2010-01-06T17:01:28Z","receivedAt":"2010-01-06T17:01:28Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"When calling a git command from a subdirectory and a file locking fails,\nthe user will get a path relative to the root of the worktree, which is\ninvalid from the place where the command is ran. Make it easy for the\nuser to know which file it is.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nI'm writting this because I just got the situation with students:\n\n- Sir, we broke our repository (git commit interrupted violently).\n- See, the error message tells you what to do.\n- But sir, where is .git/index.lock, we can't find it.\n\nThis patch would have solved their problem. OTOH, an absolute path can\nbe rather long and painfull to read/cut-and-paste. I've tried to show\na path relative to where the command was ran (like\n\"../../.git/index.lock\"), but that's really a painfull to implement\n(one has to provide a prefix argument to all the calls to\nunable_to_lock_*, and even with this, I didn't find the simple way to\nmake the relative path (probably exists somewhere in Git since 'git\nstatus' does this). Then I gave up :-(.\n\n lockfile.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 6851fa5..e31cbc7 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -164,9 +164,10 @@ static char *unable_to_lock_message(const char *path, int err)\n \t\t    \"If no other git process is currently running, this probably means a\\n\"\n \t\t    \"git process crashed in this repository earlier. Make sure no other git\\n\"\n \t\t    \"process is running and remove the file manually to continue.\",\n-\t\t    path, strerror(err));\n+\t\t\t    make_absolute_path(path), strerror(err));\n \t} else\n-\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\", path, strerror(err));\n+\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\",\n+\t\t\t    make_absolute_path(path), strerror(err));\n \treturn strbuf_detach(&buf, NULL);\n }\n \n-- \n1.6.6.76.gd6b23.dirty\n"},{"id":"130940","messageId":"4B44DB6A.2050804@kdbg.org","threadId":"22105","inReplyTo":"1262797288-23004-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC/PATCH] lockfile: show absolute filename in unable_to_lock_message.","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-01-06T18:50:18Z","receivedAt":"2010-01-06T18:50:18Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Matthieu Moy schrieb:\n> -\t\t    path, strerror(err));\n> +\t\t\t    make_absolute_path(path), strerror(err));\n>  \t} else\n> -\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\", path, strerror(err));\n> +\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\",\n> +\t\t\t    make_absolute_path(path), strerror(err));\n\nSince these are merely informative, wouldn't it be more suitable to use \nmake_nonrelative_path()?\n\n-- Hannes\n"},{"id":"130998","messageId":"1262876050-345-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"22105","inReplyTo":"4B44DB6A.2050804@kdbg.org","subject":"[PATCH] lockfile: show absolute filename in unable_to_lock_message.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2010-01-07T14:54:10Z","receivedAt":"2010-01-07T14:54:10Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"When calling a git command from a subdirectory and a file locking fails,\nthe user will get a path relative to the root of the worktree, which is\ninvalid from the place where the command is ran. Make it easy for the\nuser to know which file it is.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n> Since these are merely informative, wouldn't it be more suitable to\n> use make_nonrelative_path()?\n\nSensible, yes.\n\n lockfile.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 6851fa5..b0d74cd 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -164,9 +164,10 @@ static char *unable_to_lock_message(const char *path, int err)\n \t\t    \"If no other git process is currently running, this probably means a\\n\"\n \t\t    \"git process crashed in this repository earlier. Make sure no other git\\n\"\n \t\t    \"process is running and remove the file manually to continue.\",\n-\t\t    path, strerror(err));\n+\t\t\t    make_nonrelative_path(path), strerror(err));\n \t} else\n-\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\", path, strerror(err));\n+\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\",\n+\t\t\t    make_nonrelative_path(path), strerror(err));\n \treturn strbuf_detach(&buf, NULL);\n }\n \n-- \n1.6.6.81.gda96d0\n"},{"id":"131363","messageId":"vpq1vhvk4km.fsf@bauges.imag.fr","threadId":"22105","inReplyTo":"1262876050-345-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] lockfile: show absolute filename in unable_to_lock_message.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-01-12T10:20:09Z","receivedAt":"2010-01-12T10:20:09Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Just ping-ing ...\n\nI think the patch makes sense. Junio, can you either queue the patch,\nor argue against it? I promise I'll be nice if you chose the second\noption ;-).\n\nThanks,\n\nMatthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> When calling a git command from a subdirectory and a file locking fails,\n> the user will get a path relative to the root of the worktree, which is\n> invalid from the place where the command is ran. Make it easy for the\n> user to know which file it is.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n>> Since these are merely informative, wouldn't it be more suitable to\n>> use make_nonrelative_path()?\n>\n> Sensible, yes.\n>\n>  lockfile.c |    5 +++--\n>  1 files changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/lockfile.c b/lockfile.c\n> index 6851fa5..b0d74cd 100644\n> --- a/lockfile.c\n> +++ b/lockfile.c\n> @@ -164,9 +164,10 @@ static char *unable_to_lock_message(const char *path, int err)\n>  \t\t    \"If no other git process is currently running, this probably means a\\n\"\n>  \t\t    \"git process crashed in this repository earlier. Make sure no other git\\n\"\n>  \t\t    \"process is running and remove the file manually to continue.\",\n> -\t\t    path, strerror(err));\n> +\t\t\t    make_nonrelative_path(path), strerror(err));\n>  \t} else\n> -\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\", path, strerror(err));\n> +\t\tstrbuf_addf(&buf, \"Unable to create '%s.lock': %s\",\n> +\t\t\t    make_nonrelative_path(path), strerror(err));\n>  \treturn strbuf_detach(&buf, NULL);\n>  }\n>  \n> -- \n> 1.6.6.81.gda96d0\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"131432","messageId":"7vk4vmsdbg.fsf@alter.siamese.dyndns.org","threadId":"22105","inReplyTo":"1262876050-345-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] lockfile: show absolute filename in unable_to_lock_message.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-13T06:56:19Z","receivedAt":"2010-01-13T06:56:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}