Code

Merge branch 'jn/remote-set-branches'
[git.git] / builtin / remote.c
index c4d17b52bc7725c1e1c77e1ce3e2379729a924c4..4745957b9602ed9fe5c983de35ad74cc85e9b537 100644 (file)
@@ -111,6 +111,12 @@ static int fetch_remote(const char *name)
        return 0;
 }
 
+enum {
+       TAGS_UNSET = 0,
+       TAGS_DEFAULT = 1,
+       TAGS_SET = 2
+};
+
 static int add_branch(const char *key, const char *branchname,
                const char *remotename, int mirror, struct strbuf *tmp)
 {
@@ -127,7 +133,7 @@ static int add_branch(const char *key, const char *branchname,
 
 static int add(int argc, const char **argv)
 {
-       int fetch = 0, mirror = 0;
+       int fetch = 0, mirror = 0, fetch_tags = TAGS_DEFAULT;
        struct string_list track = { NULL, 0, 0 };
        const char *master = NULL;
        struct remote *remote;
@@ -137,6 +143,11 @@ static int add(int argc, const char **argv)
 
        struct option options[] = {
                OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
+               OPT_SET_INT(0, "tags", &fetch_tags,
+                           "import all tags and associated objects when fetching",
+                           TAGS_SET),
+               OPT_SET_INT(0, NULL, &fetch_tags,
+                           "or do not fetch any tag at all (--no-tags)", TAGS_UNSET),
                OPT_CALLBACK('t', "track", &track, "branch",
                        "branch(es) to track", opt_parse_track),
                OPT_STRING('m', "master", &master, "branch", "master branch"),
@@ -184,6 +195,14 @@ static int add(int argc, const char **argv)
                        return 1;
        }
 
+       if (fetch_tags != TAGS_DEFAULT) {
+               strbuf_reset(&buf);
+               strbuf_addf(&buf, "remote.%s.tagopt", name);
+               if (git_config_set(buf.buf,
+                       fetch_tags == TAGS_SET ? "--tags" : "--no-tags"))
+                       return 1;
+       }
+
        if (fetch && fetch_remote(name))
                return 1;