Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
builtin-http-fetch.c | 67 ++++++++++++++++++++++---------------------------
1 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/builtin-http-fetch.c b/builtin-http-fetch.c
index 4a50dbd..5e1003e 100644
--- a/builtin-http-fetch.c
+++ b/builtin-http-fetch.c
@@ -1,65 +1,59 @@
#include "cache.h"
#include "walker.h"
+#include "parse-options.h"
+
+static char const * const http_fetch_usage[] = {
+ "git-http-fetch [option] (--stdin | <commit-id>) url",
+ NULL
+};
int cmd_http_fetch(int argc, const char **argv, const char *prefix)
{
struct walker *walker;
int commits_on_stdin = 0;
int commits;
- const char **write_ref = NULL;
+ const char *wref = NULL, **write_ref = NULL;
char **commit_id;
- const char *url;
- int arg = 1;
int rc = 0;
- int get_tree = 0;
- int get_history = 0;
- int get_all = 0;
+ int get_tree = 0, get_history = 0, get_all = 0;
int get_verbosely = 0;
int get_recover = 0;
+ struct option http_fetch_options[] = {
+ OPT_BOOLEAN('c', NULL, &get_history, "get the commit objects"),
+ OPT_BOOLEAN('t', NULL, &get_tree, "get the trees"),
+ OPT_BOOLEAN('a', NULL, &get_all, "get all the objects"),
+ OPT_BOOLEAN('v', "verbose", &get_verbosely, "be verbose"),
+ OPT_STRING( 'w', NULL, &wref, "file",
+ "write the commit-id into a $GIT/refs/<file>"),
+ OPT_BOOLEAN( 0 , "recover", &get_recover, "recover from an interrupted fetch"),
+ OPT_BOOLEAN( 0 , "stdin", &commits_on_stdin, "read the commit id's from stdin"),
+ };
git_config(git_default_config);
-
- while (arg < argc && argv[arg][0] == '-') {
- if (argv[arg][1] == 't') {
- get_tree = 1;
- } else if (argv[arg][1] == 'c') {
- get_history = 1;
- } else if (argv[arg][1] == 'a') {
- get_all = 1;
- get_tree = 1;
- get_history = 1;
- } else if (argv[arg][1] == 'v') {
- get_verbosely = 1;
- } else if (argv[arg][1] == 'w') {
- write_ref = &argv[arg + 1];
- arg++;
- } else if (!strcmp(argv[arg], "--recover")) {
- get_recover = 1;
- } else if (!strcmp(argv[arg], "--stdin")) {
- commits_on_stdin = 1;
- }
- arg++;
- }
- if (argc < arg + 2 - commits_on_stdin) {
- usage("git-http-fetch [-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url");
+ argc = parse_options(argc, argv, http_fetch_options,
+ ARRAY_SIZE(http_fetch_options),
+ http_fetch_usage, 0);
+ if (argc != 2 - commits_on_stdin) {
+ make_usage(http_fetch_usage, http_fetch_options,
+ ARRAY_SIZE(http_fetch_options));
return 1;
}
if (commits_on_stdin) {
commits = walker_targets_stdin(&commit_id, &write_ref);
} else {
- commit_id = (char **) &argv[arg++];
+ commit_id = (char **)argv++;
+ write_ref = &wref;
commits = 1;
}
- url = argv[arg];
- walker = get_http_walker(url);
- walker->get_tree = get_tree;
- walker->get_history = get_history;
+ walker = get_http_walker(argv[0]);
+ walker->get_tree = get_tree | get_all;
+ walker->get_history = get_history | get_all;
walker->get_all = get_all;
walker->get_verbosely = get_verbosely;
walker->get_recover = get_recover;
- rc = walker_fetch(walker, commits, commit_id, write_ref, url);
+ rc = walker_fetch(walker, commits, commit_id, write_ref, argv[0]);
if (commits_on_stdin)
walker_targets_free(commits, commit_id, write_ref);
@@ -72,6 +66,5 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
}
walker_free(walker);
-
return rc;
}
--
1.5.3.GIT
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| Kok, Auke | Re: -mm merge plans for 2.6.23 - ioat/dma engine |
| Jeff Garzik | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Matthew Garrett | [PATCH] Remove process freezer from suspend to RAM pathway |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| David Miller | [GIT]: Networking |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Jens Axboe | Re: [BUG] New Kernel Bugs |
git: | |
