Skip to content

Commit

Permalink
Fix: Give correct error message for unrecognised options
Browse files Browse the repository at this point in the history
The first unknown thing was always treated as the URL. So in cases where the unrecognised option was before the URL the URL caused the error.
This fixes this by checking the unknown thing if it could be meant as a option. If it is a option it is not set as the URL but produces the error.

In addition two tests are added to check the produced error messages in both cases.

fixes #522
  • Loading branch information
LukasFritzeDev committed Jun 23, 2019
1 parent 162ca3f commit 27a1de7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Version 1.6.0-UNRELEASED
* Fix directory creation with SFTP
* Fix submodule handling
* Fix/Add suport for nested branch names by allowing `/` in scope names
* Fix error message for unrecognised options
* Pass insecure-flag to submodules
* Pass ssh-keys to submodules if used
* Add support for config `disable-epsv` and `no-commit`
Expand Down
2 changes: 1 addition & 1 deletion git-ftp
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ do
*)
# Pass thru anything that may be meant for fetch.
if [ -n "$1" ]; then
if [ -z "$URL" ]; then
if [ -z "$URL" ] && ! echo "$1" | egrep -q '^(-[A-Za-z])|^(--[A-Za-z0-9-]+)'; then
URL="$1"
elif [ "$ACTION" == "snapshot" -a -z "$SNAPSHOT_DIR" ]; then
SNAPSHOT_DIR="$1"
Expand Down
13 changes: 13 additions & 0 deletions tests/git-ftp-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,19 @@ test_post_push_fail() {
assertEquals $ERROR_HOOK $rtrn
}

test_unrecognised_option(){
out="$($GIT_FTP init -i 2>&1 )"
assertEquals $ERROR_MISSING_ARGUMENTS $?
echo "$out" | grep -q "fatal: Unrecognised option: -i"
assertEquals 0 $?
}
test_unrecognised_option_before_url(){
out="$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD --invalid-option $GIT_FTP_URL 2>&1 )"
assertEquals $ERROR_MISSING_ARGUMENTS $?
echo "$out" | grep -q "fatal: Unrecognised option: --invalid-option"
assertEquals 0 $?
}

disabled_test_file_named_dash() {
echo "foobar" > -
assertTrue 'test failed: file named - not there as expected' "[ -f '$GIT_PROJECT_PATH/-' ]"
Expand Down

0 comments on commit 27a1de7

Please sign in to comment.