summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-06-13 12:19:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-13 18:49:41 (GMT)
commitb3c96fb158f05152336f167076f5d81d23c3a5e5 (patch)
tree53f31350a5ace53f533e64dc5c049699e1ebfb5a /read-cache.c
parentce7c614bceedf0c0169dd5b02cae3e33ee45acdd (diff)
downloadgit-b3c96fb158f05152336f167076f5d81d23c3a5e5.zip
git-b3c96fb158f05152336f167076f5d81d23c3a5e5.tar.gz
git-b3c96fb158f05152336f167076f5d81d23c3a5e5.tar.bz2
split-index: strip pathname of on-disk replaced entries
We know the positions of replaced entries via the replace bitmap in "link" extension, so the "name" path does not have to be stored (it's still in the shared index). With this, we also have a way to distinguish additions vs replacements at load time and can catch broken "link" extensions. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index d5f70a0..af475dc 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1787,9 +1787,15 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
{
int size;
struct ondisk_cache_entry *ondisk;
+ int saved_namelen = saved_namelen; /* compiler workaround */
char *name;
int result;
+ if (ce->ce_flags & CE_STRIP_NAME) {
+ saved_namelen = ce_namelen(ce);
+ ce->ce_namelen = 0;
+ }
+
if (!previous_name) {
size = ondisk_ce_size(ce);
ondisk = xcalloc(1, size);
@@ -1821,6 +1827,10 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce,
strbuf_splice(previous_name, common, to_remove,
ce->name + common, ce_namelen(ce) - common);
}
+ if (ce->ce_flags & CE_STRIP_NAME) {
+ ce->ce_namelen = saved_namelen;
+ ce->ce_flags &= ~CE_STRIP_NAME;
+ }
result = ce_write(c, fd, ondisk, size);
free(ondisk);