diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2008-07-15 09:49:38 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-15 07:18:04 -0700 |
commit | d53fe8187c38a5a160ef2199a899d9c47ec881b9 (patch) | |
tree | e692814e75ece9695971380addbdb67ec983bb69 /archive-zip.c | |
parent | 671f0707212c929533dc6ec9e032faee328e4602 (diff) | |
download | git-d53fe8187c38a5a160ef2199a899d9c47ec881b9.tar.gz |
archive: add baselen member to struct archiver_args
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>
Diffstat (limited to 'archive-zip.c')
-rw-r--r-- | archive-zip.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/archive-zip.c b/archive-zip.c index 0d24f3fe37..d18254c5c0 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -316,17 +316,15 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time) 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); @@ -336,7 +334,7 @@ int write_zip_archive(struct archiver_args *args) 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); |