summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0310676)
raw | patch | inline | side by side (parent: 0310676)
author | Phil Hord <phil.hord@gmail.com> | |
Tue, 4 Oct 2011 20:08:20 +0000 (16:08 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 4 Oct 2011 20:30:38 +0000 (13:30 -0700) |
The transport_get() function assumes that a regular file is a
bundle rather than a local git directory. Look inside the file
for the telltale "gitlink: " header to see if it is actually a
gitfile. If so, do not try to process it as a bundle, but
treat it as a local repository instead.
Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle rather than a local git directory. Look inside the file
for the telltale "gitlink: " header to see if it is actually a
gitfile. If so, do not try to process it as a bundle, but
treat it as a local repository instead.
Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
transport.c | patch | blob | history |
diff --git a/transport.c b/transport.c
index fa279d531fe1b99841424080487e685fbe04e5bb..1707c52446d5937a66c101c142931b3cc0465456 100644 (file)
--- a/transport.c
+++ b/transport.c
has_dos_drive_prefix(url);
}
+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: ");
+}
+
static int is_file(const char *url)
{
struct stat buf;
ret->fetch = fetch_objs_via_rsync;
ret->push = rsync_transport_push;
ret->smart_options = NULL;
- } else if (is_local(url) && is_file(url)) {
+ } else if (is_local(url) && is_file(url) && !is_gitfile(url)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
ret->data = data;
ret->get_refs_list = get_refs_from_bundle;