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

Re: [PATCH] Better error message when we are unable to lock the index file

From
Junio C Hamano <junkio@cox.net>
Date
Aug 12, 2006, 08:09 UTC
Message-ID
<7v4pwiqss7.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7v8xluqt24.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 24 quoted lines
> Looking at output from:
>
> 	$ git grep -A 3 hold_lock_file_for_update
>
> I wonder if it might be more consistent to do something like
> this instead.  It removes more lines than it adds ;-).
>
> Most of the callers except the one in refs.c use the function to
> update the index file.  Among the index writers, everybody
> except write-tree dies if they cannot open it for writing.
>
> diff --git a/refs.c b/refs.c
> index 28a9394..564f8a7 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -319,7 +319,7 @@ static struct ref_lock *lock_ref_sha1_ba
>  
>  	if (safe_create_leading_directories(lock->ref_file))
>  		die("unable to create directory for %s", lock->ref_file);
> -	lock->lock_fd = hold_lock_file_for_update(lock->lk, lock->ref_file);
> +	lock->lock_fd = hold_lock_file_for_update(lock->lk, lock->ref_file, 0);
>  	if (lock->lock_fd < 0) {
>  		error("Couldn't open lock file %s: %s",
>  		      lock->lk->filename, strerror(errno));

Looking at this part further, it seems that this one could simply die when it fails -- after all it dies when leading directories cannot be created, so dying upon failure of hold_lock_file_for_update() would be consistent ;-).

Which makes write-tree the only odd-man-out.
Previous: Junio C HamanoNext: Shawn Pearce
Message 3 of 5 in “Better error message when we are unable to lock the index file”
  1. Better error message when we are unable to lock the index fileFredrik Kuivinen, Aug 12, 2006
  2. Junio C HamanoAug 12, 2006
  3. Junio C HamanoAug 12, 2006
  4. Shawn PearceAug 12, 2006
  5. Fredrik KuivinenAug 12, 2006

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.