diff options
Diffstat (limited to 'archive.c')
-rw-r--r-- | archive.c | 32 |
1 files changed, 8 insertions, 24 deletions
@@ -87,19 +87,6 @@ void *sha1_file_to_archive(const struct archiver_args *args, return buffer; } -static void setup_archive_check(struct git_attr_check *check) -{ - static struct git_attr *attr_export_ignore; - static struct git_attr *attr_export_subst; - - if (!attr_export_ignore) { - attr_export_ignore = git_attr("export-ignore"); - attr_export_subst = git_attr("export-subst"); - } - check[0].attr = attr_export_ignore; - check[1].attr = attr_export_subst; -} - struct directory { struct directory *up; struct object_id oid; @@ -120,10 +107,10 @@ static int write_archive_entry(const unsigned char *sha1, const char *base, void *context) { static struct strbuf path = STRBUF_INIT; + static struct attr_check *check; struct archiver_context *c = context; struct archiver_args *args = c->args; write_archive_entry_fn_t write_entry = c->write_entry; - struct git_attr_check check[2]; const char *path_without_prefix; int err; @@ -137,11 +124,12 @@ static int write_archive_entry(const unsigned char *sha1, const char *base, strbuf_addch(&path, '/'); path_without_prefix = path.buf + args->baselen; - setup_archive_check(check); - if (!git_check_attr(path_without_prefix, ARRAY_SIZE(check), check)) { - if (ATTR_TRUE(check[0].value)) + if (!check) + check = attr_check_initl("export-ignore", "export-subst", NULL); + if (!git_check_attr(path_without_prefix, check)) { + if (ATTR_TRUE(check->items[0].value)) return 0; - args->convert = ATTR_TRUE(check[1].value); + args->convert = ATTR_TRUE(check->items[1].value); } if (S_ISDIR(mode) || S_ISGITLINK(mode)) { @@ -504,15 +492,11 @@ static int parse_archive_args(int argc, const char **argv, } int write_archive(int argc, const char **argv, const char *prefix, - int setup_prefix, const char *name_hint, int remote) + const char *name_hint, int remote) { - int nongit = 0; const struct archiver *ar = NULL; struct archiver_args args; - if (setup_prefix && prefix == NULL) - prefix = setup_git_directory_gently(&nongit); - git_config_get_bool("uploadarchive.allowunreachable", &remote_allow_unreachable); git_config(git_default_config, NULL); @@ -520,7 +504,7 @@ int write_archive(int argc, const char **argv, const char *prefix, init_zip_archiver(); argc = parse_archive_args(argc, argv, &ar, &args, name_hint, remote); - if (nongit) { + if (!startup_info->have_repository) { /* * We know this will die() with an error, so we could just * die ourselves; but its error message will be more specific |