@@ -634,7 +634,7 @@ mktempdir() do dir
634634 commit_oid1 = LibGit2. GitHash ()
635635 commit_oid2 = LibGit2. GitHash ()
636636 commit_oid3 = LibGit2. GitHash ()
637- master_branch = " master"
637+ default_branch = LibGit2 . getconfig ( " init.defaultBranch " , " master" )
638638 test_branch = " test_branch"
639639 test_branch2 = " test_branch_two"
640640 tag1 = " tag1"
@@ -958,19 +958,19 @@ mktempdir() do dir
958958 # various branch properties
959959 @test LibGit2. isbranch (brref)
960960 @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
963963 @test LibGit2. ishead (brref)
964964 @test LibGit2. upstream (brref) === nothing
965965
966966 # showing the GitReference to this branch
967967 show_strs = split (sprint (show, brref), " \n " )
968968 @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) "
970970 @test show_strs[3 ] == " Branch is HEAD."
971971 @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
974974
975975 # create a branch *without* setting its tip as HEAD
976976 LibGit2. branch! (repo, test_branch, string (commit_oid1), set_head= false )
@@ -991,7 +991,7 @@ mktempdir() do dir
991991 end
992992 end
993993 branches = map (b-> LibGit2. shortname (b[1 ]), LibGit2. GitBranchIter (repo))
994- @test master_branch in branches
994+ @test default_branch in branches
995995 @test test_branch in branches
996996 end
997997 end
@@ -1050,7 +1050,7 @@ mktempdir() do dir
10501050 @test tag2 in tags
10511051
10521052 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" ]
10541054 # test deleting a tag
10551055 LibGit2. tag_delete (repo, tag1)
10561056 tags = LibGit2. tag_list (repo)
@@ -1334,7 +1334,7 @@ mktempdir() do dir
13341334 add_and_commit_file (repo, " file1" , " 111\n " )
13351335 # switch back, add a commit, try to merge
13361336 # from branch/merge_a
1337- LibGit2. branch! (repo, " master " )
1337+ LibGit2. branch! (repo, default_branch )
13381338
13391339 # test for showing a Reference to a non-HEAD branch
13401340 brref = LibGit2. GitReference (repo, " refs/heads/branch/merge_a" )
@@ -1347,7 +1347,7 @@ mktempdir() do dir
13471347
13481348 add_and_commit_file (repo, " file2" , " 222\n " )
13491349 upst_ann = LibGit2. GitAnnotated (repo, " branch/merge_a" )
1350- head_ann = LibGit2. GitAnnotated (repo, " master " )
1350+ head_ann = LibGit2. GitAnnotated (repo, default_branch )
13511351
13521352 # (fail to) merge them because we can't fastforward
13531353 @test_logs (:warn ," Cannot perform fast-forward merge" ) ! LibGit2. merge! (repo, [upst_ann], true )
@@ -1360,7 +1360,7 @@ mktempdir() do dir
13601360 mv (joinpath (LibGit2. path (repo)," file1" ),joinpath (LibGit2. path (repo)," mvfile1" ))
13611361 LibGit2. add! (repo, " mvfile1" )
13621362 LibGit2. commit (repo, " move file1" )
1363- LibGit2. branch! (repo, " master " )
1363+ LibGit2. branch! (repo, default_branch )
13641364 upst_ann = LibGit2. GitAnnotated (repo, " branch/merge_b" )
13651365 rename_flag = Cint (0 )
13661366 rename_flag = LibGit2. toggle (rename_flag, Cint (0 )) # turns on the find renames opt
@@ -1438,14 +1438,14 @@ mktempdir() do dir
14381438 # the rebase should fail.
14391439 @test_throws LibGit2. GitError LibGit2. rebase! (repo)
14401440 # Try rebasing on master instead
1441- newhead = LibGit2. rebase! (repo, master_branch )
1441+ newhead = LibGit2. rebase! (repo, default_branch )
14421442 @test newhead == head_oid
14431443
14441444 # Switch to the master branch
1445- LibGit2. branch! (repo, master_branch )
1445+ LibGit2. branch! (repo, default_branch )
14461446
14471447 fetch_heads = LibGit2. fetchheads (repo)
1448- @test fetch_heads[1 ]. name == " refs/heads/master "
1448+ @test fetch_heads[1 ]. name == " refs/heads/$(default_branch) "
14491449 @test fetch_heads[1 ]. ismerge == true # we just merged master
14501450 @test fetch_heads[2 ]. name == " refs/heads/test_branch"
14511451 @test fetch_heads[2 ]. ismerge == false
@@ -1485,7 +1485,7 @@ mktempdir() do dir
14851485
14861486 # all tag in place
14871487 branches = map (b-> LibGit2. shortname (b[1 ]), LibGit2. GitBranchIter (repo))
1488- @test master_branch in branches
1488+ @test default_branch in branches
14891489 @test test_branch in branches
14901490
14911491 # issue #16337
@@ -1683,7 +1683,7 @@ mktempdir() do dir
16831683 # add yet another file
16841684 add_and_commit_file (repo, " file4" , " 444\n " )
16851685 # rebase with onto
1686- newhead = LibGit2. rebase! (repo, " branch/a" , " master " )
1686+ newhead = LibGit2. rebase! (repo, " branch/a" , default_branch )
16871687
16881688 newerhead = LibGit2. head_oid (repo)
16891689 @test newerhead == newhead
@@ -1693,7 +1693,7 @@ mktempdir() do dir
16931693 pre_abort_head = add_and_commit_file (repo, " file6" , " 666\n " )
16941694 # Rebase type
16951695 head_ann = LibGit2. GitAnnotated (repo, " branch/a" )
1696- upst_ann = LibGit2. GitAnnotated (repo, " master " )
1696+ upst_ann = LibGit2. GitAnnotated (repo, default_branch )
16971697 rb = LibGit2. GitRebase (repo, head_ann, upst_ann)
16981698 @test_throws BoundsError rb[3 ]
16991699 @test_throws BoundsError rb[0 ]
@@ -1718,7 +1718,7 @@ mktempdir() do dir
17181718
17191719 a_head = LibGit2. head_oid (repo)
17201720 add_and_commit_file (repo, " merge_file1" , " 111\n " )
1721- LibGit2. branch! (repo, " master " )
1721+ LibGit2. branch! (repo, default_branch )
17221722 a_head_ann = LibGit2. GitAnnotated (repo, " branch/merge_a" )
17231723 # merge returns true if successful
17241724 @test_logs (:info ," Review and commit merged changes" ) LibGit2. merge! (repo, [a_head_ann])
@@ -1751,7 +1751,7 @@ mktempdir() do dir
17511751 close (repo_file)
17521752 # and checkout HEAD once more
17531753 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
17551755 @test ! LibGit2. isdirty (repo)
17561756 end
17571757 end
0 commit comments