Commit 2aeadb9c78df4b463ffb3293e242e19a7e0d17a9

Chris Young 2012-06-12T19:25:09

Actually do the mmap... unsurprisingly, this makes the indexer work on SFS On RAM: the .idx and .pack files become links to a .lock and the original download respectively. Assume some feature (such as record locking) supported by SFS but not JXFS or RAM: is required.

diff --git a/src/indexer.c b/src/indexer.c
index f0e0a63..5542bfe 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -363,11 +363,11 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 		if (error < 0) {
 			idx->off = entry_start;
 			error = store_delta(idx);
+
 			if (error == GIT_EBUFS)
 				return 0;
 			if (error < 0)
 				return error;
-
 			continue;
 		}
 
diff --git a/src/mwindow.c b/src/mwindow.c
index 57adabd..74fbf78 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -158,6 +158,7 @@ static git_mwindow *new_window(
 	git_mwindow *w;
 
 	w = git__malloc(sizeof(*w));
+	
 	if (w == NULL)
 		return NULL;
 
diff --git a/src/pack.c b/src/pack.c
index 85bc670..9b5e0e1 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -215,7 +215,7 @@ static int packfile_unpack_header1(
 	unsigned shift;
 	unsigned long size, c;
 	unsigned long used = 0;
-printf("[pack 218] buf = %lx, used = %ld, len = %ld\n", buf, used, len);
+
 	c = buf[used++];
 	*type = (c >> 4) & 7;
 	size = c & 15;
@@ -261,8 +261,8 @@ int git_packfile_unpack_header(
 	base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
 	if (base == NULL)
 		return GIT_EBUFS;
-printf("[pack 264] base = %lx, mwf = %lx\n", base, mwf);
-	ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
+
+		ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
 	git_mwindow_close(w_curs);
 	if (ret == GIT_EBUFS)
 		return ret;
diff --git a/src/unix/map.c b/src/unix/map.c
index 8e853b9..b04e95a 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -39,11 +39,11 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
 #else
 	if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
 		printf("Trying to map shared-writeable file!!!\n");
+	}
 
-		if(out->data = malloc(len)) {
-			lseek(fd, offset, SEEK_SET);
-			p_read(fd, out->data, len);
-		}
+	if(out->data = malloc(len)) {
+		lseek(fd, offset, SEEK_SET);
+		p_read(fd, out->data, len);
 	}
 #endif