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

jj handles renames of the remote trunk poorly #4616

Closed
tonyfinn opened this issue Oct 9, 2024 · 1 comment
Closed

jj handles renames of the remote trunk poorly #4616

tonyfinn opened this issue Oct 9, 2024 · 1 comment

Comments

@tonyfinn
Copy link

tonyfinn commented Oct 9, 2024

Description

Steps to Reproduce the Problem

  1. Create a git repo with a master branch
  2. Push the git repo to a remote
  3. Run jj git init --colocate in this copy
  4. Run jj branch track master@origin in this copy
  5. From a different checkout of the git repo (or a different device/user), rename the branch master to main, push the new main branch to the remote, delete master on the remote
  6. Run jj git fetch on the first checkout
  7. Attempt to switch to the new main branch with jj new main

Expected Behavior

Ideally: You're able to continue developing the on local repo with the new name for the trunk branch.

At a minimum: Warn the target that the trunk() alias refers to has been deleted and you need to update the trunk() alias.

Actual Behavior

Output from jj git fetch in step 6:

> jj git fetch
bookmark: main@origin   [updated] tracked
bookmark: master@origin [deleted] untracked

Most jj commands fail after this jj git fetch.

> jj new main
Config error: Invalid `revset-aliases.immutable_heads()`
Caused by: Revision "master@origin" doesn't exist
> jj log
Error: Revision "master@origin" doesn't exist
> jj log -r main@origin
Error: Failed to parse template: In alias "builtin_log_node"
Caused by:
1:  --> 1:1
  |
1 | builtin_log_node
  | ^--------------^
  |
  = In alias "builtin_log_node"
2:  --> 6:10
  |
6 |       if(immutable, "immutable"),
  |          ^-------^
  |
  = Failed to evaluate revset
3: Revision "master@origin" doesn't exist
Hint: Did you mean "main@origin"
> jj bookmark untrack master@origin
Error: No such remote bookmark: master@origin

It's not clear how to recover from this situation other than rm -R .jj && jj git init --colocate

Specifications

  • Platform: NixOS
  • Version: 0.22.0
@yuja
Copy link
Collaborator

yuja commented Oct 10, 2024

You'll need to update trunk() saved in .jj/repo/config.toml, which was probably generated by jj git init --colocate.

I agree the error message isn't actionable.

yuja added a commit to yuja/jj that referenced this issue Oct 10, 2024
This patch replaces all call sites with present(trunk()), and adds an explicit
check for unresolvable trunk(). If we add coalesce() expression, maybe it can
be rewritten to coalesce(present(trunk()), builtin_trunk()).

Fixes martinvonz#4616
yuja added a commit to yuja/jj that referenced this issue Oct 11, 2024
This patch replaces all call sites with present(trunk()), and adds an explicit
check for unresolvable trunk(). If we add coalesce() expression, maybe it can
be rewritten to coalesce(present(trunk()), builtin_trunk()).

Fixes martinvonz#4616
@yuja yuja closed this as completed in c656878 Oct 11, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 10, 2024
## [0.23.0] - 2024-11-06

### Security fixes

* Fixed path traversal by cloning/checking out crafted Git repository containing
  `..`, `.jj`, `.git` paths.
  ([GHSA-88h5-6w7m-5w56](https://github.com/martinvonz/jj/security/advisories/GHSA-88h5-6w7m-5w56);CVE-2024-51990)

### Breaking changes

* Revset function names can no longer start with a number.

* Evaluation error of `revsets.short-prefixes` configuration is now reported.

* The `HEAD@git` symbol no longer resolves to the Git HEAD revision. Use
  `git_head()` or `@-` revset expression instead. The `git_head` template
  keyword now returns a boolean.

* Help command doesn't work recursively anymore, i.e. `jj workspace help root`
  doesn't work anymore.

* The color label `op_log` from the `[colors]` config section now **only**
  applies to the op log and not to the other places operations are displayed. In
  almost all cases, if you configured `op_log` before, you should use the new
  `operation` label instead.

* Default operation log template now shows end times of operations instead of
  start times.

### Deprecations

* `git.auto-local-bookmark` replaces `git.auto-local-branch`. The latter remains
  supported for now (at lower precedence than the former).

### New features

* Added diff options to ignore whitespace when comparing lines. Whitespace
  changes are still highlighted.

* New command `jj simplify-parents` will remove redundant parent edges.

* `jj squash` now supports `-f/-t` shorthands for `--from/--[in]to`.

* Initial support for shallow Git repositories has been implemented. However,
  deepening the history of a shallow repository is not yet supported.

* `jj git clone` now accepts a `--depth <DEPTH>` option, which
  allows to clone the repository with a given depth.

* New command `jj file annotate` that annotates files line by line. This is similar
  in functionality to `git blame`. Invoke the command with `jj file annotate <file_path>`.
  The output can be customized via the `templates.annotate_commit_summary`
  config variable.

* `jj bookmark list` gained a `--remote REMOTE` option to display bookmarks
   belonging to a remote. This option can be combined with `--tracked` or
   `--conflicted`.

* New command `jj config unset` that unsets config values. For example,
  `jj config unset --user user.name`.

* `jj help` now has the flag `--keyword` (shorthand `-k`), which can give help
  for some keywords (e.g. `jj help -k revsets`). To see a list of the available
  keywords you can do `jj help --help`.

* New `at_operation(op, expr)` revset can be used in order to query revisions
  based on historical state.

* String literals in filesets, revsets and templates now support hex bytes
  (with `\e` as escape / shorthand for `\x1b`).

* New `coalesce(revsets...)` revset which returns commits in the first revset
  in the `revsets` list that does not evaluate to `none()`.

* New template function `raw_escape_sequence(...)` preserves escape sequences.

* Timestamp objects in templates now have `after(date) -> Boolean` and
  `before(date) -> Boolean` methods for comparing timestamps to other dates.

* New template functions `pad_start()`, `pad_end()`, `truncate_start()`, and
  `truncate_end()` are added.

* Add a new template alias `bultin_log_compact_full_description()`.

* Added the config settings `diff.color-words.context` and `diff.git.context` to
  control the default number of lines of context shown.

### Fixed bugs

* Error on `trunk()` revset resolution is now handled gracefully.
  [#4616](martinvonz/jj#4616)

* Updated the built-in diff editor `scm-record` to version
  [0.4.0](https://github.com/arxanas/scm-record/releases/tag/v0.4.0), which
  includes multiple fixes.
tmeijn pushed a commit to tmeijn/dotfiles that referenced this issue Nov 22, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [martinvonz/jj](https://github.com/martinvonz/jj) | minor | `v0.22.0` -> `v0.23.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.23.0`](https://github.com/martinvonz/jj/releases/tag/v0.23.0)

[Compare Source](martinvonz/jj@v0.22.0...v0.23.0)

##### Security fixes

-   Fixed path traversal by cloning/checking out crafted Git repository containing
    `..`, `.jj`, `.git` paths. ([GHSA-88h5-6w7m-5w56](GHSA-88h5-6w7m-5w56); CVE-2024-51990)

##### Breaking changes

-   Revset function names can no longer start with a number.

-   Evaluation error of `revsets.short-prefixes` configuration is now reported.

-   The `HEAD@git` symbol no longer resolves to the Git HEAD revision. Use
    `git_head()` or `@-` revset expression instead. The `git_head` template
    keyword now returns a boolean.

-   Help command doesn't work recursively anymore, i.e. `jj workspace help root`
    doesn't work anymore.

-   The color label `op_log` from the `[colors]` config section now **only**
    applies to the op log and not to the other places operations are displayed. In
    almost all cases, if you configured `op_log` before, you should use the new
    `operation` label instead.

-   Default operation log template now shows end times of operations instead of
    start times.

##### Deprecations

-   `git.auto-local-bookmark` replaces `git.auto-local-branch`. The latter remains
    supported for now (at lower precedence than the former).

##### New features

-   Added diff options to ignore whitespace when comparing lines. Whitespace
    changes are still highlighted.

-   New command `jj simplify-parents` will remove redundant parent edges.

-   `jj squash` now supports `-f/-t` shorthands for `--from/--[in]to`.

-   Initial support for shallow Git repositories has been implemented. However,
    deepening the history of a shallow repository is not yet supported.

-   `jj git clone` now accepts a `--depth <DEPTH>` option, which
    allows to clone the repository with a given depth.

-   New command `jj file annotate` that annotates files line by line. This is similar
    in functionality to `git blame`. Invoke the command with `jj file annotate <file_path>`.
    The output can be customized via the `templates.annotate_commit_summary`
    config variable.

-   `jj bookmark list` gained a `--remote REMOTE` option to display bookmarks
    belonging to a remote. This option can be combined with `--tracked` or
    `--conflicted`.

-   New command `jj config unset` that unsets config values. For example,
    `jj config unset --user user.name`.

-   `jj help` now has the flag `--keyword` (shorthand `-k`), which can give help
    for some keywords (e.g. `jj help -k revsets`). To see a list of the available
    keywords you can do `jj help --help`.

-   New `at_operation(op, expr)` revset can be used in order to query revisions
    based on historical state.

-   String literals in filesets, revsets and templates now support hex bytes
    (with `\e` as escape / shorthand for `\x1b`).

-   New `coalesce(revsets...)` revset which returns commits in the first revset
    in the `revsets` list that does not evaluate to `none()`.

-   New template function `raw_escape_sequence(...)` preserves escape sequences.

-   Timestamp objects in templates now have `after(date) -> Boolean` and
    `before(date) -> Boolean` methods for comparing timestamps to other dates.

-   New template functions `pad_start()`, `pad_end()`, `truncate_start()`, and
    `truncate_end()` are added.

-   Add a new template alias `builtin_log_compact_full_description()`.

-   Added the config settings `diff.color-words.context` and `diff.git.context` to
    control the default number of lines of context shown.

##### Fixed bugs

-   Error on `trunk()` revset resolution is now handled gracefully.
    [#&#8203;4616](martinvonz/jj#4616)

-   Updated the built-in diff editor `scm-record` to version
    [0.4.0](https://github.com/arxanas/scm-record/releases/tag/v0.4.0), which
    includes multiple fixes.

##### Contributors

Thanks to the people who made this release happen!

-   Alec Snyder ([@&#8203;allonsy](https://github.com/allonsy))
-   Arthur Grillo (Grillo-0)
-   Austin Seipp ([@&#8203;thoughtpolice](https://github.com/thoughtpolice))
-   Benjamin Tan ([@&#8203;bnjmnt4n](https://github.com/bnjmnt4n))
-   Dave Townsend ([@&#8203;Mossop](https://github.com/Mossop))
-   Daniel Ploch ([@&#8203;torquestomp](https://github.com/torquestomp))
-   Emily ([@&#8203;neongreen](https://github.com/neongreen))
-   Essien Ita Essien ([@&#8203;essiene](https://github.com/essiene))
-   Fedor Sheremetyev ([@&#8203;sheremetyev](https://github.com/sheremetyev))
-   Ilya Grigoriev ([@&#8203;ilyagr](https://github.com/ilyagr))
-   Jakub Okoński ([@&#8203;farnoy](https://github.com/farnoy))
-   Jcparkyn ([@&#8203;Jcparkyn](https://github.com/Jcparkyn))
-   Joaquín Triñanes ([@&#8203;JoaquinTrinanes](https://github.com/JoaquinTrinanes))
-   Lukas Wirth ([@&#8203;Veykril](https://github.com/Veykril))
-   Marco Neumann ([@&#8203;crepererum](https://github.com/crepererum))
-   Martin von Zweigbergk ([@&#8203;martinvonz](https://github.com/martinvonz))
-   Matt Stark ([@&#8203;matts1](https://github.com/matts1))
-   Philip Metzger ([@&#8203;PhilipMetzger](https://github.com/PhilipMetzger))
-   Philipp Albrecht ([@&#8203;pylbrecht](https://github.com/pylbrecht))
-   Remo Senekowitsch ([@&#8203;senekor](https://github.com/senekor))
-   Richard Macklin ([@&#8203;rmacklin](https://github.com/rmacklin))
-   Robin Stocker ([@&#8203;robinst](https://github.com/robinst))
-   Samuel Tardieu ([@&#8203;samueltardieu](https://github.com/samueltardieu))
-   Sora ([@&#8203;SoraTenshi](https://github.com/SoraTenshi))
-   Stephen Jennings ([@&#8203;jennings](https://github.com/jennings))
-   Theodore Ehrenborg ([@&#8203;TheodoreEhrenborg](https://github.com/TheodoreEhrenborg))
-   Vamsi Avula ([@&#8203;avamsi](https://github.com/avamsi))
-   Vincent Ging Ho Yim ([@&#8203;cenviity](https://github.com/cenviity))
-   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:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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