{"thread":{"id":"16969","subject":"[PATCH] bundle: allow rev-list options to exclude annotated tags","startedAt":"2009-01-02T18:08:46Z","lastAt":"2009-01-06T08:17:51Z","messageCount":2,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"99180","messageId":"alpine.DEB.1.00.0901021725530.27818@racer","threadId":"16969","inReplyTo":null,"subject":"[PATCH] bundle: allow rev-list options to exclude annotated tags","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-02T18:08:46Z","receivedAt":"2009-01-02T18:08:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith options such as \"--all --since=2.weeks.ago\", annotated tags used to\nbe included, when they should have been excluded.  The reason is that we\nheavily abuse the revision walker to determine what needs to be included\nor excluded.  And the revision walker does not show tags at all (and\ntherefore never marks tags as uninteresting).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n bundle.c          |   32 ++++++++++++++++++++++++++++++++\n t/t5704-bundle.sh |   33 +++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+), 0 deletions(-)\n create mode 100755 t/t5704-bundle.sh\n\ndiff --git a/bundle.c b/bundle.c\nindex daecd8e..4977962 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -167,6 +167,32 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n \treturn list_refs(&header->references, argc, argv);\n }\n \n+static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n+{\n+\tunsigned long size;\n+\tenum object_type type;\n+\tchar *buf, *line, *lineend;\n+\tunsigned long date;\n+\n+\tif (revs->max_age == -1 && revs->min_age == -1)\n+\t\treturn 1;\n+\n+\tbuf = read_sha1_file(tag->sha1, &type, &size);\n+\tif (!buf)\n+\t\treturn 1;\n+\tline = memmem(buf, size, \"\\ntagger \", 8);\n+\tif (!line++)\n+\t\treturn 1;\n+\tlineend = memchr(line, buf + size - line, '\\n');\n+\tline = memchr(line, lineend ? lineend - line : buf + size - line, '>');\n+\tif (!line++)\n+\t\treturn 1;\n+\tdate = strtoul(line, NULL, 10);\n+\tfree(buf);\n+\treturn (revs->max_age == -1 || revs->max_age < date) &&\n+\t\t(revs->min_age == -1 || revs->min_age > date);\n+}\n+\n int create_bundle(struct bundle_header *header, const char *path,\n \t\tint argc, const char **argv)\n {\n@@ -255,6 +281,12 @@ int create_bundle(struct bundle_header *header, const char *path,\n \t\t\tflag = 0;\n \t\tdisplay_ref = (flag & REF_ISSYMREF) ? e->name : ref;\n \n+\t\tif (e->item->type == OBJ_TAG &&\n+\t\t\t\t!is_tag_in_date_range(e->item, &revs)) {\n+\t\t\te->item->flags |= UNINTERESTING;\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\t/*\n \t\t * Make sure the refs we wrote out is correct; --max-count and\n \t\t * other limiting options could have prevented all the tips\ndiff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh\nnew file mode 100755\nindex 0000000..a8f4419\n--- /dev/null\n+++ b/t/t5704-bundle.sh\n@@ -0,0 +1,33 @@\n+#!/bin/sh\n+\n+test_description='some bundle related tests'\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\n+\t: > file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m initial &&\n+\ttest_tick &&\n+\tgit tag -m tag tag &&\n+\t: > file2 &&\n+\tgit add file2 &&\n+\t: > file3 &&\n+\ttest_tick &&\n+\tgit commit -m second &&\n+\tgit add file3 &&\n+\ttest_tick &&\n+\tgit commit -m third\n+\n+'\n+\n+test_expect_success 'tags can be excluded by rev-list options' '\n+\n+\tgit bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 &&\n+\tgit ls-remote bundle > output &&\n+\t! grep tag output\n+\n+'\n+\n+test_done\n-- \n1.6.1.rc3.224.g95ac9\n"},{"id":"99431","messageId":"7v4p0cn900.fsf@gitster.siamese.dyndns.org","threadId":"16969","inReplyTo":"alpine.DEB.1.00.0901021725530.27818@racer","subject":"Re: [PATCH] bundle: allow rev-list options to exclude annotated tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-06T08:17:51Z","receivedAt":"2009-01-06T08:17:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; queued for maint (and possibly maint-1.6.0).\n"}]}