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

Re: git-rm -n leaves .git/index.lock if not allowed to finish

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2008, 00:38 UTC
Message-ID
<7v4p11f18d.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20081219002524.GB21154@genesis.frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
Show 29 quoted lines
> On Fri, Dec 19, 2008 at 04:02:48AM +0800, jidanni@jidanni.org wrote:
>> Bug: if git-rm -n is not allowed to write all it wants to write, it
>> will leave a .git/index.lock file:
>> # git-rm -n -r . 2>&1|sed q
>> error: '.etckeeper' has changes staged in the index
>> # git-rm -n -r . 2>&1|sed q
>> fatal: unable to create '.git/index.lock': File exists
>
> Can't reproduce:
>
> diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
> index b7d46e5..1581691 100755
> --- a/t/t3600-rm.sh
> +++ b/t/t3600-rm.sh
> @@ -251,4 +251,12 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
>  
>  '
>  
> +test_expect_success 'test from jidanni' '
> +
> +	git reset --hard &&
> +	git rm -n -r . 2>&1|sed q &&
> +	git rm -n -r . 2>&1|sed q
> +
> +'
> +
>  test_done
>
> passes here just fine. Yes, there are multiple files in the repo.

I think you need to have tons of files to cause the pipe buffer to fill up with the "rm 'frotz'" output, triggering a SIGPIPE to kill the upstream process of the pipe.

Would this patch help?
 lockfile.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git i/lockfile.c w/lockfile.c
index 6d75608..8589155 100644
--- i/lockfile.c
+++ w/lockfile.c
@@ -140,6 +140,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
 			signal(SIGHUP, remove_lock_file_on_signal);
 			signal(SIGTERM, remove_lock_file_on_signal);
 			signal(SIGQUIT, remove_lock_file_on_signal);
+			signal(SIGPIPE, remove_lock_file_on_signal);
 			atexit(remove_lock_file);
 		}
 		lk->owner = getpid();
Previous: Miklos VajnaNext: Junio C Hamano
Message 5 of 6 in “git-rm -n leaves .git/index.lock if not allowed to finish”
  1. jidanni@jidanni.orgDec 18, 2008
  2. Miklos VajnaDec 19, 2008
  3. Junio C HamanoDec 19, 2008
  4. Miklos VajnaDec 19, 2008
  5. Junio C HamanoDec 19, 2008
  6. Junio C HamanoDec 19, 2008

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.