All of lore.kernel.org
 help / color / mirror / Atom feed
* Feature request: option to not fetch tags for 'git remote' branches
@ 2010-03-24 20:54 Frans Pop
  2010-03-24 21:08 ` John Feuerstein
  0 siblings, 1 reply; 7+ messages in thread
From: Frans Pop @ 2010-03-24 20:54 UTC (permalink / raw)
  To: git

I'm sometimes asked to build a kernel or rebase patches against a certain 
development repository. No problem, happy to do that.

Except that some of those repos have huge numbers of tags that I'm not 
interested in and which only muddy the tags from the "origin" repo and my 
own.

I mostly want to remove the remote again ASAP and having to semi-manually 
remove the unwanted tags afterwards is a nuisance.

Example (on top of kernel mainline):
$ git remote add -t master iwlwifi \
	git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6.git
This results in the addition of 326 'master-<date>' tags, 70 'merge-<date>' 
tags and 6 'snapshot-<date>' tags.
Similar effects for example from Ingo's "tip" repository.

It would be great to be able to tell 'git remote' to skip tags and only 
fetch the requested branch. A --no-tags option maybe?

AFAIK this is currently not possible, although I'd happy to be proven 
wrong.

Cheers,
FJP

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-24 20:54 Feature request: option to not fetch tags for 'git remote' branches Frans Pop
@ 2010-03-24 21:08 ` John Feuerstein
  2010-03-24 21:35   ` Björn Steinbrink
  2010-03-24 21:46   ` Frans Pop
  0 siblings, 2 replies; 7+ messages in thread
From: John Feuerstein @ 2010-03-24 21:08 UTC (permalink / raw)
  To: Frans Pop; +Cc: git

Hello Frans,

> It would be great to be able to tell 'git remote' to skip tags and only 
> fetch the requested branch. A --no-tags option maybe?
> 
> AFAIK this is currently not possible, although I'd happy to be proven 
> wrong.

have a look at -n, --no-tags provided by git-fetch, ie.

$ git remote add ... foo ...
$ git fetch -n foo


Regards,
John

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-24 21:08 ` John Feuerstein
@ 2010-03-24 21:35   ` Björn Steinbrink
  2010-03-24 21:46   ` Frans Pop
  1 sibling, 0 replies; 7+ messages in thread
From: Björn Steinbrink @ 2010-03-24 21:35 UTC (permalink / raw)
  To: John Feuerstein; +Cc: Frans Pop, git

On 2010.03.24 22:08:43 +0100, John Feuerstein wrote:
> Hello Frans,
> 
> > It would be great to be able to tell 'git remote' to skip tags and only 
> > fetch the requested branch. A --no-tags option maybe?
> > 
> > AFAIK this is currently not possible, although I'd happy to be proven 
> > wrong.
> 
> have a look at -n, --no-tags provided by git-fetch, ie.
> 
> $ git remote add ... foo ...
> $ git fetch -n foo

And you can set remote.<name>.tagopt to --no-tags to make that the
default.

Björn

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-24 21:08 ` John Feuerstein
  2010-03-24 21:35   ` Björn Steinbrink
@ 2010-03-24 21:46   ` Frans Pop
  2010-03-27 19:10     ` Samuel Tardieu
  1 sibling, 1 reply; 7+ messages in thread
From: Frans Pop @ 2010-03-24 21:46 UTC (permalink / raw)
  To: John Feuerstein; +Cc: git

On Wednesday 24 March 2010, John Feuerstein wrote:
> > It would be great to be able to tell 'git remote' to skip tags and
> > only fetch the requested branch. A --no-tags option maybe?
> >
> > AFAIK this is currently not possible, although I'd happy to be proven
> > wrong.
>
> have a look at -n, --no-tags provided by git-fetch, ie.
>
> $ git remote add ... foo ...
> $ git fetch -n foo

Thanks John. I'll need to test if that's persistent, or that I'll have
to remember to specify it with each fetch. I guess the option is also 
recognized by 'git remote update'?

Ahh. I've just found 'remote.<name>.tagopt' in 'man git-config'.
I still think it would be nice if that could be set with an option for
'git remote add'. That would make life so much simpler :-)

Cheers,
FJP

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-24 21:46   ` Frans Pop
@ 2010-03-27 19:10     ` Samuel Tardieu
  2010-03-27 19:25       ` Samuel Tardieu
  2010-03-30  8:09       ` Frans Pop
  0 siblings, 2 replies; 7+ messages in thread
From: Samuel Tardieu @ 2010-03-27 19:10 UTC (permalink / raw)
  To: Frans Pop; +Cc: John Feuerstein, git

Add a '--no-tags' option to 'git remote add' which adds a
'remote.REMOTE.tagopt = --no-tags' to the configuration file.

'git add -f -n REMOTE' will create a new remote and fetch from it
without importing the tags. Subsequent 'git fetch REMOTE' will also
not import the tags.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
---
 Documentation/git-remote.txt |    5 ++++-
 builtin/remote.c             |   11 ++++++++++-
 t/t5505-remote.sh            |   36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 2 deletions(-)


>>>>> "Frans" == Frans Pop <elendil@planet.nl> writes:

Frans> I still think it would be nice if that could be set with an
Frans> option for 'git remote add'. That would make life so much simpler

This should do the job.

  Sam


diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 3fc599c..9db3c35 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git remote' [-v | --verbose]
-'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
+'git remote add' [-t <branch>] [-m <master>] [-f] [-n] [--mirror] <name> <url>
 'git remote rename' <old> <new>
 'git remote rm' <name>
 'git remote set-head' <name> (-a | -d | <branch>)
@@ -51,6 +51,9 @@ update remote-tracking branches <name>/<branch>.
 With `-f` option, `git fetch <name>` is run immediately after
 the remote information is set up.
 +
+With `-n` option, `git fetch <name>` does not import tags from
+the remote repository.
++
 With `-t <branch>` option, instead of the default glob
 refspec for the remote to track all branches under
 `$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`
diff --git a/builtin/remote.c b/builtin/remote.c
index 277765b..bb5606b 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -106,7 +106,7 @@ static int fetch_remote(const char *name)
 
 static int add(int argc, const char **argv)
 {
-	int fetch = 0, mirror = 0;
+	int fetch = 0, mirror = 0, notags = 0;
 	struct string_list track = { NULL, 0, 0 };
 	const char *master = NULL;
 	struct remote *remote;
@@ -116,6 +116,8 @@ static int add(int argc, const char **argv)
 
 	struct option options[] = {
 		OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
+		OPT_BOOLEAN('n', "no-tags", &notags,
+			"do not import remote tags when fetching"),
 		OPT_CALLBACK('t', "track", &track, "branch",
 			"branch(es) to track", opt_parse_track),
 		OPT_STRING('m', "master", &master, "branch", "master branch"),
@@ -172,6 +174,13 @@ static int add(int argc, const char **argv)
 			return 1;
 	}
 
+	if (notags) {
+		strbuf_reset(&buf);
+		strbuf_addf(&buf, "remote.%s.tagopt", name);
+		if (git_config_set(buf.buf, "--no-tags"))
+			return 1;
+	}
+
 	if (fetch && fetch_remote(name))
 		return 1;
 
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2692050..3a92a70 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -319,6 +319,42 @@ test_expect_success 'add alt && prune' '
 	 git rev-parse --verify refs/remotes/origin/side2)
 '
 
+cat > test/expect << EOF
+some-tag
+EOF
+
+test_expect_success 'add with tags (default)' '
+	(cd one &&
+	 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 &&
+	 test_must_fail git config remote.origin.tagopt) &&
+	(cd one &&
+	 git tag -d some-tag) &&
+	test_cmp test/expect test/output
+'
+
+cat > test/expect << EOF
+--no-tags
+EOF
+
+test_expect_success 'add --no-tags' '
+	(cd one &&
+	 git tag -a -m "Some tag" some-tag) &&
+	(mkdir add-no-tags &&
+	 cd add-no-tags &&
+	 git init &&
+	 git remote add -f -n origin ../one &&
+	 git tag -l some-tag > ../test/output &&
+	 git config remote.origin.tagopt >> ../test/output) &&
+	(cd one &&
+	 git tag -d some-tag) &&
+	test_cmp test/expect test/output
+'
+
 cat > one/expect << EOF
   apis/master
   apis/side

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-27 19:10     ` Samuel Tardieu
@ 2010-03-27 19:25       ` Samuel Tardieu
  2010-03-30  8:09       ` Frans Pop
  1 sibling, 0 replies; 7+ messages in thread
From: Samuel Tardieu @ 2010-03-27 19:25 UTC (permalink / raw)
  To: Frans Pop; +Cc: John Feuerstein, git

>>>>> "Sam" == Samuel Tardieu <sam@rfc1149.net> writes:

Sam> Add a '--no-tags' option to 'git remote add' which adds a
Sam> 'remote.REMOTE.tagopt = --no-tags' to the configuration file.

Sam> 'git add -f -n REMOTE' will create a new remote and fetch from it
Sam> without importing the tags. Subsequent 'git fetch REMOTE' will also
Sam> not import the tags.

Sam> Signed-off-by: Samuel Tardieu <sam@rfc1149.net>

I didn't notice that the subject was not appropriate. One can use:

remote add: add a --no-tags (-n) option

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Feature request: option to not fetch tags for 'git remote' branches
  2010-03-27 19:10     ` Samuel Tardieu
  2010-03-27 19:25       ` Samuel Tardieu
@ 2010-03-30  8:09       ` Frans Pop
  1 sibling, 0 replies; 7+ messages in thread
From: Frans Pop @ 2010-03-30  8:09 UTC (permalink / raw)
  To: Samuel Tardieu; +Cc: John Feuerstein, git

On Saturday 27 March 2010, Samuel Tardieu wrote:
> Add a '--no-tags' option to 'git remote add' which adds a
> 'remote.REMOTE.tagopt = --no-tags' to the configuration file.
>
> 'git add -f -n REMOTE' will create a new remote and fetch from it
> without importing the tags. Subsequent 'git fetch REMOTE' will also
> not import the tags.

Not tested, but looks as if it will do exactly what I had in mind. Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-03-30  8:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-24 20:54 Feature request: option to not fetch tags for 'git remote' branches Frans Pop
2010-03-24 21:08 ` John Feuerstein
2010-03-24 21:35   ` Björn Steinbrink
2010-03-24 21:46   ` Frans Pop
2010-03-27 19:10     ` Samuel Tardieu
2010-03-27 19:25       ` Samuel Tardieu
2010-03-30  8:09       ` Frans Pop

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.