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

Rationalize line endings for scissors-cleanup #2714

Merged
merged 1 commit into from
Jul 3, 2020
Merged

Rationalize line endings for scissors-cleanup #2714

merged 1 commit into from
Jul 3, 2020

Conversation

lbonanomi
Copy link

This PR attempts to resolve #2623

Strip cut_line[] definition to enhance interoperability between UNIX and DOS line-ending styles

Signed-off-by: Luke Bonanomi lbonanomi@gmail.com

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR also wants a more verbose commit message, I think. Something similar to d540b70's commit message strikes me as desirable.

wt-status.c Outdated Show resolved Hide resolved
@lbonanomi
Copy link
Author

This PR also wants a more verbose commit message, I think. Something similar to d540b70's commit message strikes me as desirable.

I take your point and apologize for a scant commit message.

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the suggestions I gave, I would like to ask you to use the interactive rebase to squash the fixup commits into the commits that were not quite right in the first place, and to drop the merge commit.

t/t7502-commit-porcelain.sh Outdated Show resolved Hide resolved
t/t7502-commit-porcelain.sh Outdated Show resolved Hide resolved
t/t7502-commit-porcelain.sh Outdated Show resolved Hide resolved
t/t7502-commit-porcelain.sh Show resolved Hide resolved
echo >>negative &&
cat >text <<-\EOF &&

# ------------------------ >8 ------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks as if the lines above were indented using spaces, but here you use a tab. Git's coding style is to use tabs, always.

I cannot fail to see that you left an empty line after the test_expect_success line (which BTW is too long, it has to be at most 80 columns). Both coding style violations are already present in the test script, so I don't fault you for copy/editing those. But I would like to request to fix the style of the lines you added. (You don't need to bother with lines you did not touch, of course, that's not your responsibility.)

t/t7502-commit-porcelain.sh Outdated Show resolved Hide resolved
t/t7502-commit-porcelain.sh Outdated Show resolved Hide resolved
wt-status.c Outdated Show resolved Hide resolved
wt-status.c Outdated Show resolved Hide resolved
wt-status.h Outdated Show resolved Hide resolved
This change enhances `git commit --cleanup=scissors` by detecting
scissors lines ending in either LF (UNIX-style) or CR/LF (DOS-style).

Regression tests are included to specifically test for trailing
comments after a CR/LF-terminated scissors line.

Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member

dscho commented Jul 2, 2020

I hope you don't mind that I made a couple of edits. Nothing major, just a few touch-ups that I hope will increase the chances that the core Git project will accept this patch as-is. Here is the range-diff (if you have not worked with range-diffs before, here is an explanation):

1:  17fffb7c9383 ! 1:  d508f45ebfed This change enhances git-commit "scissors" cleanup by making scissors lines ("------------------------ >8 ------------------------") ending in either LF (UNIX-style) or CR/LF (DOS-style) detectable by git-commit.
    @@
      ## Metadata ##
    -Author: lbonanomİ <lbonanomi@gmail.com>
    +Author: Luke Bonanomi <lbonanomi@gmail.com>
     
      ## Commit message ##
    -    This change enhances git-commit "scissors" cleanup by making scissors lines
    -    ("------------------------ >8 ------------------------") ending in either LF
    -    (UNIX-style) or CR/LF (DOS-style) detectable by git-commit.
    +    commit: accept "scissors" with CR/LF line endings
     
    -    Regression tests are included to specifically test for trailing comments after
    -    a CR/LF-terminated scissors line.
    +    This change enhances `git commit --cleanup=scissors` by detecting
    +    scissors lines ending in either LF (UNIX-style) or CR/LF (DOS-style).
    +
    +    Regression tests are included to specifically test for trailing
    +    comments after a CR/LF-terminated scissors line.
     
         Signed-off-by: Luke Bonanomi <lbonanomi@gmail.com>
    +    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
     
      ## t/t7502-commit-porcelain.sh ##
     @@ t/t7502-commit-porcelain.sh: test_expect_success 'cleanup commit messages (scissors option,-F,-e, scissors on
    - 	git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
    - 	git cat-file -p HEAD >raw &&
    - 	sed -e "1,/^\$/d" raw >actual &&
    -+	test_must_be_empty actual 
    -+'
    -+
    + 	test_must_be_empty actual
    + '
    + 
     +test_expect_success 'helper-editor' '
     +
    -+	write_script "$PWD"/lf-to-crlf.sh <<-\EOF
    ++	write_script lf-to-crlf.sh <<-\EOF
     +	sed "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
    -+	cp "$1".new /tmp
     +	mv -f "$1".new "$1"
     +	EOF
     +'
     +
     +test_expect_success 'cleanup commit messages (scissors option,-F,-e, CR/LF line endings)' '
     +
    -+	echo >>negative &&
     +	test_config core.editor "\"$PWD/lf-to-crlf.sh\"" &&
     +	scissors="# ------------------------ >8 ------------------------" &&
    ++
     +	test_write_lines >text \
     +	"# Keep this comment" "" " $scissors" \
     +	"# Keep this comment, too" "$scissors" \
    -+	"# Removed this comment" "$scissors" \
    ++	"# Remove this comment" "$scissors" \
     +	"Remove this comment, too" &&
    -+	true &&
    ++
     +	test_write_lines >expect \
     +	"# Keep this comment" "" " $scissors" \
     +	"# Keep this comment, too" &&
    -+	git commit --cleanup=scissors -e -F text -a &&
    ++
    ++	git commit --cleanup=scissors -e -F text --allow-empty &&
     +	git cat-file -p HEAD >raw &&
     +	sed -e "1,/^\$/d" raw >actual &&
     +	test_cmp expect actual
    @@ t/t7502-commit-porcelain.sh: test_expect_success 'cleanup commit messages (sciss
     +
     +test_expect_success 'cleanup commit messages (scissors option,-F,-e, scissors on first line, CR/LF line endings)' '
     +
    -+	echo >>negative &&
     +	scissors="# ------------------------ >8 ------------------------" &&
     +	test_write_lines >text \
     +	"$scissors" \
     +	"# Remove this comment and any following lines" &&
     +	cp text /tmp/test2-text &&
    -+	git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
    ++	git commit --cleanup=scissors -e -F text --allow-empty --allow-empty-message &&
     +	git cat-file -p HEAD >raw &&
     +	sed -e "1,/^\$/d" raw >actual &&
    - 	test_must_be_empty actual
    - '
    ++	test_must_be_empty actual
    ++'
    ++
    + test_expect_success 'cleanup commit messages (strip option,-F)' '
      
    + 	echo >>negative &&
     
      ## wt-status.c ##
     @@
    @@ wt-status.c: static void wt_longstatus_print_other(struct wt_status *s,
      
      	strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
     -	if (starts_with(s, pattern.buf + 1))
    -+	if (starts_with(s, pattern.buf + 1) && starts_with_newline(s + pattern.len - 1))
    ++	if (starts_with(s, pattern.buf + 1) &&
    ++	    starts_with_newline(s + pattern.len - 1))
      		len = 0;
     -	else if ((p = strstr(s, pattern.buf)))
    -+	else if ((p = strstr(s, pattern.buf)) && starts_with_newline(p + pattern.len))
    ++	else if ((p = strstr(s, pattern.buf)) &&
    ++		 starts_with_newline(p + pattern.len))
      		len = p - s + 1;
      	strbuf_release(&pattern);
      	return len;
    -
    - ## wt-status.h ##
    -@@ wt-status.h: static inline int is_from_cherry_pick(enum commit_whence whence)
    - 		whence == FROM_CHERRY_PICK_MULTI;
    - }
    - 
    -+
    - static inline int is_from_rebase(enum commit_whence whence)
    - {
    - 	return whence == FROM_REBASE_PICK;

@wedataintelligence

This comment has been minimized.

@dscho dscho merged commit 9646b3d into git-for-windows:main Jul 3, 2020
@dscho dscho added this to the Next release milestone Jul 3, 2020
git-for-windows-ci pushed a commit that referenced this pull request Jul 3, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 3, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 3, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 3, 2020
Rationalize line endings for scissors-cleanup
dscho added a commit to git-for-windows/build-extra that referenced this pull request Jul 3, 2020
The cleanup mode called "scissors" in `git
commit` [now handles CR/LF line endings
correctly](git-for-windows/git#2714).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Jul 8, 2020
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Jul 8, 2020
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 8, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 8, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 9, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 10, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 10, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 10, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 11, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 11, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 11, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 11, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 20, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 20, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 21, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 21, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 21, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
Rationalize line endings for scissors-cleanup
dscho added a commit that referenced this pull request Oct 23, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
Rationalize line endings for scissors-cleanup
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
Rationalize line endings for scissors-cleanup
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 this pull request may close these issues.

Scissors not removed from commit message
3 participants