Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong argument parsing logic results in hooks not being called #212

Open
dnebauer opened this issue Aug 21, 2016 · 1 comment
Open

wrong argument parsing logic results in hooks not being called #212

dnebauer opened this issue Aug 21, 2016 · 1 comment

Comments

@dnebauer
Copy link

dnebauer commented Aug 21, 2016

[Line numbers refer to version 1.20151229 (current debian testing)]

The command line argument parsing logic is incorrect and means that hooks that should be called are not called. This occurs when a repo name is included in the command, such as vcsh zsh push.

The problem starts at line 521 where VCSH_COMMAND is set to $1, i.e., the repo name 'zsh'. That means no match is found in the following command-expansion case-block (lines 523-539). For example, if the command is pus the case-block does not expand that to push.

The following if-block (lines 541-620) fails to match VCSH_COMMAND, which is now set to repo name 'zsh', to a git command. It drops through to the elif [ -n "$2" ] branch which sets VCSH_COMMAND to 'run', VCSH_REPO_NAME (correctly) to repo name 'zsh', and the positional parameters to 'git' and 'push'. That means line 659 ($VCSH_COMMAND "$@") becomes run git push. In the 'run()' function this becomes git push.

The fundamental problem with processing this three-item command line is that when vcsh is matching the vcsh command (in the if-block from lines 541-620), the VCSH_COMMAND variable is set to the repo name. While this example uses the 'push' command, the same problem will occur for most other commands.

It is not possible to put a workaround in the 'pre-command' and 'post-command' hooks because the actual vcsh command remains a positional parameter of the vcsh script itself and there is no way for either of these hook scripts to discover it. The vcsh script needs to be fixed to enable the pre- and post-push hooks (and other hooks) to be called.

@alerque
Copy link
Collaborator

alerque commented Apr 3, 2021

Confirmed, this is one of several edge cases where the current argument handling can do the wrong thing. Blindly assigning $VCSH_COMMAND to $1 before checking that it a supported command is wrong, as are a couple latter assumptions that something is a repo name even if one doesn't exist.

#239 will clear up some hook handling issues, but not the core problem described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants