Skip to content

Support injecting additional CLI arguments to the commit step #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ohadlb
Copy link
Contributor

@ohadlb ohadlb commented May 29, 2025

This branch adds the new command-line flag -c that allows modifying the git commit step in the sync process. This is a flexible way to adapt git-sync to support different usecases

@ohadlb
Copy link
Contributor Author

ohadlb commented May 30, 2025

I'd like to add some context for this branch, because I'm not too sure about it myself.
As I alluded to in the README update, my main usecase here is to use git-sync on a company repo that has some strict requirements in the pre-commit hook, but given that I seem to be the first person to run into this problem in the years this project's been online I think it's safe to say this is a pretty marginal usecase that might not justify adding a dedicated flag. In addition, it's very likely that additional rare usecases will eventually appear that will require more and more for-one-user-only flags, so instead I opted to add this catch-all to just allow the user to set any additional arguments they find necessary.
However, I am aware that it is a problematic design. It requires the user to know the details of the commit commands the script uses and so on, while a dedicated abstract flag would allow the script to just do The Right Thing™.
Moreover I can point out that a user who truly wants to inject additional flags does not really need this new -c flag at all: via the magic of dynamic binding in the shell it's possible to change literally any aspect of the git invocation by creating a wrapper script for git-sync like this:

git () {
    case "$1" in
        commit)
            shift
            command git commit --no-verify "$@"
            ;;
        *)
            command git "$@"
            ;;
    esac
}
. git-sync "$@"

Note that the last line is . git-sync, sourcing the script rather than executing it.

Anyway, let me know what you think when you get around to reviewing this. I'm fine with any decision you make as project owner.

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

Successfully merging this pull request may close these issues.

1 participant