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
Fredrik Kuivinen <freku045@student.liu.se>
Date
Aug 12, 2006, 19:19 UTC
Message-ID
<20060812191930.GA5205@c165.ib.student.liu.se>
In-Reply-To
<7v8xluqt24.fsf@assigned-by-dhcp.cox.net>
On Sat, Aug 12, 2006 at 01:03:47AM -0700, Junio C Hamano wrote:
Show 19 quoted lines
> Fredrik Kuivinen <freku045@student.liu.se> writes:
> 
> > diff --git a/builtin-update-index.c b/builtin-update-index.c
> > index 24dca47..f8f5e10 100644
> > --- a/builtin-update-index.c
> > +++ b/builtin-update-index.c
> > @@ -493,7 +493,7 @@ int cmd_update_index(int argc, const cha
> >  
> >  	newfd = hold_lock_file_for_update(lock_file, get_index_file());
> >  	if (newfd < 0)
> > -		die("unable to create new cachefile");
> > +		die("unable to lock index file: %s", strerror(errno));
> 
> 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 ;-).
Looks good, one small comment below.
Show 22 quoted lines
> diff --git a/lockfile.c b/lockfile.c
> index 2346e0e..a5ea49b 100644
> --- a/lockfile.c
> +++ b/lockfile.c
> @@ -22,7 +22,7 @@ static void remove_lock_file_on_signal(i
>  	raise(signo);
>  }
>  
> -int hold_lock_file_for_update(struct lock_file *lk, const char *path)
> +static int lock_file(struct lock_file *lk, const char *path)
>  {
>  	int fd;
>  	sprintf(lk->filename, "%s.lock", path);
> @@ -41,6 +41,14 @@ int hold_lock_file_for_update(struct loc
>  	return fd;
>  }
>  
> +int hold_lock_file_for_update(struct lock_file *lk, const char *path, int die_on_error)
> +{
> +	int fd = lock_file(lk, path);
> +	if (fd < 0 && die_on_error)
> +		die("unable to create new index file");
Could we have (something like)
    die("unable to lock index file: %s", strerror(errno));
here instead?
Show 6 quoted lines
> +	return fd;
> +}
> +
>  int commit_lock_file(struct lock_file *lk)
>  {
> 	char result_file[PATH_MAX];
- Fredrik
Previous: Shawn Pearce
Message 5 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.