8
8
)
9
9
10
10
var (
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'" )
13
14
)
14
15
15
16
// Branch contains information on the
@@ -21,6 +22,10 @@ type Branch struct {
21
22
Remote string
22
23
// Merge is the local refspec for the branch
23
24
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
24
29
25
30
raw * format.Subsection
26
31
}
@@ -35,6 +40,13 @@ func (b *Branch) Validate() error {
35
40
return errBranchInvalidMerge
36
41
}
37
42
43
+ if b .Rebase != "" &&
44
+ b .Rebase != "true" &&
45
+ b .Rebase != "interactive" &&
46
+ b .Rebase != "false" {
47
+ return errBranchInvalidRebase
48
+ }
49
+
38
50
return nil
39
51
}
40
52
@@ -57,6 +69,12 @@ func (b *Branch) marshal() *format.Subsection {
57
69
b .raw .SetOption (mergeKey , string (b .Merge ))
58
70
}
59
71
72
+ if b .Rebase == "" {
73
+ b .raw .RemoveOption (rebaseKey )
74
+ } else {
75
+ b .raw .SetOption (rebaseKey , string (b .Rebase ))
76
+ }
77
+
60
78
return b .raw
61
79
}
62
80
@@ -66,6 +84,7 @@ func (b *Branch) unmarshal(s *format.Subsection) error {
66
84
b .Name = b .raw .Name
67
85
b .Remote = b .raw .Options .Get (remoteSection )
68
86
b .Merge = plumbing .ReferenceName (b .raw .Options .Get (mergeKey ))
87
+ b .Rebase = b .raw .Options .Get (rebaseKey )
69
88
70
89
return b .Validate ()
71
90
}
0 commit comments