commands: teach ls-files to fail with argument and '--all'

This commit is contained in:
Taylor Blau 2017-12-19 18:52:38 -05:00
parent 4ba685a38c
commit 2d5611f8b8
2 changed files with 22 additions and 0 deletions

@ -23,6 +23,9 @@ func lsFilesCommand(cmd *cobra.Command, args []string) {
var ref string
if len(args) == 1 {
if lsFilesScanAll {
Exit("fatal: cannot use --all with explicit reference")
}
ref = args[0]
} else {
fullref, err := git.CurrentRef()

@ -262,3 +262,22 @@ begin_test "ls-files: history with --all"
[ 1 -eq $(grep -c "b\.dat" ls-files-all.log) ]
)
end_test
begin_test "ls-files: --all with argument(s)"
(
set -e
reponame="ls-files-all-with-arguments"
git init "$reponame"
cd "$reponame"
git lfs ls-files --all master 2>&1 | tee ls-files.log
if [ "0" -eq "${PIPESTATUS[0]}" ]; then
echo >&2 "fatal: \`git lfs ls-files --all master\` to fail"
exit 1
fi
[ "fatal: cannot use --all with explicit reference" = "$(cat ls-files.log)" ]
)
end_test