summaryrefslogtreecommitdiff
path: root/archive-tar.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2008-07-15 09:49:38 +0200
committerJunio C Hamano <gitster@pobox.com>2008-07-15 07:18:04 -0700
commitd53fe8187c38a5a160ef2199a899d9c47ec881b9 (patch)
treee692814e75ece9695971380addbdb67ec983bb69 /archive-tar.c
parent671f0707212c929533dc6ec9e032faee328e4602 (diff)
downloadgit-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-tar.c')
-rw-r--r--archive-tar.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/archive-tar.c b/archive-tar.c
index 6eaf59eb01..63cc2eca11 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -268,19 +268,17 @@ static int write_tar_entry(const unsigned char *sha1, const char *base,
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);
@@ -290,7 +288,7 @@ int write_tar_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_tar_entry, NULL);
write_trailer();