Merge pull request #3378 from git-lfs/ttaylorr/status-in-working-copy
commands/command_status.go: require a working copy
This commit is contained in:
commit
836e241986
@ -22,6 +22,7 @@ var (
|
||||
|
||||
func statusCommand(cmd *cobra.Command, args []string) {
|
||||
requireInRepo()
|
||||
requireWorkingCopy()
|
||||
|
||||
// tolerate errors getting ref so this works before first commit
|
||||
ref, _ := git.CurrentRef()
|
||||
|
@ -309,6 +309,22 @@ func requireInRepo() {
|
||||
}
|
||||
}
|
||||
|
||||
// requireWorkingCopy requires that the working directory be a work tree, i.e.,
|
||||
// that it not be bare. If it is bare (or the state of the repository could not
|
||||
// be determined), this function will terminate the program.
|
||||
func requireWorkingCopy() {
|
||||
bare, err := git.IsBare()
|
||||
if err != nil {
|
||||
ExitWithError(errors.Wrap(
|
||||
err, "fatal: could not determine bareness"))
|
||||
}
|
||||
|
||||
if bare {
|
||||
Print("This operation must be run in a work tree.")
|
||||
os.Exit(128)
|
||||
}
|
||||
}
|
||||
|
||||
func handlePanic(err error) string {
|
||||
if err == nil {
|
||||
return ""
|
||||
|
@ -18,6 +18,8 @@ Display paths of Git LFS objects that
|
||||
* have differences between the working tree and the index file. These
|
||||
are files that could be staged using `git add`.
|
||||
|
||||
This command must be run in a non-bare repository.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
* `--porcelain`:
|
||||
|
@ -448,3 +448,19 @@ Git LFS objects not staged for commit:"
|
||||
[ "$expected" = "$(git lfs status)" ]
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "status (without a working copy)"
|
||||
(
|
||||
reponame="status-no-working-copy.git"
|
||||
|
||||
git init --bare "$reponame"
|
||||
cd "$reponame"
|
||||
|
||||
git lfs status 2>&1 | tee status.log
|
||||
if [ "0" -eq "${PIPESTATUS[0]}" ]; then
|
||||
echo >&2 "git lfs status should have failed, didn't ..."
|
||||
exit 1
|
||||
fi
|
||||
[ "This operation must be run in a work tree." = "$(cat status.log)" ]
|
||||
)
|
||||
end_test
|
||||
|
Loading…
Reference in New Issue
Block a user