Skip to content
Permalink
Browse files

command/install: exit unsuccessfully on error

When git lfs install fails, exit unsuccessfully, so that the users
writing scripts can easily detect this error. Disable the test on
Windows, which does not have the proper chmod behavior to make the test
work.
  • Loading branch information...
bk2204 committed Apr 23, 2019
1 parent 2bbe78f commit 743f9b3ade4bd45d3cf2524cac951c7b9978d9c7
Showing with 34 additions and 2 deletions.
  1. +1 −1 commands/command_install.go
  2. +33 −1 t/t-install.sh
@@ -20,7 +20,7 @@ func installCommand(cmd *cobra.Command, args []string) {
if err := cmdInstallOptions().Install(); err != nil {
Print("WARNING: %s", err.Error())
Print("Run `git lfs install --force` to reset git config.")
return
os.Exit(2)
}

if !skipRepoInstall && (localInstall || cfg.InRepo()) {
@@ -35,7 +35,7 @@ begin_test "install with old (non-upgradeable) settings"
git config --global filter.lfs.clean "git-lfs clean --something %f"

git lfs install | tee install.log
[ "${PIPESTATUS[0]}" = 0 ]
[ "${PIPESTATUS[0]}" = 2 ]

grep -E "(clean|smudge)\" attribute should be" install.log
[ `grep -c "(MISSING)" install.log` = "0" ]
@@ -44,6 +44,7 @@ begin_test "install with old (non-upgradeable) settings"
[ "git-lfs clean --something %f" = "$(git config --global filter.lfs.clean)" ]

git lfs install --force

[ "git-lfs smudge -- %f" = "$(git config --global filter.lfs.smudge)" ]
[ "git-lfs clean -- %f" = "$(git config --global filter.lfs.clean)" ]
)
@@ -224,6 +225,37 @@ begin_test "install --local"
)
end_test

begin_test "install --local with failed permissions"
(
set -e

# Windows lacks POSIX permissions.
[ "$IS_WINDOWS" -eq 1 ] && exit 0

# old values that should be ignored by `install --local`
git config --global filter.lfs.smudge "git lfs smudge %f"
git config --global filter.lfs.clean "git lfs clean %f"

mkdir install-local-repo-perms
cd install-local-repo-perms
git init

# Make it impossible to write a new .git/config file so we can't write config
# options.
chmod 500 .git

res=0
git lfs install --local >err.log || res=$?

# Cleanup fails without this.
chmod 700 .git

cat err.log
grep -E "Error running.*git.*config" err.log
[ "$res" -eq 2 ]
)
end_test

begin_test "install --local outside repository"
(
# If run inside the git-lfs source dir this will update its .git/config & cause issues

0 comments on commit 743f9b3

Please sign in to comment.
You can’t perform that action at this time.