Skip to content

Commit 1758682

Browse files
committed
Mention commit style guide properly
Commit messages are important as soon as we need to dig into the history of certain parts of the system. Change-Id: I3d9411e792be96cd76873a70786f7d07cd89dc4c
1 parent 6f5a552 commit 1758682

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,65 @@ mainstream architectures. PDP-11 era is long gone.
789789
- It is fair to assume that `NULL` is matching `(uintptr_t) 0` and it is fair
790790
to `memset()` structures with zero. Non-zero `NULL` is for retro computing.
791791
792+
## Git Commit Style
793+
794+
Clear and descriptive commit messages are crucial for maintaining a transparent history of changes and for facilitating effective debugging and tracking. Please adhere to the guidelines outlined in [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/).
795+
1. Separate the subject from the body with a blank line.
796+
2. Limit the subject line to 50 characters.
797+
3. Capitalize the subject line.
798+
4. Do not end the subject line with a period.
799+
5. Use the imperative mood in the subject line.
800+
6. Wrap the body at 72 characters.
801+
7. Use the body to explain what and why, not how.
802+
803+
An example (derived from Chris' blog post) looks like the following:
804+
805+
```text
806+
Summarize changes in around 50 characters or less
807+
808+
More detailed explanatory text, if necessary. Wrap it to about 72
809+
characters or so. In some contexts, the first line is treated as the
810+
subject of the commit and the rest of the text as the body. The
811+
blank line separating the summary from the body is critical (unless
812+
you omit the body entirely); various tools like `log`, `shortlog`
813+
and `rebase` can get confused if you run the two together.
814+
815+
Explain the problem that this commit is solving. Focus on why you
816+
are making this change as opposed to how (the code explains that).
817+
Are there side effects or other unintuitive consequences of this
818+
change? Here's the place to explain them.
819+
820+
Further paragraphs come after blank lines.
821+
822+
- Bullet points are okay, too
823+
824+
- Typically a hyphen or asterisk is used for the bullet, preceded
825+
by a single space, with blank lines in between, but conventions
826+
vary here
827+
828+
If you use an issue tracker, put references to them at the bottom,
829+
like this:
830+
Close #123
831+
```
832+
833+
In addition, this project expects contributors to follow these additional rules:
834+
* If there is important, useful, or essential conversation or information,
835+
include a reference or copy it.
836+
* Do not write single-word commits. Provide a descriptive subject.
837+
* Avoid using just a filename (e.g., `Update qtest.c`).
838+
Each commit message subject should be sufficiently descriptive.
839+
* Avoid using abusive words.
840+
* For queue functions (names starting with "q_", e.g., `Implement q_size` or `Finish q_new`),
841+
ensure the commit message includes a detailed explanation in the body.
842+
* Avoid using backticks in commit subjects.
843+
Backticks can be easily confused with single quotes on some terminals,
844+
reducing readability. Plain text or single quotes provide sufficient clarity and emphasis.
845+
* Avoid using parentheses in commit subjects.
846+
Excessive use of parentheses "()" can clutter the subject line,
847+
making it harder to quickly grasp the essential message.
848+
849+
Some conventions are automatically enforced by the [githooks](https://git-scm.com/docs/githooks).
850+
792851
## References
793852
- [Linux kernel coding style](https://www.kernel.org/doc/html/latest/process/coding-style.html)
794853
- 1999, Brian W. Kernighan and Rob Pike, The Practice of Programming, Addison–Wesley.

scripts/commit-msg.hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ display_warnings() {
9393

9494
echo
9595
echo -e "${RED}$(cat <<-EOF
96-
How to Write a Git Commit Message: https://chris.beams.io/posts/git-commit/
96+
Read https://github.com/sysprog21/lab0-c/blob/master/CONTRIBUTING.md#git-commit-style carefully.
9797
EOF
9898
)${NC}"
9999
}

0 commit comments

Comments
 (0)