(path string)
| 136 | } |
| 137 | |
| 138 | func 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 | |
| 166 | func unlockAbortIfFileModifiedById(id string, lockClient *locking.Client) error { |
| 167 | // Get the path so we can check the status |
no test coverage detected