refs: make create_symref() virtual
[gitweb.git] / archive.c
index d37c41daf29b1163ac7743e5ce17cdafc9b2e8a3..5d735ae6039f0d9708d61a27a490953ff27badf5 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "refs.h"
 #include "commit.h"
 #include "tree-walk.h"
 #include "attr.h"
@@ -33,7 +34,7 @@ static void format_subst(const struct commit *commit,
        char *to_free = NULL;
        struct strbuf fmt = STRBUF_INIT;
        struct pretty_print_context ctx = {0};
-       ctx.date_mode = DATE_NORMAL;
+       ctx.date_mode.type = DATE_NORMAL;
        ctx.abbrev = DEFAULT_ABBREV;
 
        if (src == buf->buf)
@@ -170,13 +171,14 @@ static void queue_directory(const unsigned char *sha1,
                unsigned mode, int stage, struct archiver_context *c)
 {
        struct directory *d;
-       d = xmallocz(sizeof(*d) + base->len + 1 + strlen(filename));
+       size_t len = st_add4(base->len, 1, strlen(filename), 1);
+       d = xmalloc(st_add(sizeof(*d), len));
        d->up      = c->bottom;
        d->baselen = base->len;
        d->mode    = mode;
        d->stage   = stage;
        c->bottom  = d;
-       d->len = sprintf(d->path, "%.*s%s/", (int)base->len, base->buf, filename);
+       d->len = xsnprintf(d->path, len, "%.*s%s/", (int)base->len, base->buf, filename);
        hashcpy(d->oid.hash, sha1);
 }
 
@@ -239,7 +241,7 @@ int write_archive_entries(struct archiver_args *args,
                        len--;
                if (args->verbose)
                        fprintf(stderr, "%.*s\n", (int)len, args->base);
-               err = write_entry(args, args->tree->object.sha1, args->base,
+               err = write_entry(args, args->tree->object.oid.hash, args->base,
                                  len, 040777);
                if (err)
                        return err;
@@ -372,7 +374,7 @@ static void parse_treeish_arg(const char **argv,
 
        commit = lookup_commit_reference_gently(oid.hash, 1);
        if (commit) {
-               commit_sha1 = commit->object.sha1;
+               commit_sha1 = commit->object.oid.hash;
                archive_time = commit->date;
        } else {
                commit_sha1 = NULL;
@@ -388,7 +390,7 @@ static void parse_treeish_arg(const char **argv,
                unsigned int mode;
                int err;
 
-               err = get_tree_entry(tree->object.sha1, prefix,
+               err = get_tree_entry(tree->object.oid.hash, prefix,
                                     tree_oid.hash, &mode);
                if (err || !S_ISDIR(mode))
                        die("current working directory is untracked");