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

Gedit strips newlines when commit lacks a blank line #2315

Closed
idbrii opened this issue Jun 27, 2024 · 2 comments · Fixed by #2318
Closed

Gedit strips newlines when commit lacks a blank line #2315

idbrii opened this issue Jun 27, 2024 · 2 comments · Fixed by #2318

Comments

@idbrii
Copy link
Contributor

idbrii commented Jun 27, 2024

I use git-svn on a project that don't follow good commit message formatting. We frequently have commit messages that are mostly nicely formatted -- except for the "one blank line" rule. Git generally handles this fine, but fugitive does not. :Gedit HEAD (or navigating :G blame and other commands that view a commit) will put the entire commit message on one line if it doesn't have a blank line after the first line.

git log --online also dumps it on one line.
:G show HEAD displays with expected newlines -- probably because it includes text from git verbatim?


Example commit message:

Capitalized, short (50 chars or less) summary
More detailed explanatory text, if necessary.  Wrap it to about 72
characters or so.  In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body.  The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, followed by a
  single space, with blank lines in between, but conventions vary here
- Use a hanging indent

Looks similar with :G show HEAD (but indented). However, :Gedit HEAD results in one massive line:

tree 97f0c365846b67412c5fadf7b0727893b72f75c2
parent 982feb7a65aef15e4cff157120808f439a9abdc4
author idbrii <idbrii@example.com> 2024-06-27 Thu 01:11:18 PM
committer idbrii <idbrii@example.com> 2024-06-27 Thu 01:24:35 PM

Capitalized, short (50 chars or less) summary More detailed explanatory text, if necessary.  Wrap it to about 72 characters or so.  In some contexts, the first line is treated as the subject of an email and the rest of the text as the body.  The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. - Bullet points are okay, too - Typically a hyphen or asterisk is used for the bullet, followed by a   single space, with blank lines in between, but conventions vary here - Use a hanging indent

Tested on fugitive latest: d0c1a43. Used gvim on Win10 and vim on Ubuntu 22.04.4 LTS (WSL).

Minimal vimrc:

" Invoke with:
" gvim -Nu reprovimrc.vim -U NONE +"Gedit HEAD" c:/project/readme.md

let s:plugins = ['sensible']
let s:plugins += ['fugitive']

set runtimepath-=~/.vim
set runtimepath-=~/.vim/after
set runtimepath-=~/vimfiles
set runtimepath-=~/vimfiles/after
for plugin in s:plugins
    exec "set runtimepath^=~/.vim/bundle/". plugin
    exec "set runtimepath+=~/.vim/bundle/". plugin ."/after"
endfor
set viminfofile=NONE

set hlsearch
colorscheme desert
@tpope
Copy link
Owner

tpope commented Jun 27, 2024

This is the the same thing that git show -s --format=%s does, correct? Probably not going to get fixed until that buffer gets redone.

@idbrii
Copy link
Contributor Author

idbrii commented Jul 3, 2024

Yup. git show -s --format=%s does dump all the text on one line in commits lacking a blank line.

I see. It's due to the massive format in this line setting up a b:fugitive_type==commit buffer:

call s:ReplaceCmd([dir, '-c', 'diff.noprefix=false', '-c', 'log.showRoot=false', 'show', '--no-color', '-m', '--first-parent', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev])

idbrii added a commit to idbrii/vim-fugitive that referenced this issue Jul 3, 2024
Fix tpope#2315: Gedit strips newlines when commit lacks a blank line

%B is the "raw body (unwrapped subject and body)". Since we're
displaying both, we can use that to avoid any changes to the message
content. %B was added to git in 1.7.2 (2010) in commit
1367b12ad623e28546ba40c435015d94e7fbb248, and fugitive requires 1.8.5 so
it's safe to use.
idbrii added a commit to idbrii/vim-fugitive that referenced this issue Jul 3, 2024
Fix tpope#2315: Gedit strips newlines when commit lacks a blank line

%B is the "raw body (unwrapped subject and body)". Since we're
displaying both, we can use that to avoid any changes to the message
content. %B was added to git in 1.7.2 (2010) in commit
1367b12ad623e28546ba40c435015d94e7fbb248, and fugitive requires 1.8.5 so
it's safe to use.
@tpope tpope closed this as completed in 5661dea Jul 5, 2024
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 a pull request may close this issue.

2 participants