+
Skip to content

archive: Add --recurse-submodules to git-archive command #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Documentation/git-archive.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SYNOPSIS
--------
[verse]
'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
[-o <file> | --output=<file>] [--worktree-attributes]
[-o <file> | --output=<file>]
[--recurse-submodules] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[<path>...]

Expand Down Expand Up @@ -82,6 +83,9 @@ The file mode is limited to a regular file, and the option may be
subject to platform-dependent command-line limits. For non-trivial
cases, write an untracked file and use `--add-file` instead.

--recurse-submodules
Include submodules recursively in archive.

--worktree-attributes::
Look for attributes in .gitattributes files in the working tree
as well (see <<ATTRIBUTES>>).
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
TEST_BUILTINS_OBJS += test-submodule.o
TEST_BUILTINS_OBJS += test-subprocess.o
TEST_BUILTINS_OBJS += test-trace2.o
TEST_BUILTINS_OBJS += test-tree-read-tree-at.o
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
TEST_BUILTINS_OBJS += test-userdiff.o
TEST_BUILTINS_OBJS += test-wildmatch.o
Expand Down
15 changes: 10 additions & 5 deletions archive-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static unsigned long offset;
static int tar_umask = 002;

static int write_tar_filter_archive(const struct archiver *ar,
struct repository *repo,
struct archiver_args *args);

/*
Expand Down Expand Up @@ -246,7 +247,9 @@ static void write_extended_header(struct archiver_args *args,
write_blocked(buffer, size);
}

static int write_tar_entry(struct archiver_args *args,
static int write_tar_entry(
struct repository *repo,
struct archiver_args *args,
const struct object_id *oid,
const char *path, size_t pathlen,
unsigned int mode,
Expand Down Expand Up @@ -316,7 +319,7 @@ static int write_tar_entry(struct archiver_args *args,
if (buffer)
write_blocked(buffer, size);
else
err = stream_blocked(args->repo, oid);
err = stream_blocked(repo, oid);
}
return err;
}
Expand Down Expand Up @@ -422,12 +425,13 @@ static int git_tar_config(const char *var, const char *value, void *cb)
}

static int write_tar_archive(const struct archiver *ar UNUSED,
struct repository *repo,
struct archiver_args *args)
{
int err = 0;

write_global_extended_header(args);
err = write_archive_entries(args, write_tar_entry);
err = write_archive_entries(repo, args, write_tar_entry);
if (!err)
write_trailer();
return err;
Expand Down Expand Up @@ -462,6 +466,7 @@ static void tgz_write_block(const void *data)
static const char internal_gzip_command[] = "git archive gzip";

static int write_tar_filter_archive(const struct archiver *ar,
struct repository *repo,
struct archiver_args *args)
{
#if ZLIB_VERNUM >= 0x1221
Expand All @@ -484,7 +489,7 @@ static int write_tar_filter_archive(const struct archiver *ar,
gzstream.next_out = outbuf;
gzstream.avail_out = sizeof(outbuf);

r = write_tar_archive(ar, args);
r = write_tar_archive(ar, repo, args);

tgz_deflate(Z_FINISH);
git_deflate_end(&gzstream);
Expand All @@ -506,7 +511,7 @@ static int write_tar_filter_archive(const struct archiver *ar,
die_errno(_("unable to redirect descriptor"));
close(filter.in);

r = write_tar_archive(ar, args);
r = write_tar_archive(ar, repo, args);

close(1);
if (finish_command(&filter) != 0)
Expand Down
15 changes: 9 additions & 6 deletions archive-zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ static int entry_is_binary(struct index_state *istate, const char *path,

#define STREAM_BUFFER_SIZE (1024 * 16)

static int write_zip_entry(struct archiver_args *args,
static int write_zip_entry(
struct repository *repo,
struct archiver_args *args,
const struct object_id *oid,
const char *path, size_t pathlen,
unsigned int mode,
Expand Down Expand Up @@ -340,7 +342,7 @@ static int write_zip_entry(struct archiver_args *args,

if (!buffer) {
enum object_type type;
stream = open_istream(args->repo, oid, &type, &size,
stream = open_istream(repo, oid, &type, &size,
NULL);
if (!stream)
return error(_("cannot stream blob %s"),
Expand All @@ -349,7 +351,7 @@ static int write_zip_entry(struct archiver_args *args,
out = NULL;
} else {
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(args->repo->index,
is_binary = entry_is_binary(repo->index,
path_without_prefix,
buffer, size);
out = buffer;
Expand Down Expand Up @@ -426,7 +428,7 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(args->repo->index,
is_binary = entry_is_binary(repo->index,
path_without_prefix,
buf, readlen);
write_or_die(1, buf, readlen);
Expand Down Expand Up @@ -459,7 +461,7 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(args->repo->index,
is_binary = entry_is_binary(repo->index,
path_without_prefix,
buf, readlen);

Expand Down Expand Up @@ -619,6 +621,7 @@ static int archive_zip_config(const char *var, const char *value,
}

static int write_zip_archive(const struct archiver *ar UNUSED,
struct repository *repo,
struct archiver_args *args)
{
int err;
Expand All @@ -629,7 +632,7 @@ static int write_zip_archive(const struct archiver *ar UNUSED,

strbuf_init(&zip_dir, 0);

err = write_archive_entries(args, write_zip_entry);
err = write_archive_entries(repo, args, write_zip_entry);
if (!err)
write_zip_trailer(args->commit_oid);

Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载