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

Command alias doesn't work in repo-level config #2414

Closed
martinvonz opened this issue Oct 22, 2023 · 2 comments
Closed

Command alias doesn't work in repo-level config #2414

martinvonz opened this issue Oct 22, 2023 · 2 comments
Labels
🐛bug Something isn't working

Comments

@martinvonz
Copy link
Member

martinvonz commented Oct 22, 2023

Description

I'm filing this on @ppwwyyxx's behalf. Copying from #982 (comment):

This is what I got:

❯ 14:18 cd $(mktemp -d) ; jj init --git
Initialized repo in "."
❯ 14:18 echo 'aliases.foo = ["diff"]' > .jj/repo/config.toml
❯ 14:18 jj config list aliases.foo
❯ 14:18 jj config --no-pager list aliases.foo
aliases.foo=["diff"]
❯ 14:18 jj foo
error: unrecognized subcommand 'foo'

Usage: jj [OPTIONS] [COMMAND]

For more information, try '--help'.

Specifications

  • Platform: unknown
  • Version: 0.10.0-8dbe12da2a6d771d3409b19b76bf0f8781e6b218
@martinvonz
Copy link
Member Author

I have no idea what the problem could be here. @ppwwyyxx, can you think of anything unusual in your setup? What else do you have in your config? Is jj a shell alias? What shell do you use?

@yuja
Copy link
Contributor

yuja commented Oct 23, 2023

There's a TODO about this. The repository path isn't determined until the command arguments gets parsed.
https://github.com/martinvonz/jj/blob/171896aefa4c65be37e3b325fe5441b3d0885da3/cli/src/cli_util.rs#L2783-L2802

Possible workarounds:

  • show warning (as the comment says)
  • load temporary repo config from cwd and use it only for command alias expansion
  • parse command arguments without aliases as much as possible, and use -R to load temporary repo config

In any case, it's better to show warning if the repository path was different from the one we use for alias expansion.

@PhilipMetzger PhilipMetzger added the 🐛bug Something isn't working label Oct 25, 2023
yuja added a commit to yuja/jj that referenced this issue Dec 23, 2023
… aliases

This is basically the same as Mercurial's workaround. I don't know about Git,
but arguments order is very restricted in git, so -C path can be parsed prior
to alias expansion. In hg and jj, doing that would be messy and unreliable.

Closes jj-vcs#2414
yuja added a commit to yuja/jj that referenced this issue Dec 23, 2023
… aliases

This is basically the same as Mercurial's workaround. I don't know about Git,
but arguments order is very restricted in git, so -C path can be parsed prior
to alias expansion. In hg and jj, doing that would be messy and unreliable.

Closes jj-vcs#2414
yuja added a commit to yuja/jj that referenced this issue Dec 23, 2023
… aliases

This is basically the same as Mercurial's workaround. I don't know about Git,
but arguments order is very restricted in git, so -C path can be parsed prior
to alias expansion. In hg and jj, doing that would be messy and unreliable.

Closes jj-vcs#2414
@yuja yuja closed this as completed in 30b5e88 Dec 23, 2023
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 8, 2024
## [0.13.0] - 2024-01-03

### Breaking changes

* `jj git fetch` no longer imports new remote branches as local branches. Set
  `git.auto-local-branch = true` to restore the old behavior.

### New features

* Information about new and resolved conflicts is now printed by every command.

* `jj branch` has gained a new `rename` subcommand that allows changing a branch
  name atomically. `jj branch help rename` for details.

### Fixed bugs

* Command aliases can now be loaded from repository config relative to the
  current working directory.
  [#2414](jj-vcs/jj#2414)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants