projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow finding things that begin with a dash in 'git grep'
[git.git]
/
read-cache.c
diff --git
a/read-cache.c
b/read-cache.c
index
f448ab1
..
6eff4c8
100644
(file)
--- a/
read-cache.c
+++ b/
read-cache.c
@@
-191,6
+191,8
@@
int ce_path_match(const struct cache_entry *ce, const char **pathspec)
return 1;
if (name[matchlen] == '/' || !name[matchlen])
return 1;
return 1;
if (name[matchlen] == '/' || !name[matchlen])
return 1;
+ if (!matchlen)
+ return 1;
}
return 0;
}
}
return 0;
}
@@
-392,7
+394,7
@@
int read_cache(void)
return (errno == ENOENT) ? 0 : error("open failed");
size = 0; // avoid gcc warning
return (errno == ENOENT) ? 0 : error("open failed");
size = 0; // avoid gcc warning
- map =
(void *)-1
;
+ map =
MAP_FAILED
;
if (!fstat(fd, &st)) {
size = st.st_size;
errno = EINVAL;
if (!fstat(fd, &st)) {
size = st.st_size;
errno = EINVAL;
@@
-400,7
+402,7
@@
int read_cache(void)
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
}
close(fd);
map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
}
close(fd);
- if (
-1 == (int)(long)map
)
+ if (
map == MAP_FAILED
)
return error("mmap failed");
hdr = map;
return error("mmap failed");
hdr = map;
@@
-460,6
+462,13
@@
static int ce_flush(SHA_CTX *context, int fd)
SHA1_Update(context, write_buffer, left);
}
SHA1_Update(context, write_buffer, left);
}
+ /* Flush first if not enough space for SHA1 signature */
+ if (left + 20 > WRITE_BUFFER_SIZE) {
+ if (write(fd, write_buffer, left) != left)
+ return -1;
+ left = 0;
+ }
+
/* Append the SHA1 signature at the end */
SHA1_Final(write_buffer + left, context);
left += 20;
/* Append the SHA1 signature at the end */
SHA1_Final(write_buffer + left, context);
left += 20;