summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3296e3)
raw | patch | inline | side by side (parent: d3296e3)
author | Rene Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Fri, 25 Jul 2008 10:41:21 +0000 (12:41 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 26 Jul 2008 00:16:12 +0000 (17:16 -0700) |
Both archive and upload-archive have to parse command line arguments and
then call the archiver specific write function. Move the duplicate code
to a new function, write_archive().
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
then call the archiver specific write function. Move the duplicate code
to a new function, write_archive().
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive.c | patch | blob | history | |
archive.h | patch | blob | history | |
builtin-archive.c | patch | blob | history | |
builtin-upload-archive.c | patch | blob | history |
diff --git a/archive.c b/archive.c
index b8b45bad77230b0258622e993dbbac3a20e3716c..75eb2577602da1f2cd56ca416265c5efb14a96b1 100644 (file)
--- a/archive.c
+++ b/archive.c
err = 0;
return err;
}
+
+int write_archive(int argc, const char **argv, const char *prefix,
+ int setup_prefix)
+{
+ const struct archiver *ar = NULL;
+ struct archiver_args args;
+ int tree_idx;
+
+ tree_idx = parse_archive_args(argc, argv, &ar, &args);
+ if (setup_prefix && prefix == NULL)
+ prefix = setup_git_directory();
+
+ argv += tree_idx;
+ parse_treeish_arg(argv, &args, prefix);
+ parse_pathspec_arg(argv + 1, &args);
+
+ return ar->write_archive(&args);
+}
diff --git a/archive.h b/archive.h
index 4a02371f374a159604ab55102be5ba5b9d3f7cd2..6b5fe5af4534117a8ece6da25ab3dc3cd5ce9236 100644 (file)
--- a/archive.h
+++ b/archive.h
extern int write_zip_archive(struct archiver_args *);
extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
+extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix);
#endif /* ARCHIVE_H */
diff --git a/builtin-archive.c b/builtin-archive.c
index df9772469681285d69f968b59172c4aaee2eb679..502b339e6bb0080799a552a03bad172b99f93960 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
int cmd_archive(int argc, const char **argv, const char *prefix)
{
- const struct archiver *ar = NULL;
- struct archiver_args args;
- int tree_idx;
const char *remote = NULL;
remote = extract_remote_arg(&argc, argv);
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
- tree_idx = parse_archive_args(argc, argv, &ar, &args);
- if (prefix == NULL)
- prefix = setup_git_directory();
-
- argv += tree_idx;
- parse_treeish_arg(argv, &args, prefix);
- parse_pathspec_arg(argv + 1, &args);
-
- return ar->write_archive(&args);
+ return write_archive(argc, argv, prefix, 1);
}
index 13a6c6203eff7d8dc96a56fa5709dc9eb69da0a6..cc37b36d996cfc293987a30e23725d28bd635f57 100644 (file)
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
static int run_upload_archive(int argc, const char **argv, const char *prefix)
{
- const struct archiver *ar;
- struct archiver_args args;
const char *sent_argv[MAX_ARGS];
const char *arg_cmd = "argument ";
char *p, buf[4096];
- int treeish_idx;
int sent_argc;
int len;
sent_argv[sent_argc] = NULL;
/* parse all options sent by the client */
- treeish_idx = parse_archive_args(sent_argc, sent_argv, &ar, &args);
-
- parse_treeish_arg(sent_argv + treeish_idx, &args, prefix);
- parse_pathspec_arg(sent_argv + treeish_idx + 1, &args);
-
- return ar->write_archive(&args);
+ return write_archive(sent_argc, sent_argv, prefix, 0);
}
static void error_clnt(const char *fmt, ...)