From: Nguyen Thai Ngoc Duy Date: Tue, 04 Oct 2011 21:46:33 GMT Subject: Re: [PATCH 3/4] Teach transport about the gitfile mechanism Message-ID: In-Reply-To: On Wed, Oct 5, 2011 at 7:08 AM, Phil Hord wrote: > +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