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

feat(cli): Add --working-directory option #195

Closed
wants to merge 1 commit into from

Conversation

arxanas
Copy link
Contributor

@arxanas arxanas commented Mar 12, 2022

No description provided.

This is useful for an invocation of `cargo flamegraph` (and also probably for `cargo run`):

```
cargo flamegraph --bin git-stack --root -- --working-directory <repo>
```
@arxanas arxanas changed the title feat(cli): add --working-directory option feat(cli): Add --working-directory option Mar 12, 2022
@epage
Copy link
Collaborator

epage commented Mar 12, 2022

Could you help me understand the motivation? I'm not seeing git implement this, so its not for parity.

@arxanas
Copy link
Contributor Author

arxanas commented Mar 12, 2022

Oops, the motivation was in the commit message:

This is useful for an invocation of cargo flamegraph (and also probably for cargo run):

cargo flamegraph --bin git-stack --root -- --working-directory <repo>

The corresponding option in Git is -C.

@epage
Copy link
Collaborator

epage commented Mar 12, 2022

Oh, thanks!

I'll look at this more on monday to decide what the semantics should be standalone and as a git subcommand.

Right now I'm leaning towards this being -C and matching git's semantics (allowing multiple and doing path joins on them) but having it hidden as people will most likely be using it via git. I also want to see how git passes state for other related path flags to subcommands, like --git-dir, to make sure we respect them as well.

@arxanas
Copy link
Contributor Author

arxanas commented Mar 13, 2022

I suppose that if users can use -C from Git itself, then it might be better to hide this option and/or rename it so that it's obvious that it's for testing, or use a different mechanism like environment variables, or just drop the feature altogether since its use is limited. (For git-branchless, I added a -C flag primarily for testing with cargo run, but it doesn't actually do the behavior when specifying the flag multiple times.)

epage added a commit to epage/git-stack that referenced this pull request Mar 14, 2022
This helps when running outside of `git`.  Because of the limited case,
its hidden.

This supersedes gitext-rs#195
@epage epage mentioned this pull request Mar 14, 2022
@epage
Copy link
Collaborator

epage commented Mar 14, 2022

Closing in favor of #197

@epage epage closed this Mar 14, 2022
@arxanas arxanas deleted the workdir branch March 14, 2022 20:19
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.

2 participants