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

Re: [PATCH 3/5] merge-recursive: always roll back lock in `merge_recursive_generic()`

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Feb 28, 2018, 11:02 UTC
Message-ID
<CAN0heSqmWAN=rCO8busGtb0xNPiB5H_jkL664qH8xasPq1Sy0A@mail.gmail.com>
In-Reply-To
<b19db05a8d8a98977788c04908134915eebc86a3.1519763396.git.martin.agren@gmail.com>
On 27 February 2018 at 22:30, Martin Ågren <martin.agren@gmail.com> wrote:
Show 23 quoted lines
> If we return early, we forget to roll back the lockfile. Do so.
>
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
>  merge-recursive.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/merge-recursive.c b/merge-recursive.c
> index cc5fa0a949..7345125691 100644
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -2198,8 +2198,10 @@ int merge_recursive_generic(struct merge_options *o,
>         hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
>         clean = merge_recursive(o, head_commit, next_commit, ca,
>                         result);
> -       if (clean < 0)
> +       if (clean < 0) {
> +               rollback_lock_file(&lock);
>                 return clean;
> +       }
>
>         if (active_cache_changed &&
>             write_locked_index(&the_index, &lock, COMMIT_LOCK))

This is incomplete. If "!active_cache_changed", this function fails to roll back the lock. I'll reroll this series.

This also highlights the point Peff made in [1] about how that "active_cache_changed &&" can be confusing. I'll look into the added or extended API he proposed, although perhaps not as part of the reroll.

Martin
[1] https://public-inbox.org/git/20180227214430.GC6899@sigill.intra.peff.net/
Previous: Martin ÅgrenNext: Martin Ågren
Message 8 of 26 in “roll back locks in various code paths”
  1. 0/5 roll back locks in various code pathsMartin Ågren, Feb 27, 2018
  2. 1/5 sequencer: make lockfiles non-staticMartin Ågren, Feb 27, 2018
  3. 2/5 sequencer: always roll back lock in `do_recursive_merge()`Martin Ågren, Feb 27, 2018
  4. Jeff KingFeb 27, 2018
  5. Martin ÅgrenFeb 27, 2018
  6. Jeff KingFeb 27, 2018
  7. 3/5 merge-recursive: always roll back lock in `merge_recursive_generic()`Martin Ågren, Feb 27, 2018
  8. Martin ÅgrenFeb 28, 2018
  9. 0/5 roll back locks in various code pathsMartin Ågren, Feb 28, 2018
  10. 1/5 sequencer: make lockfiles non-staticMartin Ågren, Feb 28, 2018
  11. 2/5 sequencer: always roll back lock in `do_recursive_merge()`Martin Ågren, Feb 28, 2018
  12. 5/5 sequencer: do not roll back lockfile unnecessarilyMartin Ågren, Feb 28, 2018
  13. 4/5 merge: always roll back lock in `checkout_fast_forward()`Martin Ågren, Feb 28, 2018
  14. 3/5 merge-recursive: always roll back lock in `merge_recursive_generic()`Martin Ågren, Feb 28, 2018
  15. Martin ÅgrenFeb 28, 2018
  16. Junio C HamanoFeb 28, 2018
  17. Martin ÅgrenMar 1, 2018
  18. Jeff KingMar 1, 2018
  19. Junio C HamanoMar 1, 2018
  20. Martin ÅgrenMar 1, 2018
  21. Jeff KingMar 2, 2018
  22. Jeff KingMar 1, 2018
  23. 4/5 merge: always roll back lock in `checkout_fast_forward()`Martin Ågren, Feb 27, 2018
  24. 5/5 sequencer: do not roll back lockfile unnecessarilyMartin Ågren, Feb 27, 2018
  25. Jeff KingFeb 27, 2018
  26. Junio C HamanoFeb 27, 2018

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.