X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=archive.c;h=6502b76ef10a182e9d9f0e60ad926c55a31a737a;hb=f55638874774acc1e13a046353449ebc8734ab08;hp=fb159fe59e9e6fc40db584468c7b1ddf8495ccb3;hpb=f1a8cc635455a65567d040349327b9ea4adb479b;p=git.git diff --git a/archive.c b/archive.c index fb159fe59..6502b76ef 100644 --- a/archive.c +++ b/archive.c @@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit, const char *b, *c; b = memmem(src, len, "$Format:", 8); - if (!b || src + len < b + 9) + if (!b) break; - c = memchr(b + 8, '$', len - 8); + c = memchr(b + 8, '$', (src + len) - b - 8); if (!c) break; @@ -82,3 +82,16 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1, return buffer; } +int is_archive_path_ignored(const char *path) +{ + static struct git_attr *attr_export_ignore; + struct git_attr_check check[1]; + + if (!attr_export_ignore) + attr_export_ignore = git_attr("export-ignore", 13); + + check[0].attr = attr_export_ignore; + if (git_checkattr(path, ARRAY_SIZE(check), check)) + return 0; + return ATTR_TRUE(check[0].value); +}