Merge branch 'st/remote-tags-no-tags'
* st/remote-tags-no-tags: remote add: add a --[no-]tags option Honor "tagopt = --tags" configuration optionmaint
commit
42779124a2
|
@ -1593,7 +1593,9 @@ remote.<name>.uploadpack::
|
||||||
|
|
||||||
remote.<name>.tagopt::
|
remote.<name>.tagopt::
|
||||||
Setting this value to \--no-tags disables automatic tag following when
|
Setting this value to \--no-tags disables automatic tag following when
|
||||||
fetching from remote <name>
|
fetching from remote <name>. Setting it to \--tags will fetch every
|
||||||
|
tag from remote <name>, even if they are not reachable from remote
|
||||||
|
branch heads.
|
||||||
|
|
||||||
remote.<name>.vcs::
|
remote.<name>.vcs::
|
||||||
Setting this to a value <vcs> will cause git to interact with
|
Setting this to a value <vcs> will cause git to interact with
|
||||||
|
|
|
@ -10,7 +10,7 @@ SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git remote' [-v | --verbose]
|
'git remote' [-v | --verbose]
|
||||||
'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
|
'git remote add' [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror] <name> <url>
|
||||||
'git remote rename' <old> <new>
|
'git remote rename' <old> <new>
|
||||||
'git remote rm' <name>
|
'git remote rm' <name>
|
||||||
'git remote set-head' <name> (-a | -d | <branch>)
|
'git remote set-head' <name> (-a | -d | <branch>)
|
||||||
|
@ -51,6 +51,12 @@ update remote-tracking branches <name>/<branch>.
|
||||||
With `-f` option, `git fetch <name>` is run immediately after
|
With `-f` option, `git fetch <name>` is run immediately after
|
||||||
the remote information is set up.
|
the remote information is set up.
|
||||||
+
|
+
|
||||||
|
With `--tags` option, `git fetch <name>` imports every tag from the
|
||||||
|
remote repository.
|
||||||
|
+
|
||||||
|
With `--no-tags` option, `git fetch <name>` does not import tags from
|
||||||
|
the remote repository.
|
||||||
|
+
|
||||||
With `-t <branch>` option, instead of the default glob
|
With `-t <branch>` option, instead of the default glob
|
||||||
refspec for the remote to track all branches under
|
refspec for the remote to track all branches under
|
||||||
`$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`
|
`$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`
|
||||||
|
|
|
@ -104,9 +104,15 @@ static int fetch_remote(const char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
TAGS_UNSET = 0,
|
||||||
|
TAGS_DEFAULT = 1,
|
||||||
|
TAGS_SET = 2
|
||||||
|
};
|
||||||
|
|
||||||
static int add(int argc, const char **argv)
|
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 };
|
struct string_list track = { NULL, 0, 0 };
|
||||||
const char *master = NULL;
|
const char *master = NULL;
|
||||||
struct remote *remote;
|
struct remote *remote;
|
||||||
|
@ -116,6 +122,11 @@ static int add(int argc, const char **argv)
|
||||||
|
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
|
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",
|
OPT_CALLBACK('t', "track", &track, "branch",
|
||||||
"branch(es) to track", opt_parse_track),
|
"branch(es) to track", opt_parse_track),
|
||||||
OPT_STRING('m', "master", &master, "branch", "master branch"),
|
OPT_STRING('m', "master", &master, "branch", "master branch"),
|
||||||
|
@ -172,6 +183,14 @@ static int add(int argc, const char **argv)
|
||||||
return 1;
|
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))
|
if (fetch && fetch_remote(name))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -127,10 +127,12 @@ then
|
||||||
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allow --notags from remote.$1.tagopt
|
# Allow --tags/--notags from remote.$1.tagopt
|
||||||
case "$tags$no_tags" in
|
case "$tags$no_tags" in
|
||||||
'')
|
'')
|
||||||
case "$(git config --get "remote.$1.tagopt")" in
|
case "$(git config --get "remote.$1.tagopt")" in
|
||||||
|
--tags)
|
||||||
|
tags=t ;;
|
||||||
--no-tags)
|
--no-tags)
|
||||||
no_tags=t ;;
|
no_tags=t ;;
|
||||||
esac
|
esac
|
||||||
|
|
2
remote.c
2
remote.c
|
@ -443,6 +443,8 @@ static int handle_config(const char *key, const char *value, void *cb)
|
||||||
} else if (!strcmp(subkey, ".tagopt")) {
|
} else if (!strcmp(subkey, ".tagopt")) {
|
||||||
if (!strcmp(value, "--no-tags"))
|
if (!strcmp(value, "--no-tags"))
|
||||||
remote->fetch_tags = -1;
|
remote->fetch_tags = -1;
|
||||||
|
else if (!strcmp(value, "--tags"))
|
||||||
|
remote->fetch_tags = 2;
|
||||||
} else if (!strcmp(subkey, ".proxy")) {
|
} else if (!strcmp(subkey, ".proxy")) {
|
||||||
return git_config_string((const char **)&remote->http_proxy,
|
return git_config_string((const char **)&remote->http_proxy,
|
||||||
key, value);
|
key, value);
|
||||||
|
|
|
@ -320,6 +320,69 @@ test_expect_success 'add alt && prune' '
|
||||||
git rev-parse --verify refs/remotes/origin/side2)
|
git rev-parse --verify refs/remotes/origin/side2)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >test/expect <<\EOF
|
||||||
|
some-tag
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'add with reachable tags (default)' '
|
||||||
|
(cd one &&
|
||||||
|
>foobar &&
|
||||||
|
git add foobar &&
|
||||||
|
git commit -m "Foobar" &&
|
||||||
|
git tag -a -m "Foobar tag" foobar-tag &&
|
||||||
|
git reset --hard HEAD~1 &&
|
||||||
|
git tag -a -m "Some tag" some-tag) &&
|
||||||
|
(mkdir add-tags &&
|
||||||
|
cd add-tags &&
|
||||||
|
git init &&
|
||||||
|
git remote add -f origin ../one &&
|
||||||
|
git tag -l some-tag >../test/output &&
|
||||||
|
git tag -l foobar-tag >>../test/output &&
|
||||||
|
test_must_fail git config remote.origin.tagopt) &&
|
||||||
|
test_cmp test/expect test/output
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >test/expect <<\EOF
|
||||||
|
some-tag
|
||||||
|
foobar-tag
|
||||||
|
--tags
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'add --tags' '
|
||||||
|
(rm -rf add-tags &&
|
||||||
|
mkdir add-tags &&
|
||||||
|
cd add-tags &&
|
||||||
|
git init &&
|
||||||
|
git remote add -f --tags origin ../one &&
|
||||||
|
git tag -l some-tag >../test/output &&
|
||||||
|
git tag -l foobar-tag >>../test/output &&
|
||||||
|
git config remote.origin.tagopt >>../test/output) &&
|
||||||
|
test_cmp test/expect test/output
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >test/expect <<\EOF
|
||||||
|
--no-tags
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'add --no-tags' '
|
||||||
|
(rm -rf add-tags &&
|
||||||
|
mkdir add-no-tags &&
|
||||||
|
cd add-no-tags &&
|
||||||
|
git init &&
|
||||||
|
git remote add -f --no-tags origin ../one &&
|
||||||
|
git tag -l some-tag >../test/output &&
|
||||||
|
git tag -l foobar-tag >../test/output &&
|
||||||
|
git config remote.origin.tagopt >>../test/output) &&
|
||||||
|
(cd one &&
|
||||||
|
git tag -d some-tag foobar-tag) &&
|
||||||
|
test_cmp test/expect test/output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'reject --no-no-tags' '
|
||||||
|
(cd add-no-tags &&
|
||||||
|
test_must_fail git remote add -f --no-no-tags neworigin ../one)
|
||||||
|
'
|
||||||
|
|
||||||
cat > one/expect << EOF
|
cat > one/expect << EOF
|
||||||
apis/master
|
apis/master
|
||||||
apis/side
|
apis/side
|
||||||
|
|
Loading…
Reference in New Issue