int write_tar_archive(struct archiver_args *args)
{
- int plen = args->base ? strlen(args->base) : 0;
-
git_config(git_tar_config, NULL);
archive_time = args->time;
verbose = args->verbose;
commit = args->commit;
- base_len = args->base ? strlen(args->base) : 0;
+ base_len = args->baselen;
if (args->commit_sha1)
write_global_extended_header(args->commit_sha1);
- if (args->base && plen > 0 && args->base[plen - 1] == '/') {
+ if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
char *base = xstrdup(args->base);
int baselen = strlen(base);
0, NULL);
free(base);
}
- read_tree_recursive(args->tree, args->base, plen, 0,
+ read_tree_recursive(args->tree, args->base, args->baselen, 0,
args->pathspec, write_tar_entry, NULL);
write_trailer();
int write_zip_archive(struct archiver_args *args)
{
- int plen = strlen(args->base);
-
dos_time(&args->time, &zip_date, &zip_time);
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
verbose = args->verbose;
commit = args->commit;
- base_len = args->base ? strlen(args->base) : 0;
+ base_len = args->baselen;
- if (args->base && plen > 0 && args->base[plen - 1] == '/') {
+ if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
char *base = xstrdup(args->base);
int baselen = strlen(base);
0, NULL);
free(base);
}
- read_tree_recursive(args->tree, args->base, plen, 0,
+ read_tree_recursive(args->tree, args->base, args->baselen, 0,
args->pathspec, write_zip_entry, NULL);
write_zip_trailer(args->commit_sha1);
struct archiver_args {
const char *base;
+ size_t baselen;
struct tree *tree;
const unsigned char *commit_sha1;
const struct commit *commit;
}
args->verbose = verbose;
args->base = base;
+ args->baselen = strlen(base);
return i;
}