From: "Stefan-W. Hahn" <stefan.hahn@s-hahn.de>
To: git@vger.kernel.org
Subject: problem with git clone on cygwin
Date: Sat, 6 Jan 2007 18:03:30 +0100 [thread overview]
Message-ID: <20070106170330.GA8041@scotty.home> (raw)
[-- Attachment #1: Type: text/plain, Size: 930 bytes --]
Hi,
running git on Cygwin I have a problem with git clone on local disk,
while packing data.
The problem comes with v1.5.0-rc0. I bisected the problem down to
commit 6d2fa7 as the first bad commit.
It seems to be a problem with cygwin.dll prior v1.5.22 and pread(), if
using an offset!=0. (I'm running cygwin.dll v1.5.21 build date
2006-07-27 and I can't update because of other compatibility problems).
So I tried:
- not to set NO_MMAP to use real mmap
- changing get_data_from_pack() from index-pack.c to used mmap() as
in 042aea8. (I did this because it directly uses pread().)
This solved the problem for my testcase.
The added testcase also succeeds on Linux but just with v1.4.4 or my
patch on Cygwin.
Is there anybody else having the same problem in git universe?
--
Stefan-W. Hahn It is easy to make things.
/ mailto:stefan.hahn@s-hahn.de / It is hard to make things simple.
[-- Attachment #2: ppp.diff --]
[-- Type: text/plain, Size: 2341 bytes --]
diff --git a/Makefile b/Makefile
index 180e1e0..afa5d08 100644
--- a/Makefile
+++ b/Makefile
@@ -368,7 +368,7 @@ ifeq ($(uname_O),Cygwin)
# There are conflicting reports about this.
# On some boxes NO_MMAP is needed, and not so elsewhere.
# Try commenting this out if you suspect MMAP is more efficient
- NO_MMAP = YesPlease
+ #NO_MMAP = YesPlease
NO_IPV6 = YesPlease
X = .exe
endif
diff --git a/index-pack.c b/index-pack.c
index 5f6d128..f1d11a0 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -277,25 +277,27 @@ static void *get_data_from_pack(struct object_entry *obj)
{
unsigned long from = obj[0].offset + obj[0].hdr_size;
unsigned long len = obj[1].offset - from;
- unsigned char *src, *data;
+ unsigned pg_offset = from % getpagesize();
+ unsigned char *map, *data;
z_stream stream;
int st;
- src = xmalloc(len);
- if (pread(pack_fd, src, len, from) != len)
- die("cannot pread pack file: %s", strerror(errno));
+ map = mmap(NULL, len + pg_offset, PROT_READ, MAP_PRIVATE,
+ pack_fd, from - pg_offset);
+ if (map == MAP_FAILED)
+ die("cannot mmap pack file: %s", strerror(errno));
data = xmalloc(obj->size);
memset(&stream, 0, sizeof(stream));
stream.next_out = data;
stream.avail_out = obj->size;
- stream.next_in = src;
+ stream.next_in = map + pg_offset;
stream.avail_in = len;
inflateInit(&stream);
while ((st = inflate(&stream, Z_FINISH)) == Z_OK);
inflateEnd(&stream);
if (st != Z_STREAM_END || stream.total_out != obj->size)
die("serious inflate inconsistency");
- free(src);
+ munmap(map, len + pg_offset);
return data;
}
diff --git a/t/t5610-clone-fail.sh b/t/t5610-clone-fail.sh
new file mode 100755
index 0000000..d46c255
--- /dev/null
+++ b/t/t5610-clone-fail.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+
+test_description='test git-clone failure on cygwin using pread()
+'
+
+. ./test-lib.sh
+
+# Need a repo to clone
+test_create_repo foo2
+
+GIT_AUTHOR_EMAIL=xxxxxxxx@yyyyyyyy.yyyyy.yyyyyyy.yyy
+GIT_COMMITTER_EMAIL=xxxxxxxx@yyyyyyyy.yyyyy.yyyyyyy.yyy
+export GIT_AUTHOR_EMAIL
+export GIT_COMMITTER_EMAIL
+
+(cd foo2 && echo "Hello" > file && git add file && git commit -m 'add file' >/dev/null 2>&1)
+(cd foo2 && echo "Hello2" >> file && git commit -a -m 'test' >/dev/null 2>&1)
+
+test_expect_success \
+ 'clone with resolving' \
+ 'git-clone foo2 bar2'
+
+test_done
next reply other threads:[~2007-01-06 17:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-06 17:03 Stefan-W. Hahn [this message]
2007-01-06 21:40 ` problem with git clone on cygwin Juergen Ruehle
[not found] ` <20070106215919.GB8041@scotty.home>
2007-01-07 9:30 ` Stefan-W. Hahn
2007-01-07 10:46 ` Juergen Ruehle
2007-01-07 11:21 ` Stefan-W. Hahn
2007-01-07 6:00 ` Shawn O. Pearce
2007-01-07 11:17 ` [PATCH] Replacing the system call pread() with real mmap() Stefan-W. Hahn
2007-01-07 11:24 ` Shawn O. Pearce
2007-01-07 16:36 ` Stefan-W. Hahn
2007-01-07 17:10 ` Johannes Schindelin
2007-01-07 20:01 ` Stefan-W. Hahn
2007-01-09 18:51 ` [PATCH] Test for failing pread() on cygwin Stefan-W. Hahn
2007-01-09 18:51 ` [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence Stefan-W. Hahn
2007-01-09 20:21 ` Junio C Hamano
2007-01-07 11:18 ` [PATCH] Test for failing pread() on cygwin Stefan-W. Hahn
2007-01-08 0:19 ` Horst H. von Brand
2007-01-08 17:09 ` Stefan-W. Hahn
[not found] <11683687161816-git-send-email->
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070106170330.GA8041@scotty.home \
--to=stefan.hahn@s-hahn.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).