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

honor '~/.git-config' [commit] section #17175

Closed
Zweihorn opened this issue Aug 4, 2023 · 4 comments
Closed

honor '~/.git-config' [commit] section #17175

Zweihorn opened this issue Aug 4, 2023 · 4 comments

Comments

@Zweihorn
Copy link

Zweihorn commented Aug 4, 2023

The problem

Apparently, good git commit message style requires to separate subject from body with a blank line.

Unfortunately, the GitHub Desktop deletes any leading empty line in a body of a new commit. At least this happens to me with GitHub 3.2.7 (and earlier) on macOS and I found no easy way to change this.

Please note a git config --global commit.cleanup verbatim did not help. Apparently, GitHub Desktop ignores the "[commit]" section of the '~/.git-config' and always enforces a "--cleanup=whitespace", if I am correct.

Naturally, there would be CLI git but GitHub Desktop should honor more of '~/.git-config' thus IMO making this worth a bug report and not just a feature request.

Release version

3.2.7

Operating system

macOS 11.7.9

Steps to reproduce the behavior

  1. Git global setup git config --global commit.cleanup verbatim via CLI
  2. Establish a new commit via GitHub Desktop in the "Changes" of a branch view
  3. Try to introduce leading empty lines in the description of a.m. commit
  4. Activate the "Commit ..." button
  5. View the (unwanted) outcome of an apparent "--cleanup=whitespace" in the "History" of same branch view

Log files

% cat ~/.gitconfig

[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[user]
	name = Zweihorn
	email = 4863737+Zweihorn@users.noreply.github.com
[init]
	defaultBranch = main
[commit]
	cleanup = verbatim

Screenshots

GHD_Changes

GHD_History

Additional context

ref git-commit - cleanup

ref General Commit Message Guidelines

ref MacPorts Commit Messages Guidelines

@tidy-dev
Copy link
Contributor

tidy-dev commented Aug 4, 2023

Copied from #17179

The feature request

Apparently, good git commit message style requires to separate subject from body with a blank line.

IMO the GitHub Desktop App should provide an easy feature to accomplish this without editing the global Git config.

Thus the apparent default behaviour of a "--cleanup=whitespace" could continue and as a new optional feature for a new commit just one empty line could be added to separate subject from body with a blank line.

Proposed solution

Avoid complexity and do not honour the [commit] section nor edit the global Git config.

The new optional feature should:

  1. be configurable in the "Preferences" window under "Git"
  2. provide just one empty line to separate subject from body with a blank line for any new commit
  3. stay independent from the global Git config if applicable

Example GUI given below:

GHD_Feature-request01

Additional context

ref git-commit - cleanup

ref General Commit Message Guidelines

ref MacPorts Commit Messages Guidelines

ref #17175

@tidy-dev
Copy link
Contributor

tidy-dev commented Aug 4, 2023

To address the original issue. GitHub Desktop does trim the body input as a means to remove unintended introduction of whitespace (not through git, but programmatically as input validation). However, it automatically adds the expected newline between the summary and description. We do not apply --cleanup=whitespace

You can find the logic here:

The commit formatting:

export async function formatCommitMessage(

The createCommit method.

export async function createCommit(

Here is some images showing that it does:

Input:
image

Output in CLI (showing whitespace)
image

Screenshot of our logic showing the \n\n being added
image

@tidy-dev
Copy link
Contributor

tidy-dev commented Aug 4, 2023

If you view your commits in the command line, are you not seeing the newlines?

@tidy-dev tidy-dev added the more-info-needed The submitter needs to provide more information about the issue label Aug 4, 2023
@Zweihorn
Copy link
Author

Zweihorn commented Aug 4, 2023

Oh silly me and this was a most embarrassingly misjudgement from my side. Obviously, I misinterpreted a reasonable complaint from a third party and totally overreacted.

A basic git log would have shown the technical details and would have helped me to avoid causing unnecessary effort.

However, I would like to thank for the able and kind advice of this great community. Please accept my sincere apologies for any inconvenience.

🌻

@Zweihorn Zweihorn closed this as completed Aug 4, 2023
@github-actions github-actions bot removed the more-info-needed The submitter needs to provide more information about the issue label Aug 4, 2023
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

No branches or pull requests

2 participants