@@ -9,11 +9,21 @@ import (
99 "sort"
1010 "strconv"
1111 "strings"
12- "syscall"
1312
1413 "github.com/git-lfs/gitobj/v2/pack"
1514)
1615
16+ // We define these here instead of using the system ones because not all
17+ // operating systems use the traditional values. For example, zOS uses
18+ // different values.
19+ const (
20+ sIFMT = int32 (0170000 )
21+ sIFREG = int32 (0100000 )
22+ sIFDIR = int32 (0040000 )
23+ sIFLNK = int32 (0120000 )
24+ sIFGITLINK = int32 (0160000 )
25+ )
26+
1727// Tree encapsulates a Git tree object.
1828type Tree struct {
1929 // Entries is the list of entries held by this tree.
@@ -209,24 +219,18 @@ func (e *TreeEntry) Equal(other *TreeEntry) bool {
209219// Type is the type of entry (either blob: BlobObjectType, or a sub-tree:
210220// TreeObjectType).
211221func (e * TreeEntry ) Type () ObjectType {
212- switch e .Filemode & syscall . S_IFMT {
213- case syscall . S_IFREG :
222+ switch e .Filemode & sIFMT {
223+ case sIFREG :
214224 return BlobObjectType
215- case syscall . S_IFDIR :
225+ case sIFDIR :
216226 return TreeObjectType
217- case syscall . S_IFLNK :
227+ case sIFLNK :
218228 return BlobObjectType
229+ case sIFGITLINK :
230+ return CommitObjectType
219231 default :
220- if e .Filemode == 0xe000 {
221- // Mode 0xe000, or a gitlink, has no formal filesystem
222- // (`syscall.S_IF<t>`) equivalent.
223- //
224- // Safeguard that catch here, or otherwise panic.
225- return CommitObjectType
226- } else {
227- panic (fmt .Sprintf ("gitobj: unknown object type: %o" ,
228- e .Filemode ))
229- }
232+ panic (fmt .Sprintf ("gitobj: unknown object type: %o" ,
233+ e .Filemode ))
230234 }
231235}
232236
0 commit comments