git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <paolo.bonzini@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Git mailing list <git@vger.kernel.org>
Subject: Re: [PATCH] rollback index if git-commit is interrupted by a signal
Date: Thu, 29 May 2008 15:19:37 +0200	[thread overview]
Message-ID: <483EAD69.9090001@gnu.org> (raw)
In-Reply-To: <alpine.DEB.1.00.0805291341290.13507@racer.site.net>


>>  static void rollback_index_files(void)
>>  {
>> -	switch (commit_style) {
>> -	case COMMIT_AS_IS:
>> -		break; /* nothing to do */
>> -	case COMMIT_NORMAL:
>> -		rollback_lock_file(&index_lock);
>> -		break;
>> -	case COMMIT_PARTIAL:
>> -		rollback_lock_file(&index_lock);
>> -		rollback_lock_file(&false_lock);
>> -		break;
>> -	}
>> +	rollback_lock_file(&index_lock);
>> +	rollback_lock_file(&false_lock);
>>  }
> 
> Your commit message gives _no_ good reason for this change.  As a matter 
> of fact, I imagine that this could be a regression.

Without this change, there could be races between the time the lock file 
is created and the time the commit_style variable is set, leading to the 
rollback not being performed.  You're right however about my sloppiness 
in the commit message: I thought the cover letter did explain this,

	rollback_index_files handles cleanly the case when the lock
	had not been established

but what I meant was *rollback_lock_file* "handles cleanly the case when 
the lock had not been established".  In fact, rollback_lock_file is very 
careful:

         if (lk->filename[0]) {
                 if (lk->fd >= 0)
                         close(lk->fd);
                 unlink(lk->filename);
         }
         lk->filename[0] = 0;

and in turn, lock_file never leaves the filename set

         lk->fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
         if (0 <= lk->fd) {
		...
	}
         else
                 lk->filename[0] = 0;

This has always been like this.  It was there in commit 021b6e45, which 
introduces lockfile.c based on index.c; and it was also there in 415e96c 
which introduced index.c.

Paolo

  reply	other threads:[~2008-05-29 13:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-29  8:03 [PATCH] rollback index if git-commit is interrupted by a signal Paolo Bonzini
2008-05-29 12:42 ` Johannes Schindelin
2008-05-29 13:19   ` Paolo Bonzini [this message]
2008-05-29 14:03     ` Johannes Schindelin
2008-05-29 14:35       ` Paolo Bonzini
2008-05-29 14:42         ` Johannes Schindelin
2008-05-29 14:55           ` [PATCH v2] rollback lock files on more signals than just SIGINT Paolo Bonzini
2008-06-04 11:40             ` Mike Ralphson
2008-06-04 17:29               ` Junio C Hamano
2008-06-05  8:02                 ` Mike Ralphson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=483EAD69.9090001@gnu.org \
    --to=paolo.bonzini@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).