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

Conditional config doesn't apply when initializing or cloning a repository #5144

Closed
jennings opened this issue Dec 19, 2024 · 3 comments
Closed
Assignees

Comments

@jennings
Copy link
Contributor

Description

When initializing or cloning a new repository, conditional config is not considered when creating the first empty commit.

Steps to Reproduce the Problem

  1. Add the following conditional config (Windows, but probably not relevant to this issue):
    [user]
    name = "Stephen"
    [[--scope]]
    --when.repositories = ["\\\\?\\C:\\src\\github.com"]
    [--scope.user]
    email = "stephen@example.com"
  2. Execute: jj git clone git@github.com:jj-vcs/jj C:\src\github.com\jj

Expected Behavior

The working copy commit created by jj should have the email stephen@example.com.

Actual Behavior

The working copy commit has no email address set.

Specifications

  • Platform: Windows
  • Version: jj 0.24.0-f5d450d7c3a8f8a49e30aef0fd18d8295ffc8cb6
@yuja
Copy link
Contributor

yuja commented Dec 19, 2024

It's working as intended (because the repository to load configuration for doesn't exist), but yeah, it's a bit inconvenient. We might need some way to specify configuration for the cwd, not for the repository/workspace directory.

EDIT: or add special case to initialization commands to preload settings for the destination directory.

@jennings
Copy link
Contributor Author

Don't get me wrong, I'm very grateful to have this feature now. I simply ran into this and #5144 when setting it up, so I wanted to write it down before I forgot.

Suppose we had both --when.repositories and --when.cwd. Is there a scenario when you'd want the repositories behavior? If not, I think special case might make the most sense.

@yuja
Copy link
Contributor

yuja commented Dec 19, 2024

Suppose we had both --when.repositories and --when.cwd. Is there a scenario when you'd want the repositories behavior? If not, I think special case might make the most sense.

In most scenarios, --when.repositories (or --when.workspaces) would be preferred. The workspace path can be specified by -R (which doesn't change the cwd.) That said, I agree that special case is probably better. It might look ugly, but initialization code is a bit weird in some way.

@yuja yuja self-assigned this Dec 29, 2024
yuja added a commit to yuja/jj that referenced this issue Dec 30, 2024
There are no external callers, and WorkspaceCommandEnvironment might have to
keep a separate copy of UserSettings in order to address jj-vcs#5144.
yuja added a commit that referenced this issue Dec 30, 2024
There are no external callers, and WorkspaceCommandEnvironment might have to
keep a separate copy of UserSettings in order to address #5144.
yuja added a commit to yuja/jj that referenced this issue Dec 30, 2024
I think the issue jj-vcs#5144 can be fixed cleanly if UserSettings object is
instantiated per repo/workspace, not per CommandHelper. This change makes it
clear that UserSettings is supposed to be shared immutably.
yuja added a commit to yuja/jj that referenced this issue Dec 30, 2024
I think the issue jj-vcs#5144 can be fixed cleanly if UserSettings object is
loaded/resolved per repo/workspace, not per CommandHelper.

This change makes it clear that UserSettings is supposed to be shared
immutably.
yuja added a commit that referenced this issue Dec 31, 2024
I think the issue #5144 can be fixed cleanly if UserSettings object is
loaded/resolved per repo/workspace, not per CommandHelper.

This change makes it clear that UserSettings is supposed to be shared
immutably.
yuja added a commit to yuja/jj that referenced this issue Jan 5, 2025
yuja added a commit to yuja/jj that referenced this issue Jan 5, 2025
yuja added a commit to yuja/jj that referenced this issue Jan 5, 2025
yuja added a commit to yuja/jj that referenced this issue Jan 6, 2025
@yuja yuja closed this as completed in 6c14ccd Jan 6, 2025
@bnjmnt4n bnjmnt4n marked this as a duplicate of #5603 Feb 6, 2025
tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue Feb 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [martinvonz/jj](https://github.com/martinvonz/jj) | minor | `v0.25.0` -> `v0.26.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>martinvonz/jj (martinvonz/jj)</summary>

### [`v0.26.0`](https://github.com/jj-vcs/jj/releases/tag/v0.26.0)

[Compare Source](jj-vcs/jj@v0.25.0...v0.26.0)

##### About

jj is a Git-compatible version control system that is both simple and powerful. See the [installation instructions](https://jj-vcs.github.io/jj/v0.26.0/install-and-setup/) to get started.

##### Release highlights

-   Improved Git push/fetch compatibility by spawning an external `git` process.
    This can be enabled by the `git.subprocess=true` config knob, and will be the
    default in a future release.

-   `jj log` can now show cryptographic commit signatures. The output can be
    controlled by the `ui.show-cryptographic-signatures=true` config knob.

##### Breaking changes

-   `jj abandon` now deletes bookmarks pointing to the revisions to be abandoned.
    Use `--retain-bookmarks` to move bookmarks backwards. If deleted bookmarks
    were tracking remote bookmarks, the associated bookmarks (or branches) will be
    deleted from the remote on `jj git push --all`.
    [#&#8203;3505](jj-vcs/jj#3505)

-   `jj init --git` and `jj init --git-repo` have been removed. They were
    deprecated in early 2024. Use `jj git init` instead.

-   The following deprecated commands have been removed:
    -   `jj cat` is replaced by `jj file show`.
    -   `jj chmod` is replaced by `jj file chmod`.
    -   `jj files` is replaced by `jj file list`.

-   The deprecated `-l` short alias for `--limit` in `jj log`, `jj op log`
    and `jj obslog` has been removed. The `-n` short alias can be used instead.

-   The deprecated `--siblings` options for `jj split` has been removed.
    `jj split --parallel` can be used instead.

-   The deprecated `fix.tool-command` config option has been removed.

-   In colocated repos, the Git index now contains the changes from all parents
    of the working copy instead of just the first parent (`HEAD`). 2-sided
    conflicts from the merged parents are now added to the Git index as conflicts
    as well.

-   The following change introduced in 0.25.0 is reverted:
    -   `jj config list` now prints inline tables `{ key = value, .. }` literally.
        Inner items of inline tables are no longer merged across configuration
        files.

-   `jj resolve` will now attempt to resolve all conflicted files instead of
    resolving the first conflicted file. To resolve a single file, pass a file
    path to `jj resolve`.

-   `jj util mangen` is replaced with `jj util install-man-pages`, which can
    install man pages for all `jj` subcommands to a given path.

-   In `jj config list` template, `value` is now typed as `ConfigValue`, not as
    `String` serialized in TOML syntax.

-   `jj git remote add`/`set-url` now converts relative Git remote path to
    absolute path.

-   `jj log`/`op log` now applies `-n`/`--limit` *before* the items are reversed.
    Rationale: It's more useful to see the N most recent commits/operations, and
    is more performant. The old behavior can be achieved by `jj log .. | head`.
    [#&#8203;5403](jj-vcs/jj#5403)

-   Upgraded `scm-record` from v0.4.0 to v0.5.0. See release notes at
    <https://github.com/arxanas/scm-record/releases/tag/v0.5.0>.

-   The builtin pager is switched to
    [streampager](https://github.com/markbt/streampager/). It can handle large
    inputs better and can be configured.

-   Conflicts materialized in the working copy before `jj 0.19.0` may no longer
    be parsed correctly. If you are using version 0.18.0 or earlier, check out a
    non-conflicted commit before upgrading to prevent issues.

##### Deprecations

##### New features

-   `jj git {push,clone,fetch}` can now spawn an external `git` subprocess, via
    the `git.subprocess = true` config knob. This provides an alternative that,
    when turned on, fixes SSH bugs when interacting with Git remotes due to
    `libgit2`s limitations [#&#8203;4979](jj-vcs/jj#4979).

-   `jj describe` now accepts `--edit`.

-   `jj evolog` and `jj op log` now accept `--reversed`.

-   `jj restore` now supports `-i`/`--interactive` selection.

-   `jj file list` now supports templating.

-   There is a new `builtin_op_log_oneline` template alias you can pass to `jj op
    log -T` for a more compact output. You can use `format_operation_oneline` and
    `format_snapshot_operation_oneline` to customize parts of it.

-   New template function `config(name)` to access to configuration variable from
    template.

-   New template function `pad_centered()` to center content within a minimum
    width.

-   Templater now supports `list.filter(|x| ..)` method.

-   The `diff` commit template keyword now supports custom formatting via
    `diff.files()`. For example, `diff.files().map(|e| e.path().display())` prints
    changed file paths.

-   The `diff.stat()` template method now provides methods to get summary values.

-   `jj log` can now show cryptographic commit signatures. The output can be
    controlled by the `ui.show-cryptographic-signatures=true` config knob. The
    signature template can be customized using
    `format_detailed_cryptographic_signature(signature)` and
    `format_short_cryptographic_signature(signature)`.

-   New `git.sign-on-push` config option to automatically sign commits which are
    being pushed to a Git remote.

-   New `git.push-new-bookmarks` config option to push new bookmarks without
    `--allow-new`.

-   `jj status` now shows untracked files when they reside directly under a
    tracked directory. There's still an issue that files under untracked
    directories aren't listed. [#&#8203;5389](jj-vcs/jj#5389)

-   New `merge-tools.<TOOL>.diff-expected-exit-codes` config option to suppress
    warnings from tools exiting with non-zero exit codes.

-   New `fix.tools.TOOL.enabled` config option to enable/disable tools. This is
    useful for defining disabled tools in user configuration that can be enabled
    in individual repositories with one config setting.

-   Added `--into` flag to `jj restore`, similarly to `jj squash` and `jj
    absorb`. It is equivalent to `--to`, but `--into` is the recommended name.

-   Italic text is now supported. You can set e.g. `color.error = { fg = "red",
    italic = true }` in your config.

-   New `author_name`/`author_email`/`committer_name`/`committer_email(pattern)`
    revset functions to match either name or email field explicitly.

-   New `subject(pattern)` revset function that matches first line of commit
    descriptions.

-   Conditional configuration now supports `--when.commands` to change
    configuration based on subcommand.

-   The Jujutsu documentation site now publishes a schema for the official
    configuration file, which can be integrated into your editor for autocomplete,
    inline errors, and more.
    Please [see the documentation](/docs/config.md#json-schema-support) for more
    on this.

##### Fixed bugs

-   `jj git fetch` with multiple remotes will now fetch from all remotes before
    importing refs into the jj repo. This fixes a race condition where the
    treatment of a commit that is found in multiple fetch remotes depended on the
    order the remotes were specified.

-   Fixed diff selection by external tools with `jj split`/`commit -i FILESETS`.
    [#&#8203;5252](jj-vcs/jj#5252)

-   Conditional configuration now applies when initializing new repository.
    [#&#8203;5144](jj-vcs/jj#5144)

-   `[diff.<format>]` configuration now applies to `.diff().<format>()` commit
    template methods.

-   Conflicts at the end of files which don't end with a newline character are
    now materialized in a way that can be parsed correctly.
    [#&#8203;3968](jj-vcs/jj#3968)

-   Bookmark and remote names written by `jj git clone` to
    `revset-aliases.'trunk()'` are now escaped if necessary.
    [#&#8203;5359](jj-vcs/jj#5359)

##### Contributors

Thanks to the people who made this release happen!

-   Angel Ezquerra ([@&#8203;AngelEzquerra](https://github.com/AngelEzquerra))
-   Antoine Martin ([@&#8203;alarsyo](https://github.com/alarsyo))
-   Anton Bulakh ([@&#8203;necauqua](https://github.com/necauqua))
-   Austin Seipp ([@&#8203;thoughtpolice](https://github.com/thoughtpolice))
-   Baltasar Dinis ([@&#8203;bsdinis](https://github.com/bsdinis))
-   Benjamin Tan ([@&#8203;bnjmnt4n](https://github.com/bnjmnt4n))
-   blinry ([@&#8203;blinry](https://github.com/blinry))
-   Bryce Berger ([@&#8203;bryceberger](https://github.com/bryceberger))
-   Charlie-83 ([@&#8203;Charlie-83](https://github.com/Charlie-83))
-   Christian Stoitner ([@&#8203;cstoitner](https://github.com/cstoitner))
-   Evan Martin ([@&#8203;evmar](https://github.com/evmar))
-   George Christou ([@&#8203;gechr](https://github.com/gechr))
-   Ilya Grigoriev ([@&#8203;ilyagr](https://github.com/ilyagr))
-   Jakob Hellermann ([@&#8203;jakobhellermann](https://github.com/jakobhellermann))
-   JDSeiler ([@&#8203;JDSeiler](https://github.com/JDSeiler))
-   Jonathan Frere ([@&#8203;MrJohz](https://github.com/MrJohz))
-   Jonathan Gilchrist ([@&#8203;jgilchrist](https://github.com/jgilchrist))
-   Josh Steadmon ([@&#8203;steadmon](https://github.com/steadmon))
-   Martin von Zweigbergk ([@&#8203;martinvonz](https://github.com/martinvonz))
-   Matt Kulukundis ([@&#8203;fowles](https://github.com/fowles))
-   Ollivier Robert ([@&#8203;keltia](https://github.com/keltia))
-   Philip Metzger ([@&#8203;PhilipMetzger](https://github.com/PhilipMetzger))
-   Philipp Albrecht ([@&#8203;pylbrecht](https://github.com/pylbrecht))
-   Robert Jackson ([@&#8203;rwjblue](https://github.com/rwjblue))
-   Samuel Tardieu ([@&#8203;samueltardieu](https://github.com/samueltardieu))
-   Scott Taylor ([@&#8203;scott2000](https://github.com/scott2000))
-   Stephen Jennings ([@&#8203;jennings](https://github.com/jennings))
-   Valentin Gatien-Baron ([@&#8203;v-gb](https://github.com/v-gb))
-   Vincent Ging Ho Yim ([@&#8203;cenviity](https://github.com/cenviity))
-   Waleed Khan ([@&#8203;arxanas](https://github.com/arxanas))
-   Yuya Nishihara ([@&#8203;yuja](https://github.com/yuja))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjEuNiIsInVwZGF0ZWRJblZlciI6IjM5LjE2MS42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 9, 2025
## [0.26.0] - 2025-02-05

### Release highlights

* Improved Git push/fetch compatibility by spawning an external `git` process.
  This can be enabled by the `git.subprocess=true` config knob, and will be the
  default in a future release.

* `jj log` can now show cryptographic commit signatures. The output can be
  controlled by the `ui.show-cryptographic-signatures=true` config knob.

### Breaking changes

* `jj abandon` now deletes bookmarks pointing to the revisions to be abandoned.
  Use `--retain-bookmarks` to move bookmarks backwards. If deleted bookmarks
  were tracking remote bookmarks, the associated bookmarks (or branches) will be
  deleted from the remote on `jj git push --all`.
  [#3505](jj-vcs/jj#3505)

* `jj init --git` and `jj init --git-repo` have been removed. They were
  deprecated in early 2024. Use `jj git init` instead.

* The following deprecated commands have been removed:
  - `jj cat` is replaced by `jj file show`.
  - `jj chmod` is replaced by `jj file chmod`.
  - `jj files` is replaced by `jj file list`.

* The deprecated `-l` short alias for `--limit` in `jj log`, `jj op log`
  and `jj obslog` has been removed. The `-n` short alias can be used instead.

* The deprecated `--siblings` options for `jj split` has been removed.
  `jj split --parallel` can be used instead.

* The deprecated `fix.tool-command` config option has been removed.

* In colocated repos, the Git index now contains the changes from all parents
  of the working copy instead of just the first parent (`HEAD`). 2-sided
  conflicts from the merged parents are now added to the Git index as conflicts
  as well.

* The following change introduced in 0.25.0 is reverted:
  - `jj config list` now prints inline tables `{ key = value, .. }` literally.
    Inner items of inline tables are no longer merged across configuration
    files.

* `jj resolve` will now attempt to resolve all conflicted files instead of
  resolving the first conflicted file. To resolve a single file, pass a file
  path to `jj resolve`.

* `jj util mangen` is replaced with `jj util install-man-pages`, which can
  install man pages for all `jj` subcommands to a given path.

* In `jj config list` template, `value` is now typed as `ConfigValue`, not as
  `String` serialized in TOML syntax.

* `jj git remote add`/`set-url` now converts relative Git remote path to
  absolute path.

* `jj log`/`op log` now applies `-n`/`--limit` *before* the items are reversed.
  Rationale: It's more useful to see the N most recent commits/operations, and
  is more performant. The old behavior can be achieved by `jj log .. | head`.
  [#5403](jj-vcs/jj#5403)

* Upgraded `scm-record` from v0.4.0 to v0.5.0. See release notes at
  <https://github.com/arxanas/scm-record/releases/tag/v0.5.0>.

* The builtin pager is switched to
  [streampager](https://github.com/markbt/streampager/). It can handle large
  inputs better and can be configured.

* Conflicts materialized in the working copy before `jj 0.19.0` may no longer
  be parsed correctly. If you are using version 0.18.0 or earlier, check out a
  non-conflicted commit before upgrading to prevent issues.

### Deprecations

### New features

* `jj git {push,clone,fetch}` can now spawn an external `git` subprocess, via
   the `git.subprocess = true` config knob. This provides an alternative that,
   when turned on, fixes SSH bugs when interacting with Git remotes due to
   `libgit2`s limitations [#4979](jj-vcs/jj#4979).

* `jj describe` now accepts `--edit`.

* `jj evolog` and `jj op log` now accept `--reversed`.

* `jj restore` now supports `-i`/`--interactive` selection.

* `jj file list` now supports templating.

* There is a new `builtin_op_log_oneline` template alias you can pass to `jj op
  log -T` for a more compact output. You can use `format_operation_oneline` and
  `format_snapshot_operation_oneline` to customize parts of it.

* New template function `config(name)` to access to configuration variable from
  template.

* New template function `pad_centered()` to center content within a minimum
  width.

* Templater now supports `list.filter(|x| ..)` method.

* The `diff` commit template keyword now supports custom formatting via
  `diff.files()`. For example, `diff.files().map(|e| e.path().display())` prints
  changed file paths.

* The `diff.stat()` template method now provides methods to get summary values.

* `jj log` can now show cryptographic commit signatures. The output can be
  controlled by the `ui.show-cryptographic-signatures=true` config knob. The
  signature template can be customized using
  `format_detailed_cryptographic_signature(signature)` and
  `format_short_cryptographic_signature(signature)`.

* New `git.sign-on-push` config option to automatically sign commits which are
  being pushed to a Git remote.

* New `git.push-new-bookmarks` config option to push new bookmarks without
  `--allow-new`.

* `jj status` now shows untracked files when they reside directly under a
  tracked directory. There's still an issue that files under untracked
  directories aren't listed. [#5389](jj-vcs/jj#5389)

* New `merge-tools.<TOOL>.diff-expected-exit-codes` config option to suppress
  warnings from tools exiting with non-zero exit codes.

* New `fix.tools.TOOL.enabled` config option to enable/disable tools. This is
  useful for defining disabled tools in user configuration that can be enabled
  in individual repositories with one config setting.

* Added `--into` flag to `jj restore`, similarly to `jj squash` and `jj
  absorb`. It is equivalent to `--to`, but `--into` is the recommended name.

* Italic text is now supported. You can set e.g. `color.error = { fg = "red",
  italic = true }` in your config.

* New `author_name`/`author_email`/`committer_name`/`committer_email(pattern)`
  revset functions to match either name or email field explicitly.

* New `subject(pattern)` revset function that matches first line of commit
  descriptions.

* Conditional configuration now supports `--when.commands` to change
  configuration based on subcommand.

* The Jujutsu documentation site now publishes a schema for the official
  configuration file, which can be integrated into your editor for autocomplete,
  inline errors, and more.
  Please [see the documentation](/docs/config.md#json-schema-support) for more
  on this.

### Fixed bugs

* `jj git fetch` with multiple remotes will now fetch from all remotes before
  importing refs into the jj repo. This fixes a race condition where the
  treatment of a commit that is found in multiple fetch remotes depended on the
  order the remotes were specified.

* Fixed diff selection by external tools with `jj split`/`commit -i FILESETS`.
  [#5252](jj-vcs/jj#5252)

* Conditional configuration now applies when initializing new repository.
  [#5144](jj-vcs/jj#5144)

* `[diff.<format>]` configuration now applies to `.diff().<format>()` commit
  template methods.

* Conflicts at the end of files which don't end with a newline character are
  now materialized in a way that can be parsed correctly.
  [#3968](jj-vcs/jj#3968)

* Bookmark and remote names written by `jj git clone` to
  `revset-aliases.'trunk()'` are now escaped if necessary.
  [#5359](jj-vcs/jj#5359)
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