path: root/t/
diff options
authorElijah Newren <>2018-11-16 07:59:53 (GMT)
committerJunio C Hamano <>2018-11-17 09:43:52 (GMT)
commitfdf31b6369a4c66a2db743ee480f97daa239fc81 (patch)
treed8280066ffc952539eb7815862c9512c6b845028 /t/
parentcd13762d8f837b6339b7d9f3090c0de44d3e01aa (diff)
fast-export: ensure we export requested refs
If file paths are specified to fast-export and a ref points to a commit that does not touch any of the relevant paths, then that ref would sometimes fail to be exported. (This depends on whether any ancestors of the commit which do touch the relevant paths would be exported with that same ref name or a different ref name.) To avoid this problem, put *all* specified refs into extra_refs to start, and then as we export each commit, remove the refname used in the 'commit $REFNAME' directive from extra_refs. Then, in handle_tags_and_duplicates() we know which refs actually do need a manual reset directive in order to be included. This means that we do need some special handling for excluded refs; e.g. if someone runs git fast-export ^master master then they've asked for master to be exported, but they have also asked for the commit which master points to and all of its history to be excluded. That logically means ref deletion. Previously, such refs were just silently omitted from being exported despite having been explicitly requested for export. Signed-off-by: Elijah Newren <> Acked-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 13 insertions, 3 deletions
diff --git a/t/ b/t/
index 299120b..50c2fce 100755
--- a/t/
+++ b/t/
@@ -544,10 +544,20 @@ test_expect_success 'use refspec' '
test_cmp expected actual
-test_expect_success 'delete refspec' '
+test_expect_success 'delete ref because entire history excluded' '
git branch to-delete &&
- git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual &&
- cat > expected <<-EOF &&
+ git fast-export to-delete ^to-delete >actual &&
+ cat >expected <<-EOF &&
+ reset refs/heads/to-delete
+ from 0000000000000000000000000000000000000000
+ test_cmp expected actual
+test_expect_success 'delete refspec' '
+ git fast-export --refspec :refs/heads/to-delete >actual &&
+ cat >expected <<-EOF &&
reset refs/heads/to-delete
from 0000000000000000000000000000000000000000