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

"exact" modifier does not seem to work (at least when used in a revset within a describe() expression) #5227

Open
AngelEzquerra opened this issue Jan 1, 2025 · 8 comments
Labels
documentation Improvements or additions to documentation

Comments

@AngelEzquerra
Copy link

Description

Steps to Reproduce the Problem

  1. jj new -m "my_unique_test_description"
  2. jj log -r "describe(exact:"my_unique_test_description")
  3. Returns no revisions

Expected Behavior

It should return the revisions exactly matching "my_unique_test_description" (normally it should just be one)

Actual Behavior

No revisions are matched

Specifications

  • Platform: Windows
  • Version: 0.24
@joyously
Copy link

joyously commented Jan 1, 2025

Does exact mean that the entire content matches exactly or that an exact match is contained in the content?

@scott2000
Copy link
Contributor

I've run into this before. I think it's because technically, the description ends with a newline if it's non-empty. So description(exact:"") matches empty description, and description(exact:"my_unique_test_description\n") matches "my_unique_test_description".

@yuja
Copy link
Contributor

yuja commented Jan 2, 2025

I've run into this before. I think it's because technically, the description ends with a newline if it's non-empty. So description(exact:"") matches empty description, and description(exact:"my_unique_test_description\n") matches "my_unique_test_description".

That's probably it. I think the revset doc can be updated.

@yuja yuja added the documentation Improvements or additions to documentation label Jan 2, 2025
@ilyagr
Copy link
Contributor

ilyagr commented Jan 2, 2025

Another confusing thing is that description(exact:'my_unique_test_description\n') doesn't work. A literal newline like

jj log -r 'description(exact:\'test
\')'

or

jj log -r "description(exact:'test
')"

does work (in fish at least).

Perhaps description should match both with and without a trailing \n, since jj already adds the \n automatically? I suppose we could have strict_description that acts differently. This isn't perfect, but perhaps it's better than the status quo. Or can we think of something even better?

I suppose there could be a version of exact that trims whitespace.

@yuja
Copy link
Contributor

yuja commented Jan 2, 2025

Well, '' means raw string (i.e disable escapes).

I don't think exact match on description is useful (except for exact:"".) It's probably better to suggest regex for line-based matching than adding special case for description().

@emilazy
Copy link
Contributor

emilazy commented Jan 2, 2025

What may be useful is having a query (and template?) for only the subject line of a description, which can be fairly useful to search exactly (e.g. commit subjects mentioned in emails), and could naturally strip the trailing newline.

@AngelEzquerra
Copy link
Author

I don't think exact match on description is useful (except for exact:"".) It's probably better to suggest regex for line-based matching than adding special case for description()

I think it could be quite useful if you use certain specific descriptions for certain revisions (e.g. CI/CD, etc).
In any case, the current behavior is very surprising. If you set the description to "test" by using jj describe -m "test" one would expect to find that specific revision by doing `jj log -r "description(exact:'test')", wouldn't it? The fact that jj adds a trailing '\n' should not leak to the UX, IMHO.

What may be useful is having a query (and template?) for only the subject line of a description, which can be fairly useful to search exactly (e.g. commit subjects mentioned in emails), and could naturally strip the trailing newline.

FWIW mercurial does have a "matching" function that can take "summary" as its "field" argument, which looks for the first line of each commit message.

@martinvonz
Copy link
Member

FWIW, jj describe -m has added since PR #936. git commit -m seems to do the same thing but hg commit -m does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

7 participants