Skip to content

Commit dd54b92

Browse files
committed
Merge branch 'docs' into 'master'
docs: Jujutsu support See merge request mkjeldsen/commitmsgfmt!84
2 parents 9bb3fb6 + c4ba5f3 commit dd54b92

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
`commitmsgfmt` formats commit messages. It reflows and wraps text, with special
44
understanding of patterns often seen in commit messages.
55

6+
## Unreleased
7+
8+
- MSRV 1.63.
9+
10+
- Nominal Jujutsu support, contributed by Manuel Mendez.
11+
612
## 1.6.0 - 2023-11-11
713

814
- #6: Recognize lines that begin with `>` as _block quotes_ and preserve them

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ Git commit integration:
146146

147147
### Other version control systems
148148

149-
`commitmsgfmt` uses Git-like conventions because I use Git but is ultimately
150-
agnostic about version control systems. I welcome contributions on integrating
151-
with other systems.
149+
`commitmsgfmt` uses Git-like conventions but is principally agnostic about
150+
version control systems. `commitmsgfmt` nominally supports Jujutsu. I welcome
151+
contributions on integrating with other systems.
152152

153153
### Alternatives
154154

doc/commitmsgfmt.1.adoc

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ commitmsgfmt - Format commit messages
1616
{self} *--version*
1717
{self} *-h*
1818
{self} *--help*
19-
{self} [*--width* _NUM_]
19+
{self} [*--comment-string* _STR_] [*--width* _NUM_]
2020

2121
== Description
2222

@@ -47,9 +47,15 @@ Display this help and exit.
4747

4848
Output version information and exit.
4949

50+
*-c*, *--comment-string* _STR_::
51+
52+
Specify the prefix string that identifies the current line in the commit
53+
message editor as a comment line. Default *#*. For Jujutsu use *JJ:*. If
54+
specified multiple times only the last occurrence is used.
55+
5056
*-w*, *--width* _NUM_::
5157

52-
Specify the max allowed width of body text. Default 72. If specified multiple
58+
Specify the max allowed width of body text. Default *72*. If specified multiple
5359
times only the last occurrence is used.
5460

5561
== Details
@@ -88,8 +94,8 @@ of implementation and performance comparability. This may change.
8894
rules laid out above cause degenerative behavior. {self} attempts to detect
8995
those cases and avoid them by preventing wrapping: it will
9096

91-
* never break a line immediately before the *core.commentChar* character, which
92-
would cause the second line to degenerate into a _comment_;
97+
* never break a line immediately before the _comment string_, which would cause
98+
the second line to degenerate into a _comment_;
9399

94100
* never break a line immediately before any sequence of punctuation, such as
95101
_ellipses_ and _en_--dashes, which would cause a distraction after the pause
@@ -292,19 +298,28 @@ quote with an author attribution, illustrated above.
292298

293299
=== Comment
294300

295-
A line starting with the *core.commentChar* character, or a hash sign (*#*)
296-
when that setting is unset, is considered a _comment_. Comments are not
297-
wrapped. If the whole line matches the _scissor_ marker it is instead
298-
considered _scissored_.
301+
A line starting with the specified _comment string_ is considered a _comment_.
302+
Comments are not wrapped. If the whole line matches the _scissor_ marker it is
303+
instead considered _scissored_.
304+
305+
The _comment string_ is given by
306+
307+
. the *--comment-string* option value, or
308+
. the *core.commentChar* configuration value, or
309+
. the *core.commentString* configuration value since Git 2.45.0, or
310+
. the hash sign (*#*) when none of the other options are specified.
299311

300312
{self} currently does not support the special *auto* value for
301313
*core.commentChar*. In that case, {self} falls back to the hash sign.
302314

303315
=== Scissored
304316

305-
A line matching the _scissor_ marker, as defined by *git-commit*(1), denotes
306-
the start of scissored content. Everything from the scissor to the end of the
307-
stream is printed verbatim. *git commit --verbose* relies on this.
317+
A line matching the _scissor_ marker denotes the start of scissored content.
318+
Everything from the scissor to the end of the stream is printed verbatim. *git
319+
commit --verbose* relies on this.
320+
321+
The _scissor_ marker is as defined by *git-commit*(1) or alternatively the
322+
literal _comment string_ suffix *ignore-rest* used by Jujutsu.
308323

309324
== Usage
310325

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ macro_rules! str_help_long {
6262
-c, --comment-string <STR>
6363
The string used to detect a comment. By default it queries git config
6464
for the value and defaults to `#`. Supply this to use a different value
65-
such as `JJ` for files that are to be commited in a jujutsu repository."#
65+
such as `JJ` for files that are to be commited in a Jujutsu repository."#
6666
)
6767
};
6868
}
@@ -188,6 +188,11 @@ impl Config {
188188
}
189189

190190
fn git_config_commentchar() -> Result<Vec<u8>, io::Error> {
191+
// Git >= v2.45.0: core.commentChar==core.commentString and both support a
192+
// "string." We only check core.commentChar to balance
193+
// - compatibility with older versions of Git
194+
// - implementation complexity
195+
// - author's laziness
191196
std::process::Command::new("git")
192197
.args(["config", "core.commentChar"])
193198
.output()

0 commit comments

Comments
 (0)