summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-21 16:04:32 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-21 16:04:32 -0700
commitafd6284a7fdbb479b5c99a87f64d7496f6fe8a27 (patch)
tree8023d7fb1a7be7457d8fcdeba68e7a0ddfa9f6cc /transport.c
parent8963314c77af9a4eda5dcbdbab3d4001af83ad81 (diff)
parent3ac64370164fb80e92c3c9136210d3a49f1e01fa (diff)
downloadgit-afd6284a7fdbb479b5c99a87f64d7496f6fe8a27.tar.gz
Merge branch 'ph/transport-with-gitfile'
* ph/transport-with-gitfile: Fix is_gitfile() for files too small or larger than PATH_MAX to be a gitfile Add test showing git-fetch groks gitfiles Teach transport about the gitfile mechanism Learn to handle gitfiles in enter_repo enter_repo: do not modify input
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/transport.c b/transport.c
index c048ef179b..57138d908a 100644
--- a/transport.c
+++ b/transport.c
@@ -859,6 +859,28 @@ static int is_local(const char *url)
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 > 9 + PATH_MAX)
+ return 0;
+
+ 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;
@@ -907,7 +929,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
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;