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

Re: [PATCH] shallow: verify shallow file after taking lock

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 27, 2014, 10:18 UTC
Message-ID
<CACsJy8AHwyy0wwFD3fu+Aak+k=bFM1NAWzVSs1G4389UWqZptg@mail.gmail.com>
In-Reply-To
<20140227092227.GA28551@sigill.intra.peff.net>
On Thu, Feb 27, 2014 at 4:22 PM, Jeff King <peff@peff.net> wrote:
Show 6 quoted lines
> On Thu, Feb 27, 2014 at 04:10:12AM -0500, Jeff King wrote:
>
>> I also notice that check_shallow_file_for_update returns early if
>> !is_shallow. Is that safe? Is it possible for another process to have
>> made us shallow since the program began? In that case, we would have to
>> stat() the file always, then complain if it exists and !is_shallow.
I think it's safer to do it your way.
Show 28 quoted lines
>
> That patch would look like this:
>
> diff --git a/shallow.c b/shallow.c
> index 75da07a..e05a241 100644
> --- a/shallow.c
> +++ b/shallow.c
> @@ -139,13 +139,13 @@ void check_shallow_file_for_update(void)
>  {
>         struct stat st;
>
> -       if (!is_shallow)
> -               return;
> -       else if (is_shallow == -1)
> +       if (is_shallow == -1)
>                 die("BUG: shallow must be initialized by now");
>
>         if (stat(git_path("shallow"), &st))
>                 die("shallow file was removed during fetch");
> +       else if (!is_shallow)
> +               die("shallow file appeared during fetch");
>         else if (st.st_mtime != shallow_stat.st_mtime
>  #ifdef USE_NSEC
>                  || ST_MTIME_NSEC(st) != ST_MTIME_NSEC(shallow_stat)
>
> but again, I'm not really clear on whether this is possible.
>
> -Peff
-- 
Duy
Previous: Jeff KingNext: Jeff King
Message 5 of 21 in “upload-pack: allow shallow fetching from a read-only repository”
  1. upload-pack: allow shallow fetching from a read-only repositoryNguyễn Thái Ngọc Duy, Feb 27, 2014
  2. Jeff KingFeb 27, 2014
  3. shallow: verify shallow file after taking lockJeff King, Feb 27, 2014
  4. Jeff KingFeb 27, 2014
  5. Duy NguyenFeb 27, 2014
  6. shallow: use stat_validity to check for up-to-date fileJeff King, Feb 27, 2014
  7. Duy NguyenFeb 27, 2014
  8. shallow: automatically clean up shallow tempfilesJeff King, Feb 27, 2014
  9. upload-pack: allow shallow fetching from a read-only repositoryNguyễn Thái Ngọc Duy, Mar 4, 2014
  10. Junio C HamanoMar 4, 2014
  11. Duy NguyenMar 5, 2014
  12. Junio C HamanoMar 5, 2014
  13. upload-pack: send shallow info over stdin to pack-objectsNguyễn Thái Ngọc Duy, Mar 6, 2014
  14. Junio C HamanoMar 6, 2014
  15. Duy NguyenMar 6, 2014
  16. Junio C HamanoMar 7, 2014
  17. Duy NguyenMar 8, 2014
  18. Junio C HamanoMar 10, 2014
  19. Duy NguyenMar 7, 2014
  20. Junio C HamanoMar 7, 2014
  21. upload-pack: send shallow info over stdin to pack-objectsNguyễn Thái Ngọc Duy, Mar 11, 2014

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.