MCPcopy
hub / github.com/git-lfs/git-lfs / unlockAbortIfFileModified

Function unlockAbortIfFileModified

commands/command_unlock.go:138–164  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

136}
137
138func unlockAbortIfFileModified(path string) error {
139 modified, err := git.IsFileModified(path)
140
141 if err != nil {
142 if unlockCmdFlags.Force {
143 // Since git/git@b9a7d55, `git-status(1)` causes an
144 // error when asked about files that don't exist,
145 // causing `err != nil`, as above.
146 //
147 // Unlocking a files that does not exist with
148 // --force is OK.
149 return nil
150 }
151 return err
152 }
153
154 if modified {
155 if unlockCmdFlags.Force {
156 // Only a warning
157 Error(tr.Tr.Get("warning: unlocking with uncommitted changes because --force"))
158 } else {
159 return errors.New(tr.Tr.Get("Cannot unlock file with uncommitted changes"))
160 }
161
162 }
163 return nil
164}
165
166func unlockAbortIfFileModifiedById(id string, lockClient *locking.Client) error {
167 // Get the path so we can check the status

Callers 2

unlockCommandFunction · 0.85

Calls 4

IsFileModifiedFunction · 0.92
NewFunction · 0.92
ErrorFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected