Skip to content

Conversation

@glehmann
Copy link
Contributor

@glehmann glehmann commented Oct 8, 2025

To be consistent with jj log -G.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@glehmann glehmann requested a review from a team as a code owner October 8, 2025 21:13
@glehmann glehmann force-pushed the gln/log-short-graph-vkpy branch from 4c26edc to 3a5721c Compare October 8, 2025 21:38
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.

Feel like adding it to jj evolog too?

@martinvonz
Copy link
Member

... and to jj op diff/log/show too? Try grepping for no_graph

@glehmann glehmann force-pushed the gln/log-short-graph-vkpy branch from 3a5721c to 6806dfc Compare October 9, 2025 07:11
@glehmann glehmann changed the title op log: -G as short version of --no-graph cli: -G as short version of --no-graph Oct 9, 2025
@9999years
Copy link

9999years commented Oct 9, 2025

I think it would be very valuable to have jj log -G mean the same thing as git log -G (performing a grep on the diffs), but I'm open to feedback.

Do you use -G often? I don't think I've ever used it personally, but if it's a cornerstone of some workflows then it's a trickier proposition.

See:

@ilyagr
Copy link
Contributor

ilyagr commented Oct 9, 2025

I haven't realized -G conflicts with Git's -G, thanks for bringing that up! Still, IMO it's OK to use it for another purpose in jj. I'm hoping confusing the two will lead to an immediate error, since Git's -G takes a parameter (the string to search for) and ours does not.

This goes together with my understanding that git log's choice of -G and -S for searching inside the commit diffs is somewhat arbitrary. I guess it's something like grep and search, but I find it hard to remember which is which; if anything the --pickaxe-regex option is more memorable to me.

In jj, revset language expressions seem more appropriate for this functionality. Even if we add CLI flags, they'd probably have longer names.

@9999years
Copy link

I guess it's something like grep and search, but I find it hard to remember which is which

Agreed. But I think having this functionality available from short options is important; when running a number of searches in sequence to find a specific commit, it's pretty annoying to go from jj log -r '::@ & diff_contains(regex:"foo")' to jj log -r '::@ & diff_contains(regex:"bar")' due to the shell escaping, nested quotes, and parenthesis required for the revset syntax (compare to git log -G foo and git log -G bar). I really like the revset language, but it's pretty cumbersome for tasks like this.

I do think this functionality is important enough to warrant a short flag for it, and I think that it would be slightly nicer, everything else equal, if the short flag were the same between git log and jj log. But I'm happy to learn a different option name, so I don't want to die on this hill.

Do you end up using -G for --no-graph frequently? I'm very curious about this.

@ilyagr
Copy link
Contributor

ilyagr commented Oct 9, 2025

Do you end up using -G for --no-graph frequently? I'm very curious about this.

It's only just been added in #7639. (So, now is a good time to discuss whether to keep it!)

I expect to use it mainly when doing some automated processing on commits, e.g. jj log -r :: -G -T_ | wc or jj log -r :: -G -Tcommit_id | fzf.

You make some good points. I'm currently a bit under the weather, so I don't promise to think much more deeply right now about what the best compromise would be, but hopefully others are thinking about it as well.

@glehmann
Copy link
Contributor Author

It's confusing that git only provides a short option name. What would be a good (long) name for these options, without looking at what git already did?

We could also say we go for another short name for --no-graph, like -g, but that would be a bit wasted if we go with something else for the search options :)

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.

I don't think it's worth testing the short option. Since it relies on clap, there's no logic in our code that can go wrong. It seems very unlikely to regress. I don't think it's worth spending CPU testing it all the time. I don't know if others agree.

(I think the test you added for --no-graph in test_operations.rs is useful, however.)

@glehmann
Copy link
Contributor Author

I don't think it's worth testing the short option. Since it relies on clap, there's no logic in our code that can go wrong. It seems very unlikely to regress. I don't think it's worth spending CPU testing it all the time. I don't know if others agree.

That and the cli/tests/[email protected] that lists the short options, so we would see if a short option is removed or modified by mistake.
I'll remove the tests.

@glehmann glehmann force-pushed the gln/log-short-graph-vkpy branch from 6806dfc to 245e053 Compare October 11, 2025 12:34
@glehmann
Copy link
Contributor Author

I'll remove the tests.

Done!

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

@glehmann
Copy link
Contributor Author

@ilyagr @9999years Do you want to continue the discussion on the flag name in this PR?

@joyously
Copy link

Are there any proposed standards for short flags or for --no- flags? Maybe we should make a standard and follow it.

@glehmann glehmann force-pushed the gln/log-short-graph-vkpy branch from 245e053 to 32f2ebc Compare October 12, 2025 20:58
@ilyagr
Copy link
Contributor

ilyagr commented Oct 13, 2025

TLDR: I'm personally quite happy with this as is. I'm not 100% sure we have a full consensus on this. @9999years, how do you feel now (and in light of my thoughts below)?

Do you want to continue the discussion on the flag name in this PR?

I am personally happy with this PR as is. In my mind, -G is a good name for --no-graph, and not a great name for something related to diff_contains.

One possibility for the latter would be to have flags like --modifies-text <string-pattern>, --adds-text <string-pattern>, --removes-text. For shorter versions, we could have --text for the first one, --adds for the second ones, --removes for the last one.

Even if that's not great, I'm hoping we can come up with something better than -G and -S. Or we could use -S as short for --search-diffs.

Are there any proposed standards for short flags or for --no- flags?

In my mind, minus-capital-letter is a decent standard for this. We also often use these to suppress warnings or errors (e.g. -B for --allow-backwards, -N for --allow-new).

However, we don't currently do this for any other --no- flags specifically, so this PR and #7639 actively create/strengthen such a convention.

@9999years
Copy link

It's confusing that git only provides a short option name. What would be a good (long) name for these options, without looking at what git already did?

Agreed. I suspect they had --grep for matching on the description already and just ... punted? I find -G easy to remember by analogy to grep, but I'm not sure how universal that is. (I can never remember -S for this reason.)

I would propose --grep, except it would do something different than what git does with the same option, which is not ideal (and different in a way that a user might not notice at first).

Perhaps simply --diff-contains, to match the revset function. But I'm not sure what I would want the short option to be. -S for "search"? -C for "contains"? I'm of course partial to -G for "grep" — all else equal, it's nice to respect the muscle memory of Git users.

@9999years
Copy link

(As an aside, it's a bit odd to have diff_contains but not e.g. description_contains.)

@9999years
Copy link

One possibility for the latter would be to have flags like --modifies-text <string-pattern>, --adds-text <string-pattern>, --removes-text. For shorter versions, we could have --text for the first one, --adds for the second ones, --removes for the last one.

I think we should make it explicit that these operate on the diff and not the description, e.g. --modifies-diff. Although I'm not sure what you would do for -G; --adds-or-removes-diff and --changes-occurrences-diff are both extremely cumbersome!

It's a tricky design space — I really do think that the revset functions are "the right way" to do this, but the quoting they introduce makes for poor ergonomics on the command-line. But then expressing all the options we want on the command-line introduces a combinatorial explosion of search subjects and modes.

@9999years
Copy link

I've also opened an issue (rather than the discussion I opened previously) for this functionality:

@joyously
Copy link

Sort of related: FR: --diff-filter equivalent in jj diff
maybe a mixture for the search?

@glehmann glehmann added this pull request to the merge queue Oct 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 15, 2025
@glehmann glehmann force-pushed the gln/log-short-graph-vkpy branch from 32f2ebc to 041e6fa Compare October 15, 2025 17:09
@glehmann glehmann added this pull request to the merge queue Oct 15, 2025
Merged via the queue into jj-vcs:main with commit 4be2aad Oct 15, 2025
29 checks passed
@glehmann glehmann deleted the gln/log-short-graph-vkpy branch October 15, 2025 17:38
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.

5 participants