@@ -104,9 +104,15 @@ static int fetch_remote(const char *name)
104104 return 0 ;
105105}
106106
107+ enum {
108+ TAGS_UNSET = 0 ,
109+ TAGS_DEFAULT = 1 ,
110+ TAGS_SET = 2
111+ };
112+
107113static int add (int argc , const char * * argv )
108114{
109- int fetch = 0 , mirror = 0 ;
115+ int fetch = 0 , mirror = 0 , fetch_tags = TAGS_DEFAULT ;
110116 struct string_list track = { NULL , 0 , 0 };
111117 const char * master = NULL ;
112118 struct remote * remote ;
@@ -116,6 +122,11 @@ static int add(int argc, const char **argv)
116122
117123 struct option options [] = {
118124 OPT_BOOLEAN ('f' , "fetch" , & fetch , "fetch the remote branches" ),
125+ OPT_SET_INT (0 , "tags" , & fetch_tags ,
126+ "import all tags and associated objects when fetching" ,
127+ TAGS_SET ),
128+ OPT_SET_INT (0 , NULL , & fetch_tags ,
129+ "or do not fetch any tag at all (--no-tags)" , TAGS_UNSET ),
119130 OPT_CALLBACK ('t' , "track" , & track , "branch" ,
120131 "branch(es) to track" , opt_parse_track ),
121132 OPT_STRING ('m' , "master" , & master , "branch" , "master branch" ),
@@ -172,6 +183,14 @@ static int add(int argc, const char **argv)
172183 return 1 ;
173184 }
174185
186+ if (fetch_tags != TAGS_DEFAULT ) {
187+ strbuf_reset (& buf );
188+ strbuf_addf (& buf , "remote.%s.tagopt" , name );
189+ if (git_config_set (buf .buf ,
190+ fetch_tags == TAGS_SET ? "--tags" : "--no-tags" ))
191+ return 1 ;
192+ }
193+
175194 if (fetch && fetch_remote (name ))
176195 return 1 ;
177196
0 commit comments