@@ -634,7 +634,7 @@ mktempdir() do dir
634
634
commit_oid1 = LibGit2. GitHash ()
635
635
commit_oid2 = LibGit2. GitHash ()
636
636
commit_oid3 = LibGit2. GitHash ()
637
- master_branch = " master"
637
+ default_branch = LibGit2 . getconfig ( " init.defaultBranch " , " master" )
638
638
test_branch = " test_branch"
639
639
test_branch2 = " test_branch_two"
640
640
tag1 = " tag1"
@@ -958,19 +958,19 @@ mktempdir() do dir
958
958
# various branch properties
959
959
@test LibGit2. isbranch (brref)
960
960
@test ! LibGit2. isremote (brref)
961
- @test LibGit2. name (brref) == " refs/heads/master "
962
- @test LibGit2. shortname (brref) == master_branch
961
+ @test LibGit2. name (brref) == " refs/heads/$(default_branch) "
962
+ @test LibGit2. shortname (brref) == default_branch
963
963
@test LibGit2. ishead (brref)
964
964
@test LibGit2. upstream (brref) === nothing
965
965
966
966
# showing the GitReference to this branch
967
967
show_strs = split (sprint (show, brref), " \n " )
968
968
@test show_strs[1 ] == " GitReference:"
969
- @test show_strs[2 ] == " Branch with name refs/heads/master "
969
+ @test show_strs[2 ] == " Branch with name refs/heads/$(default_branch) "
970
970
@test show_strs[3 ] == " Branch is HEAD."
971
971
@test repo. ptr == LibGit2. repository (brref). ptr
972
- @test brnch == master_branch
973
- @test LibGit2. headname (repo) == master_branch
972
+ @test brnch == default_branch
973
+ @test LibGit2. headname (repo) == default_branch
974
974
975
975
# create a branch *without* setting its tip as HEAD
976
976
LibGit2. branch! (repo, test_branch, string (commit_oid1), set_head= false )
@@ -991,7 +991,7 @@ mktempdir() do dir
991
991
end
992
992
end
993
993
branches = map (b-> LibGit2. shortname (b[1 ]), LibGit2. GitBranchIter (repo))
994
- @test master_branch in branches
994
+ @test default_branch in branches
995
995
@test test_branch in branches
996
996
end
997
997
end
@@ -1050,7 +1050,7 @@ mktempdir() do dir
1050
1050
@test tag2 in tags
1051
1051
1052
1052
refs = LibGit2. ref_list (repo)
1053
- @test refs == [" refs/heads/master " , " refs/heads/test_branch" , " refs/tags/tag1" , " refs/tags/tag2" ]
1053
+ @test refs == [" refs/heads/$(default_branch) " , " refs/heads/test_branch" , " refs/tags/tag1" , " refs/tags/tag2" ]
1054
1054
# test deleting a tag
1055
1055
LibGit2. tag_delete (repo, tag1)
1056
1056
tags = LibGit2. tag_list (repo)
@@ -1334,7 +1334,7 @@ mktempdir() do dir
1334
1334
add_and_commit_file (repo, " file1" , " 111\n " )
1335
1335
# switch back, add a commit, try to merge
1336
1336
# from branch/merge_a
1337
- LibGit2. branch! (repo, " master " )
1337
+ LibGit2. branch! (repo, default_branch )
1338
1338
1339
1339
# test for showing a Reference to a non-HEAD branch
1340
1340
brref = LibGit2. GitReference (repo, " refs/heads/branch/merge_a" )
@@ -1347,7 +1347,7 @@ mktempdir() do dir
1347
1347
1348
1348
add_and_commit_file (repo, " file2" , " 222\n " )
1349
1349
upst_ann = LibGit2. GitAnnotated (repo, " branch/merge_a" )
1350
- head_ann = LibGit2. GitAnnotated (repo, " master " )
1350
+ head_ann = LibGit2. GitAnnotated (repo, default_branch )
1351
1351
1352
1352
# (fail to) merge them because we can't fastforward
1353
1353
@test_logs (:warn ," Cannot perform fast-forward merge" ) ! LibGit2. merge! (repo, [upst_ann], true )
@@ -1360,7 +1360,7 @@ mktempdir() do dir
1360
1360
mv (joinpath (LibGit2. path (repo)," file1" ),joinpath (LibGit2. path (repo)," mvfile1" ))
1361
1361
LibGit2. add! (repo, " mvfile1" )
1362
1362
LibGit2. commit (repo, " move file1" )
1363
- LibGit2. branch! (repo, " master " )
1363
+ LibGit2. branch! (repo, default_branch )
1364
1364
upst_ann = LibGit2. GitAnnotated (repo, " branch/merge_b" )
1365
1365
rename_flag = Cint (0 )
1366
1366
rename_flag = LibGit2. toggle (rename_flag, Cint (0 )) # turns on the find renames opt
@@ -1438,14 +1438,14 @@ mktempdir() do dir
1438
1438
# the rebase should fail.
1439
1439
@test_throws LibGit2. GitError LibGit2. rebase! (repo)
1440
1440
# Try rebasing on master instead
1441
- newhead = LibGit2. rebase! (repo, master_branch )
1441
+ newhead = LibGit2. rebase! (repo, default_branch )
1442
1442
@test newhead == head_oid
1443
1443
1444
1444
# Switch to the master branch
1445
- LibGit2. branch! (repo, master_branch )
1445
+ LibGit2. branch! (repo, default_branch )
1446
1446
1447
1447
fetch_heads = LibGit2. fetchheads (repo)
1448
- @test fetch_heads[1 ]. name == " refs/heads/master "
1448
+ @test fetch_heads[1 ]. name == " refs/heads/$(default_branch) "
1449
1449
@test fetch_heads[1 ]. ismerge == true # we just merged master
1450
1450
@test fetch_heads[2 ]. name == " refs/heads/test_branch"
1451
1451
@test fetch_heads[2 ]. ismerge == false
@@ -1485,7 +1485,7 @@ mktempdir() do dir
1485
1485
1486
1486
# all tag in place
1487
1487
branches = map (b-> LibGit2. shortname (b[1 ]), LibGit2. GitBranchIter (repo))
1488
- @test master_branch in branches
1488
+ @test default_branch in branches
1489
1489
@test test_branch in branches
1490
1490
1491
1491
# issue #16337
@@ -1683,7 +1683,7 @@ mktempdir() do dir
1683
1683
# add yet another file
1684
1684
add_and_commit_file (repo, " file4" , " 444\n " )
1685
1685
# rebase with onto
1686
- newhead = LibGit2. rebase! (repo, " branch/a" , " master " )
1686
+ newhead = LibGit2. rebase! (repo, " branch/a" , default_branch )
1687
1687
1688
1688
newerhead = LibGit2. head_oid (repo)
1689
1689
@test newerhead == newhead
@@ -1693,7 +1693,7 @@ mktempdir() do dir
1693
1693
pre_abort_head = add_and_commit_file (repo, " file6" , " 666\n " )
1694
1694
# Rebase type
1695
1695
head_ann = LibGit2. GitAnnotated (repo, " branch/a" )
1696
- upst_ann = LibGit2. GitAnnotated (repo, " master " )
1696
+ upst_ann = LibGit2. GitAnnotated (repo, default_branch )
1697
1697
rb = LibGit2. GitRebase (repo, head_ann, upst_ann)
1698
1698
@test_throws BoundsError rb[3 ]
1699
1699
@test_throws BoundsError rb[0 ]
@@ -1718,7 +1718,7 @@ mktempdir() do dir
1718
1718
1719
1719
a_head = LibGit2. head_oid (repo)
1720
1720
add_and_commit_file (repo, " merge_file1" , " 111\n " )
1721
- LibGit2. branch! (repo, " master " )
1721
+ LibGit2. branch! (repo, default_branch )
1722
1722
a_head_ann = LibGit2. GitAnnotated (repo, " branch/merge_a" )
1723
1723
# merge returns true if successful
1724
1724
@test_logs (:info ," Review and commit merged changes" ) LibGit2. merge! (repo, [a_head_ann])
@@ -1751,7 +1751,7 @@ mktempdir() do dir
1751
1751
close (repo_file)
1752
1752
# and checkout HEAD once more
1753
1753
LibGit2. checkout_head (repo, options= LibGit2. CheckoutOptions (checkout_strategy= LibGit2. Consts. CHECKOUT_FORCE))
1754
- @test LibGit2. headname (repo) == master_branch
1754
+ @test LibGit2. headname (repo) == default_branch
1755
1755
@test ! LibGit2. isdirty (repo)
1756
1756
end
1757
1757
end
0 commit comments