#include "cache.h"
#include "parse-options.h"
#include "transport.h"
#include "remote.h"
#include "string-list.h"
#include "strbuf.h"
#include "run-command.h"
#include "refs.h"
static const char * const builtin_remote_usage[] = {
"git remote [-v | --verbose]",
"git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>",
"git remote rename <old> <new>",
"git remote rm <name>",
"git remote set-head <name> (-a | -d | <branch>)",
"git remote [-v | --verbose] show [-n] <name>",
"git remote prune [-n | --dry-run] <name>",
"git remote [-v | --verbose] update [-p | --prune] [group | remote]",
NULL
};
static const char * const builtin_remote_add_usage[] = {
"git remote add [<options>] <name> <url>",
NULL
};
static const char * const builtin_remote_rename_usage[] = {
"git remote rename <old> <new>",
NULL
};
static const char * const builtin_remote_rm_usage[] = {
"git remote rm <name>",
NULL
};
static const char * const builtin_remote_sethead_usage[] = {
"git remote set-head <name> (-a | -d | <branch>])",
NULL
};
static const char * const builtin_remote_show_usage[] = {
"git remote show [<options>] <name>",
NULL
};
static const char * const builtin_remote_prune_usage[] = {
"git remote prune [<options>] <name>",
NULL
};
static const char * const builtin_remote_update_usage[] = {
"git remote update [<options>] [<group> | <remote>]...",
NULL
};
#define GET_REF_STATES (1<<0)
#define GET_HEAD_NAMES (1<<1)
#define GET_PUSH_REF_STATES (1<<2)
static int verbose;
static int show_all(void);
static int prune_remote(const char *remote, int dry_run);
static inline int postfixcmp(const char *string, const char *postfix)
{
int len1 = strlen(string), len2 = strlen(postfix);
if (len1 < len2)
return 1;
return strcmp(string + len1 - len2, postfix);
}
static int opt_parse_track(const struct option *opt, const char *arg, int not)
{
struct string_list *list = opt->value;
if (not)
string_list_clear(list, 0);
else
string_list_append(arg, list);
return 0;
}
static int fetch_remote(const char *name)
{
const char *argv[] = { "fetch", name, NULL, NULL };
if (verbose) {
argv[1] = "-v";
argv[2] = name;
}
printf("Updating %s\n", name);
if (run_command_v_opt(argv, RUN_GIT_CMD))
return error("Could not fetch %s", name);
return 0;
}
static int add(int argc, const char **argv)
{
int fetch = 0, mirror = 0;
struct string_list track = { NULL, 0, 0 };
|