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 config list: escape keys #3725

Merged
merged 1 commit into from
May 21, 2024
Merged

jj config list: escape keys #3725

merged 1 commit into from
May 21, 2024

Conversation

ilyagr
Copy link
Collaborator

@ilyagr ilyagr commented May 21, 2024

Fixes #1322. There may be more places where keys need escaping, I'm not completely sure.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have added tests to cover my changes

Fixes jj-vcs#1322. There may be more places where keys need escaping, I'm not
completely sure.
@ilyagr ilyagr marked this pull request as ready for review May 21, 2024 05:07
@ilyagr
Copy link
Collaborator Author

ilyagr commented May 21, 2024

Copying from Discord, the values are currently escaped in https://github.com/martinvonz/jj/blob/1f7c4ec60ab4c430ea46c141d8f46f144cfbec18/cli/src/cli_util.rs#L2132-L2150. I'm not sure at the moment whether that's 100% correct or whether it should also use toml_edit instead.

Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

PS. I'm also not sure about the value escaping. It seems to rely on TOML and Rust's debug formatting to be the same. I haven't checked if that's correct. We can fix that separately anyway.

@ilyagr
Copy link
Collaborator Author

ilyagr commented May 21, 2024

There's also the pathological case of a value like [{"bad key"=1, v="fred"}, 2].

But, I guess, we can indeed leave it for later.

@ilyagr ilyagr merged commit 8400707 into jj-vcs:main May 21, 2024
16 checks passed
@ilyagr ilyagr deleted the tomlkeys branch May 21, 2024 05:39
ilyagr added a commit to ilyagr/jj that referenced this pull request May 21, 2024
ilyagr added a commit to ilyagr/jj that referenced this pull request May 21, 2024
ilyagr added a commit to ilyagr/jj that referenced this pull request May 21, 2024
Follows up on jj-vcs#3725

Apart from the bugfix, this also makes `jj config list` output

```
template-aliases.builtin_log_node="""
coalesce(
  if(!self, label(\"elided\", \"~\")),
  label(
    separate(\" \",
      if(current_working_copy, \"working_copy\"),
      if(immutable, \"immutable\"),
      if(conflict, \"conflict\"),
    ),
    coalesce(
      if(current_working_copy, \"@\"),
      if(immutable, \"◆\"),
      if(conflict, \"×\"),
      \"○\",
    )
  )
)
"""
```

instead of

```
template-aliases.builtin_log_node="coalesce(\n  if(!self, label(\"elided\", \"~\")),\n  label(\n    separate(\" \",\n      if(current_working_copy, \"working_copy\"),\n      if(immutable, \"immutable\"),\n      if(conflict, \"conflict\"),\n    ),\n    coalesce(\n      if(current_working_copy, \"@\"),\n      if(immutable, \"◆\"),\n      if(conflict, \"×\"),\n      \"○\",\n    )\n  )\n)\n"
```.

`toml_edit` also seems to use single-quoted strings sometimes.
ilyagr added a commit to ilyagr/jj that referenced this pull request May 21, 2024
Follows up on jj-vcs#3725

Apart from the bugfix, this also makes `jj config list` output

```
template-aliases.builtin_log_node="""
coalesce(
  if(!self, label(\"elided\", \"~\")),
  label(
    separate(\" \",
      if(current_working_copy, \"working_copy\"),
      if(immutable, \"immutable\"),
      if(conflict, \"conflict\"),
    ),
    coalesce(
      if(current_working_copy, \"@\"),
      if(immutable, \"◆\"),
      if(conflict, \"×\"),
      \"○\",
    )
  )
)
"""
```

instead of

```
template-aliases.builtin_log_node="coalesce(\n  if(!self, label(\"elided\", \"~\")),\n  label(\n    separate(\" \",\n      if(current_working_copy, \"working_copy\"),\n      if(immutable, \"immutable\"),\n      if(conflict, \"conflict\"),\n    ),\n    coalesce(\n      if(current_working_copy, \"@\"),\n      if(immutable, \"◆\"),\n      if(conflict, \"×\"),\n      \"○\",\n    )\n  )\n)\n"
```.

`toml_edit` also seems to use single-quoted strings sometimes.
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.

jj config list does not escape keys enough to produce valid TOML
3 participants