git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH 1/8] fast-export: fix exporting a tag and nothing else
Date: Tue, 24 Sep 2019 18:39:58 -0700	[thread overview]
Message-ID: <20190925014005.17056-2-newren@gmail.com> (raw)
In-Reply-To: <20190925014005.17056-1-newren@gmail.com>

fast-export allows specifying revision ranges, which can be used to
export a tag without exporting the commit it tags.  fast-export handled
this rather poorly: it would emit a "from :0" directive.  Since marks
start at 1 and increase, this means it refers to an unknown commit and
fast-import will choke on the input.

When we are unable to look up a mark for the object being tagged, use a
"from $HASH" directive instead to fix this problem.

Note that this is quite similar to the behavior fast-export exhibits
with commits and parents when --reference-excluded-parents is passed
along with an excluded commit range.  For tags of excluded commits we do
not require the --reference-excluded-parents flag because we always have
to tag something.  By contrast, when dealing with commits, pruning a
parent is always a viable option, so we need the flag to specify that
parent pruning is not wanted.  (It is slightly weird that
--reference-excluded-parents isn't the default with a separate
--prune-excluded-parents flag, but backward compatibility concerns
resulted in the current defaults.)

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/fast-export.c  |  7 ++++++-
 t/t9350-fast-export.sh | 13 +++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index f541f55d33..5822271c6b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -860,7 +860,12 @@ static void handle_tag(const char *name, struct tag *tag)
 
 	if (starts_with(name, "refs/tags/"))
 		name += 10;
-	printf("tag %s\nfrom :%d\n", name, tagged_mark);
+	printf("tag %s\n", name);
+	if (tagged_mark)
+		printf("from :%d\n", tagged_mark);
+	else
+		printf("from %s\n", oid_to_hex(&tagged->oid));
+
 	if (show_original_ids)
 		printf("original-oid %s\n", oid_to_hex(&tag->object.oid));
 	printf("%.*s%sdata %d\n%.*s\n",
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index b4004e05c2..d32ff41859 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -53,6 +53,19 @@ test_expect_success 'fast-export | fast-import' '
 
 '
 
+test_expect_success 'fast-export ^muss^{commit} muss' '
+	git fast-export --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual &&
+	cat >expected <<-EOF &&
+	tag muss
+	from $(git rev-parse --verify muss^{commit})
+	$(git cat-file tag muss | grep tagger)
+	data 9
+	valentin
+
+	EOF
+	test_cmp expected actual
+'
+
 test_expect_success 'fast-export master~2..master' '
 
 	git fast-export master~2..master >actual &&
-- 
2.23.0.177.g8af0b3ca64


  reply	other threads:[~2019-09-25  1:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25  1:39 [PATCH 0/8] fast export/import: handle nested tags, improve incremental exports Elijah Newren
2019-09-25  1:39 ` Elijah Newren [this message]
2019-09-25  1:39 ` [PATCH 2/8] fast-import: fix handling of deleted tags Elijah Newren
2019-09-25  1:40 ` [PATCH 3/8] fast-import: allow tags to be identified by mark labels Elijah Newren
2019-09-25  1:40 ` [PATCH 4/8] fast-import: add support for new 'alias' command Elijah Newren
2019-09-25  1:40 ` [PATCH 5/8] fast-export: add support for --import-marks-if-exists Elijah Newren
2019-09-25  1:40 ` [PATCH 6/8] fast-export: allow user to request tags be marked with --mark-tags Elijah Newren
2019-09-25  1:40 ` [PATCH 7/8] t9350: add tests for tags of things other than a commit Elijah Newren
2019-09-25  1:40 ` [PATCH 8/8] fast-export: handle nested tags Elijah Newren
2019-09-30 21:10 ` [PATCH v2 0/8] fast export/import: handle nested tags, improve incremental exports Elijah Newren
2019-09-30 21:10   ` [PATCH v2 1/8] fast-export: fix exporting a tag and nothing else Elijah Newren
2019-09-30 21:10   ` [PATCH v2 2/8] fast-import: fix handling of deleted tags Elijah Newren
2019-10-03 11:53     ` René Scharfe
2019-09-30 21:10   ` [PATCH v2 3/8] fast-import: allow tags to be identified by mark labels Elijah Newren
2019-09-30 21:10   ` [PATCH v2 4/8] fast-import: add support for new 'alias' command Elijah Newren
2019-09-30 21:10   ` [PATCH v2 5/8] fast-export: add support for --import-marks-if-exists Elijah Newren
2019-09-30 21:10   ` [PATCH v2 6/8] fast-export: allow user to request tags be marked with --mark-tags Elijah Newren
2019-09-30 21:10   ` [PATCH v2 7/8] t9350: add tests for tags of things other than a commit Elijah Newren
2019-09-30 21:10   ` [PATCH v2 8/8] fast-export: handle nested tags Elijah Newren
2019-10-02 15:54   ` [PATCH v2 0/8] fast export/import: handle nested tags, improve incremental exports Elijah Newren
2019-10-02 20:10     ` Junio C Hamano
2019-10-02 21:05       ` Elijah Newren
2019-10-03  1:07         ` Junio C Hamano
2019-10-03 20:27   ` [PATCH -v3 " Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 1/8] fast-export: fix exporting a tag and nothing else Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 2/8] fast-import: fix handling of deleted tags Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 3/8] fast-import: allow tags to be identified by mark labels Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 4/8] fast-import: add support for new 'alias' command Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 5/8] fast-export: add support for --import-marks-if-exists Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 6/8] fast-export: allow user to request tags be marked with --mark-tags Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 7/8] t9350: add tests for tags of things other than a commit Elijah Newren
2019-10-03 20:27     ` [PATCH -v3 8/8] fast-export: handle nested tags Elijah Newren
2019-10-04  5:51     ` [PATCH -v3 0/8] fast export/import: handle nested tags, improve incremental exports Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190925014005.17056-2-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).