MCPcopy
hub / github.com/go-git/go-git / status

Method status

worktree_status.go:64–122  ·  view source on GitHub ↗
(ss StatusStrategy, commit plumbing.Hash)

Source from the content-addressed store, hash-verified

62}
63
64func (w *Worktree) status(ss StatusStrategy, commit plumbing.Hash) (Status, error) {
65 s, err := ss.new(w)
66 if err != nil {
67 return nil, err
68 }
69
70 left, err := w.diffCommitWithStaging(commit, false)
71 if err != nil {
72 return nil, err
73 }
74
75 for _, ch := range left {
76 a, err := ch.Action()
77 if err != nil {
78 return nil, err
79 }
80
81 fs := s.File(nameFromAction(&ch))
82 fs.Worktree = Unmodified
83
84 switch a {
85 case merkletrie.Delete:
86 s.File(ch.From.String()).Staging = Deleted
87 case merkletrie.Insert:
88 s.File(ch.To.String()).Staging = Added
89 case merkletrie.Modify:
90 s.File(ch.To.String()).Staging = Modified
91 }
92 }
93
94 right, err := w.diffStagingWithWorktree(false, true)
95 if err != nil {
96 return nil, err
97 }
98
99 for _, ch := range right {
100 a, err := ch.Action()
101 if err != nil {
102 return nil, err
103 }
104
105 fs := s.File(nameFromAction(&ch))
106 if fs.Staging == Untracked {
107 fs.Staging = Unmodified
108 }
109
110 switch a {
111 case merkletrie.Delete:
112 fs.Worktree = Deleted
113 case merkletrie.Insert:
114 fs.Worktree = Untracked
115 fs.Staging = Untracked
116 case merkletrie.Modify:
117 fs.Worktree = Modified
118 }
119 }
120
121 return s, nil

Callers 1

StatusWithOptionsMethod · 0.95

Calls 7

diffCommitWithStagingMethod · 0.95
nameFromActionFunction · 0.85
newMethod · 0.80
StringMethod · 0.65
ActionMethod · 0.45
FileMethod · 0.45

Tested by

no test coverage detected