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

Re: [PATCH 3/4] Teach transport about the gitfile mechanism

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Oct 4, 2011, 21:46 UTC
Message-ID
<CACsJy8AtUWbuXVQxA7jT7rQmAzPpd72trqcSH_6X=P0FBU1vwQ@mail.gmail.com>
In-Reply-To
<CABURp0qkVcpNRyEg8gcNPjv2KbRbdHYk1XsqCjkp8Yrf7T_Lkw@mail.gmail.com>
On Wed, Oct 5, 2011 at 7:08 AM, Phil Hord <phil.hord@gmail.com> wrote:
Show 22 quoted lines
> +static int is_gitfile(const char *url)
> +{
> +       struct stat st;
> +       char buf[9];
> +       int fd, len;
> +       if (stat(url, &st))
> +               return 0;
> +       if (!S_ISREG(st.st_mode))
> +               return 0;
> +       if (st.st_size < 10 || st.st_size > PATH_MAX)
> +               return 1;
> +
> +       fd = open(url, O_RDONLY);
> +       if (fd < 0)
> +               die_errno("Error opening '%s'", url);
> +       len = read_in_full(fd, buf, sizeof(buf));
> +       close(fd);
> +       if (len != sizeof(buf))
> +               die("Error reading %s", url);
> +       return !prefixcmp(buf, "gitdir: ");
> +}
> +

There's similar code in get_repo_path(), builtin/clone.c, added in commit 9b0ebc7 (clone: allow to clone from .git file). Perhaps you can reuse this function there and remove duplicate code.

-- 
Duy
Previous: Phil Hord
Message 2 of 2 in “Teach transport about the gitfile mechanism”
  1. 3/4 Teach transport about the gitfile mechanismPhil Hord, Oct 4, 2011
  2. Nguyen Thai Ngoc DuyOct 4, 2011

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.