summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 671f070)
raw | patch | inline | side by side (parent: 671f070)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Tue, 15 Jul 2008 07:49:38 +0000 (09:49 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 15 Jul 2008 14:18:04 +0000 (07:18 -0700) |
Calculate the length of base and save it in a new member of struct
archiver_args. This way we don't have to compute it in each of the
format backends.
Note: parse_archive_args() guarantees that ->base won't ever be NULL.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archiver_args. This way we don't have to compute it in each of the
format backends.
Note: parse_archive_args() guarantees that ->base won't ever be NULL.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive-tar.c | patch | blob | history | |
archive-zip.c | patch | blob | history | |
archive.h | patch | blob | history | |
builtin-archive.c | patch | blob | history |
diff --git a/archive-tar.c b/archive-tar.c
index 6eaf59eb01d7bb180d8cc0a8c099fe8a533d28f6..63cc2eca11c305861442f515fed48a729434ca3f 100644 (file)
--- a/archive-tar.c
+++ b/archive-tar.c
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();
diff --git a/archive-zip.c b/archive-zip.c
index 0d24f3fe379417c43f3a48ba7cffc606c90aa9ad..d18254c5c00a0a491afa1d8517d08c747dbad395 100644 (file)
--- a/archive-zip.c
+++ b/archive-zip.c
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);
diff --git a/archive.h b/archive.h
index 1b24ae310dfff30748dc3dfb8a506af04bff567a..34151f41b47b812b43f2fb2c6d07dae3819072a4 100644 (file)
--- a/archive.h
+++ b/archive.h
struct archiver_args {
const char *base;
+ size_t baselen;
struct tree *tree;
const unsigned char *commit_sha1;
const struct commit *commit;
diff --git a/builtin-archive.c b/builtin-archive.c
index 6ee36775e7a63ad2b71d83204245a40f94729c40..e7f4ec634179a1cd23e967752b37e301f093e3ac 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
}
args->verbose = verbose;
args->base = base;
+ args->baselen = strlen(base);
return i;
}