{"thread":{"id":"35052","subject":"[PATCH] fast-import: always save out branches, tags and marks on checkpoint","startedAt":"2013-10-02T12:24:57Z","lastAt":"2013-10-02T12:24:57Z","messageCount":1,"participants":["Dmitry Ivankov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"228518","messageId":"1380716697-7560-1-git-send-email-divanorama@gmail.com","threadId":"35052","inReplyTo":null,"subject":"[PATCH] fast-import: always save out branches, tags and marks on checkpoint","fromName":"Dmitry Ivankov","fromEmail":"divanorama@gmail.com","sentAt":"2013-10-02T12:24:57Z","receivedAt":"2013-10-02T12:24:57Z","isPatch":true,"sender":{"key":"divanorama@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158999?v=4"},"body":"checkpoint command causes fast-import to finish the current pack and\nstart a new one. If there are no (newly imported) objects in the pack\nfast-import does nothing with the pack AND doesn't save out branches,\ntags and marks.\n\nFix it by always saving out branches, tags and marks on a checkpoint.\n\nSimple test case where no new objects are created is\n$ fast-export $somebranch | sed $somebranch to $newbranch | fast-import\nWhile it's running send checkpoint signals to fast-import to avoid\nparsing the import stream. Non-fast-forward updates may happen if there\nare merges in $somebranch history. The fast-import may fail on\ncheckpoints now. Not a regression as it'd fail the same way before if\nimport is to a new/empty repository - the intermediate packs won't be\nempty and so a real checkpoint happens anyway.\n\nWhether fast-export really should reuse $somebranch name for all commits\nin it's history graph and so cause intermediate non-fast-forwads is a\nseparate topic to be discussed.\n\nSigned-off-by: Dmitry Ivankov <divanorama@gmail.com>\n---\n fast-import.c          |  9 ++++-----\n t/t9300-fast-import.sh | 26 ++++++++++++++++++++++++++\n 2 files changed, 30 insertions(+), 5 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex f4d9969..4a3b93f 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -3101,12 +3101,11 @@ static void parse_ls(struct branch *b)\n static void checkpoint(void)\n {\n \tcheckpoint_requested = 0;\n-\tif (object_count) {\n+\tif (object_count)\n \t\tcycle_packfile();\n-\t\tdump_branches();\n-\t\tdump_tags();\n-\t\tdump_marks();\n-\t}\n+\tdump_branches();\n+\tdump_tags();\n+\tdump_marks();\n }\n \n static void parse_checkpoint(void)\ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex 88fc407..03bfdef 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -693,6 +693,32 @@ test_expect_success \\\n \t'git cat-file commit other >actual &&\n \ttest_cmp expect actual'\n \n+cat >input2 <<INPUT_END\n+reset refs/heads/branch2\n+from refs/heads/other\n+\n+reset refs/heads/branch2\n+from refs/heads/branch\n+INPUT_END\n+\n+cat >input3 <<INPUT_END\n+reset refs/heads/branch3\n+from refs/heads/other\n+\n+checkpoint\n+\n+reset refs/heads/branch3\n+from refs/heads/branch\n+INPUT_END\n+\n+test_expect_success \\\n+\t'F: intermediate non-fast-forward' \\\n+\t'git fast-import <input2'\n+\n+test_expect_success \\\n+\t'F: intermediate non-fast-forward with zero objects checkpoint should fail' \\\n+\t'test_must_fail git fast-import <input3'\n+\n ###\n ### series G\n ###\n-- \n1.8.1.5\n"}]}