git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] blame: add a failing test for a CRLF issue.

From
Torsten Bögershausen <tboegi@web.de>
Date
Feb 19, 2014, 20:16 UTC
Message-ID
<53051116.5010307@web.de>
In-Reply-To
<1392752735-168203-1-git-send-email-sandals@crustytoothpaste.net>
On 02/18/2014 08:45 PM, brian m. carlson wrote:
Show 36 quoted lines
> If a file contains CRLF line endings in a repository with
> core.autocrlf=input, then blame always marks the lines as "Not Committed
> Yet", even if they are unmodified.  Add a failing test for this case, so we
> are at least aware of this issue.
>
> Reported-by: Ephrim Khong <dr.khong@gmail.com>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>
> Obviously, this doesn't actually fix the issue, but at least we're aware of it
> so we don't lose track of it and can fix it.  A future patch can mark the test
> passing.
>
>   t/t8003-blame-corner-cases.sh | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh
> index e7cac1d..903f775 100755
> --- a/t/t8003-blame-corner-cases.sh
> +++ b/t/t8003-blame-corner-cases.sh
> @@ -191,4 +191,14 @@ test_expect_success 'indent of line numbers, ten lines' '
>   	test $(grep -c "  " actual) = 9
>   '
>
> +test_expect_failure 'blaming files with CRLF newlines' '
> +	git config core.autocrlf false &&
> +	printf "testcase\r\n" >crlffile &&
> +	git add crlffile &&
> +	git commit -m testcase &&
> +	git config core.autocrlf input &&
> +	git blame crlffile >actual &&
> +	grep "A U Thor" actual
> +'
> +
>   test_done
>

We can test that git blame gives the same result with core.autocrlf=input and core.autocrlf=false, and make the test case look like this:

test_expect_failure 'blaming files with CRLF newlines' '
	git config core.autocrlf false &&
	printf "testcase\r\n" >crlffile &&
	git add crlffile &&
	git commit -m testcase &&
	git blame crlffile >expected &&
	git -c core.autocrlf=input blame crlffile >actual &&
	test_cmp expected actual
'
Previous: brian m. carlson
Message 4 of 4 in “git blame: "Not Committed Yet" with clean WD”
  1. Ephrim KhongFeb 13, 2014
  2. brian m. carlsonFeb 14, 2014
  3. blame: add a failing test for a CRLF issue.brian m. carlson, Feb 18, 2014
  4. Torsten BögershausenFeb 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.