ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

9 commits

Author SHA1 Message Date
Martin von Zweigbergk
7f9a0a2820 cleanup: let new Clippy move variables into format strings
I ran an upgraded Clippy on the codebase. All the changes seem to be
about using variables directly in format strings instead of passing
them as separate arguments.
2022-12-14 21:30:58 -08:00
Yuya Nishihara
cec4d6c214 cli: allow multiple diff outputs
"jj log -p --summary" now shows summary and color-words diff, like
"hg log -p --stat".

Handling of "-p" is tricky. I first considered "-p" would turn on the default
diff output, but I found it would be confusing if "jj log -p --git" showed
both color-words and git diffs. So the default format is inserted only if
no --git nor --color-words is explicitly specified.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
07cf103ac1 cli: pass from/to_tree in to show_diff() instead of TreeDiffIterator
This allows us to generate diff in different formats. There are various ways
to achieve that:

 a. build TreeDiffIterator for each format (this patch)
 b. make TreeDiffIterator clonable
 c. collect TreeDiffIterator and reuse the resulting vec

(a) and (b) are practically the same. (c) would be more efficient if building
and iterating TreeDiffIterator were expensive, but I don't think it is because
Tree is cached by Store. If we add $GIT_EXTERNAL_DIFF-like feature, we'll
probably need Tree objects to snapshot them to /tmp. So I chose (a).
2022-12-15 11:41:42 +09:00
Yuya Nishihara
69e57daa64 cli: enable diff output by 'log --color-words'
It doesn't make sense that --git implies -p, but --color-words doesn't.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
b4d6c9e8da cli: extract helper that resolves diff arguments for log-like commands 2022-12-15 11:41:42 +09:00
Yuya Nishihara
cdf3bfa55f cli: extract default_diff_format() from diff_format_for()
I'll make "jj log -p --summary" show both summary and diff, where -p will
be resolved to the default diff format.
2022-12-15 11:41:42 +09:00
Yuya Nishihara
dce45794df cli: move show_patch() to diff_util
I think this belongs to the same category as show_diff().
2022-12-14 15:24:50 +09:00
Yuya Nishihara
dff53b1200 cli: simplify match arms in diff_format_for() 2022-12-14 15:24:50 +09:00
Yuya Nishihara
5e490f310f cli: extract show_diff*() functions and structs to new module
I think these functions are big enough to be separated from random chunk
of command functions.
2022-12-14 15:24:50 +09:00