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

Re: [PATCH v2 1/1] bundle: cleanup lock files on error

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Nov 14, 2018, 21:43 UTC
Message-ID
<CAN0heSqsjKksKnBHjffVMDEyX4A2DAY6Naw4tbBXEm+AdhOLtA@mail.gmail.com>
In-Reply-To
<c88887f05a145709be9e86d56f4c1e620eb5ea89.1542209112.git.gitgitgadget@gmail.com>

On Wed, 14 Nov 2018 at 16:26, Gaël Lhez via GitGitGadget <gitgitgadget@gmail.com> wrote:

> However, the `.lock` file was still open and on Windows that means
> that it could not be deleted properly. This patch fixes that issue.
Hmmm, doesn't the tempfile machinery remove the lock file when we die?
Show 9 quoted lines
>         ref_count = write_bundle_refs(bundle_fd, &revs);
> -       if (!ref_count)
> -               die(_("Refusing to create empty bundle."));
> -       else if (ref_count < 0)
> +       if (ref_count <= 0)  {
> +               if (!ref_count)
> +                       error(_("Refusing to create empty bundle."));
>                 goto err;
> +       }
One less `die()` in libgit -- nice.
> +test_expect_success 'try to create a bundle with empty ref count' '
> +       test_expect_code 1 git bundle create foobar.bundle master..master
> +'

This tries to make sure that we don't just die, but that we exit in a "controlled" way with exit code 1. After reading the log message, I had perhaps expected something like

  test_must_fail git bundle [...] &&
  test_path_is_missing foobar.bundle.lock

That relies on magically knowing the ".lock" suffix, but my point is that for me (on Linux), this alternative test passes both before and after the patch. Before, because tempfile.c cleans up; after, because bundle.c does so. Doesn't this happen on Windows too? What am I missing?

Martin
Previous: Gaël Lhez via GitGitGadgetNext: Stefan Beller
Message 7 of 20 in “bundle: fix issue when bundles would be empty”
  1. 0/1 bundle: fix issue when bundles would be emptyJohannes Schindelin via GitGitGadget, Nov 13, 2018
  2. 1/1 bundle: refuse to create empty bundleGaël Lhez via GitGitGadget, Nov 13, 2018
  3. Stefan BellerNov 13, 2018
  4. Gaël LhezNov 13, 2018
  5. 0/1 bundle: fix issue when bundles would be emptyJohannes Schindelin via GitGitGadget, Nov 14, 2018
  6. 1/1 bundle: cleanup lock files on errorGaël Lhez via GitGitGadget, Nov 14, 2018
  7. Martin ÅgrenNov 14, 2018
  8. Stefan BellerNov 14, 2018
  9. Jeff KingNov 15, 2018
  10. Johannes SchindelinNov 15, 2018
  11. Jeff KingNov 15, 2018
  12. Johannes SchindelinNov 15, 2018
  13. Jeff KingNov 15, 2018
  14. Johannes SchindelinNov 15, 2018
  15. bundle: dup() output descriptor closer to point-of-useJeff King, Nov 16, 2018
  16. Johannes SchindelinNov 16, 2018
  17. Junio C HamanoNov 17, 2018
  18. Duy NguyenNov 15, 2018
  19. Stefan BellerNov 13, 2018
  20. Johannes SchindelinNov 14, 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.