Skip to content

Crystal: args not parsed before git repo check #17

Description

@rsanheim

Problem

When running git-all-crystal with flags from inside a git repository, the flags get passed directly to git instead of being parsed by git-all.

Steps to reproduce:

cd /some/git-repo
git-all-crystal -n 8 status

Expected: git-all parses -n 8 as workers flag, runs status on sibling repos

Actual:

unknown option: -n
usage: git [-v | --version] [-h | --help] [-C <path>] ...

Cause

In crystal/src/git-all.cr, the is_inside_git_repo? check happens before argument parsing:

def main
  if Meta.dispatch(ARGV)
    exit 0
  end

  if is_inside_git_repo?
    passthrough_to_git(ARGV)  # passes raw ARGV including -n flag
  end

  options = parse_args(ARGV)  # never reached when inside a repo
  ...
end

Fix

Either:

  1. Parse args before the git repo check
  2. Check if the first non-flag arg is a known git-all command before passing through
  3. Match Rust/Zig behavior (need to verify how they handle this)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions