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

Scissors not removed from commit message #2623

Closed
yodaldevoid opened this issue May 13, 2020 · 4 comments · Fixed by #2714
Closed

Scissors not removed from commit message #2623

yodaldevoid opened this issue May 13, 2020 · 4 comments · Fixed by #2714
Labels
Milestone

Comments

@yodaldevoid
Copy link

  • [x ] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.26.2.windows.1
cpu: x86_64
built from commit: 4267c88d0d8936ae723bba55e0576b1c4f3d4e1a
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.18363.778]
(c) 2019 Microsoft Corporation. All rights reserved.
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: SublimeText
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?
core.autocrlf=true
commit.verbose=true
commit.cleanup=scissors

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Powershell 7.0.0

  1. git commit with changes staged
  2. Write message in editor window that opened above the scissor line
  3. Save and close message
  4. Commit is finished
  • What did you expect to occur after running these commands?

Commit message is saved and all lines below the scissors are not included in the commit message.

  • What actually happened instead?

The commit message included the scissors and all lines that should have been removed in addition to the intended commit message.

$ git show
commit 8e4d40caad218bd7f8f29926fbab5818d7c11e28 (HEAD -> branch_name)
Author: Gabriel Smith <ga29smith@gmail.com>
Date:   Wed May 13 16:42:12 2020 -0400

    This is an example commit message

    The below scissors should not have been included in the commit message.

    # ------------------------ >8 ------------------------
    # Do not modify or remove the line above.
    # Everything below it will be ignored.
    #

(further message truncated for brevity)

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

Private repo, sorry.

@dscho
Copy link
Member

dscho commented May 15, 2020

   # ------------------------ >8 ------------------------

Does it work when your scissors line does not start with # ?

* If the problem was occurring with a specific repository, can you provide the
  URL to that repository to help us with testing?

Private repo, sorry.

Well, that does not need to stop you from providing an easy-to-reproduce demonstration in the form of a script... the easier you make it for other people to help you, the more likely you get timely help.

@dscho dscho added the question label May 15, 2020
@lbonanomi
Copy link

lbonanomi commented Jun 22, 2020

I think the problem is in the definiton of cut_line, which ends with a newline (\n).
The function wt_status_locate_end isn't matching the pattern with a newline, so the buffer isn't being shortened to drop the post-scissors text.

I'm not sure if changing the cut_line definition in wt-status.c is the right way to handle this in a production release, but it it certainly worked in a local test case.

EDIT:

Local test case as-below, after tweaking wt-status.c:

cd /tmp/test; 
man ls > ls.man; 
git add ls.man; 
/usr/src/git/git-commit.exe  --cleanup=scissors

Commit message:

Keep this line
# ------------------------ >8 ------------------------

Drop everything
below
scissors...

# Do not modify or remove the line above.
# Everything below it will be ignored.
#
# On branch master
# Changes to be committed:
#	modified:   ls.man
#

$ git log -1
commit 2a4af65a70dfe7637d898d4facc741db3116ab81 (HEAD -> master)
Author: lbonanomi <lbonanomi@gmail.com>
Date:   Mon Jun 22 10:21:30 2020 -0400

    Keep this line

@dscho
Copy link
Member

dscho commented Jun 22, 2020

I think the problem is in the definiton of cut_line, which ends with a newline (\n).
The function wt_status_locate_end isn't matching the pattern with a newline, so the buffer isn't being shortened to drop the post-scissors text.

Do I understand correctly that this is a CR/LF issue?

@lbonanomi
Copy link

Do I understand correctly that this is a CR/LF issue?

I think so, yes. Twiddling the cut_line[] definition to either no line ending or DOS-style CRLFs makes the scissors work; is this issue just a case of a missing config directive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants