git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH] fast-import: always save out branches, tags and marks on checkpoint
Date: Wed,  2 Oct 2013 18:24:57 +0600	[thread overview]
Message-ID: <1380716697-7560-1-git-send-email-divanorama@gmail.com> (raw)

checkpoint command causes fast-import to finish the current pack and
start a new one. If there are no (newly imported) objects in the pack
fast-import does nothing with the pack AND doesn't save out branches,
tags and marks.

Fix it by always saving out branches, tags and marks on a checkpoint.

Simple test case where no new objects are created is
$ fast-export $somebranch | sed $somebranch to $newbranch | fast-import
While it's running send checkpoint signals to fast-import to avoid
parsing the import stream. Non-fast-forward updates may happen if there
are merges in $somebranch history. The fast-import may fail on
checkpoints now. Not a regression as it'd fail the same way before if
import is to a new/empty repository - the intermediate packs won't be
empty and so a real checkpoint happens anyway.

Whether fast-export really should reuse $somebranch name for all commits
in it's history graph and so cause intermediate non-fast-forwads is a
separate topic to be discussed.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
 fast-import.c          |  9 ++++-----
 t/t9300-fast-import.sh | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index f4d9969..4a3b93f 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3101,12 +3101,11 @@ static void parse_ls(struct branch *b)
 static void checkpoint(void)
 {
 	checkpoint_requested = 0;
-	if (object_count) {
+	if (object_count)
 		cycle_packfile();
-		dump_branches();
-		dump_tags();
-		dump_marks();
-	}
+	dump_branches();
+	dump_tags();
+	dump_marks();
 }
 
 static void parse_checkpoint(void)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 88fc407..03bfdef 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -693,6 +693,32 @@ test_expect_success \
 	'git cat-file commit other >actual &&
 	test_cmp expect actual'
 
+cat >input2 <<INPUT_END
+reset refs/heads/branch2
+from refs/heads/other
+
+reset refs/heads/branch2
+from refs/heads/branch
+INPUT_END
+
+cat >input3 <<INPUT_END
+reset refs/heads/branch3
+from refs/heads/other
+
+checkpoint
+
+reset refs/heads/branch3
+from refs/heads/branch
+INPUT_END
+
+test_expect_success \
+	'F: intermediate non-fast-forward' \
+	'git fast-import <input2'
+
+test_expect_success \
+	'F: intermediate non-fast-forward with zero objects checkpoint should fail' \
+	'test_must_fail git fast-import <input3'
+
 ###
 ### series G
 ###
-- 
1.8.1.5

                 reply	other threads:[~2013-10-02 12:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=1380716697-7560-1-git-send-email-divanorama@gmail.com \
    --to=divanorama@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).