88)
99
1010var (
11- errBranchEmptyName = errors .New ("branch config: empty name" )
12- errBranchInvalidMerge = errors .New ("branch config: invalid merge" )
11+ errBranchEmptyName = errors .New ("branch config: empty name" )
12+ errBranchInvalidMerge = errors .New ("branch config: invalid merge" )
13+ errBranchInvalidRebase = errors .New ("branch config: rebase must be one of 'true' or 'interactive'" )
1314)
1415
1516// Branch contains information on the
@@ -21,6 +22,10 @@ type Branch struct {
2122 Remote string
2223 // Merge is the local refspec for the branch
2324 Merge plumbing.ReferenceName
25+ // Rebase instead of merge when pulling. Valid values are
26+ // "true" and "interactive". "false" is undocumented and
27+ // typically represented by the non-existence of this field
28+ Rebase string
2429
2530 raw * format.Subsection
2631}
@@ -35,6 +40,13 @@ func (b *Branch) Validate() error {
3540 return errBranchInvalidMerge
3641 }
3742
43+ if b .Rebase != "" &&
44+ b .Rebase != "true" &&
45+ b .Rebase != "interactive" &&
46+ b .Rebase != "false" {
47+ return errBranchInvalidRebase
48+ }
49+
3850 return nil
3951}
4052
@@ -57,6 +69,12 @@ func (b *Branch) marshal() *format.Subsection {
5769 b .raw .SetOption (mergeKey , string (b .Merge ))
5870 }
5971
72+ if b .Rebase == "" {
73+ b .raw .RemoveOption (rebaseKey )
74+ } else {
75+ b .raw .SetOption (rebaseKey , string (b .Rebase ))
76+ }
77+
6078 return b .raw
6179}
6280
@@ -66,6 +84,7 @@ func (b *Branch) unmarshal(s *format.Subsection) error {
6684 b .Name = b .raw .Name
6785 b .Remote = b .raw .Options .Get (remoteSection )
6886 b .Merge = plumbing .ReferenceName (b .raw .Options .Get (mergeKey ))
87+ b .Rebase = b .raw .Options .Get (rebaseKey )
6988
7089 return b .Validate ()
7190}
0 commit comments