From: Jeff King <peff@peff.net>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 2/5] sequencer: always roll back lock in `do_recursive_merge()`
Date: Tue, 27 Feb 2018 16:44:30 -0500 [thread overview]
Message-ID: <20180227214430.GC6899@sigill.intra.peff.net> (raw)
In-Reply-To: <5d657ac87d1e71fd95175faed2b591fa609b8f1c.1519763396.git.martin.agren@gmail.com>
On Tue, Feb 27, 2018 at 10:30:10PM +0100, Martin Ågren wrote:
> diff --git a/sequencer.c b/sequencer.c
> index 90807c4559..e6bac4692a 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -465,8 +465,10 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
> fputs(o.obuf.buf, stdout);
> strbuf_release(&o.obuf);
> diff_warn_rename_limit("merge.renamelimit", o.needed_rename_limit, 0);
> - if (clean < 0)
> + if (clean < 0) {
> + rollback_lock_file(&index_lock);
> return clean;
> + }
>
> if (active_cache_changed &&
> write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
This addition is obviously correct.
I want to note one thing that confused me while reviewing. While looking
to see if there were other returns, I noticed that the lines right near
the end of your context are funny:
if (active_cache_changed &&
write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
/*
* TRANSLATORS: %s will be "revert", "cherry-pick" or
* "rebase -i".
*/
return error(_("%s: Unable to write new index file"),
_(action_name(opts)));
rollback_lock_file(&index_lock);
At first I thought that rollback was a noop, since write_locked_index()
would always either commit or rollback. But it's needed for the case
when we active_cache_changed isn't true.
So I think it's correct as-is, but I wonder if writing it as:
if (!active_cache_changed)
rollback_lock_file(&index_lock);
else if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
return error(...);
might be easier to follow. I'm OK with leaving it, too, but thought I'd
mention it in case it confused other reviewers.
-Peff
next prev parent reply other threads:[~2018-02-27 21:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 21:30 [PATCH 0/5] roll back locks in various code paths Martin Ågren
2018-02-27 21:30 ` [PATCH 1/5] sequencer: make lockfiles non-static Martin Ågren
2018-02-27 21:30 ` [PATCH 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-27 21:44 ` Jeff King [this message]
2018-02-27 22:08 ` Martin Ågren
2018-02-27 22:15 ` Jeff King
2018-02-27 21:30 ` [PATCH 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 11:02 ` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 19:07 ` [PATCH v2 1/5] sequencer: make lockfiles non-static Martin Ågren
2018-02-28 19:07 ` [PATCH v2 2/5] sequencer: always roll back lock in `do_recursive_merge()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-28 19:07 ` [PATCH v2 5/5] sequencer: do not roll back lockfile unnecessarily Martin Ågren
2018-02-28 19:58 ` [PATCH v2 0/5] roll back locks in various code paths Martin Ågren
2018-02-28 23:20 ` Junio C Hamano
2018-03-01 6:18 ` Martin Ågren
2018-03-01 7:41 ` Jeff King
2018-03-01 19:24 ` Junio C Hamano
2018-03-01 20:40 ` Martin Ågren
2018-03-02 10:49 ` Jeff King
2018-03-01 7:38 ` Jeff King
2018-02-27 21:30 ` [PATCH 4/5] merge: always roll back lock in `checkout_fast_forward()` Martin Ågren
2018-02-27 21:30 ` [PATCH 5/5] sequencer: do not roll back lockfile unnecessarily Martin Ågren
2018-02-27 21:47 ` [PATCH 0/5] roll back locks in various code paths Jeff King
2018-02-27 23:42 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180227214430.GC6899@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=martin.agren@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).