summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2016-06-28 10:01:16 +0200
committerJunio C Hamano <gitster@pobox.com>2016-07-07 09:17:12 -0700
commit9e2be614c1fa594f786b408e717159f1ed52bb37 (patch)
treee258b374c5ebb6ec538c602429997d31592052bf /combine-diff.c
parent75964d2722cb95f0a9a04f9c0a5814faabbd232f (diff)
downloadgit-tb/convert-peek-in-index.tar.gz
correct ce_compare_data() in a middle of a mergetb/convert-peek-in-index
The following didn't work as expected: - In a middle of a merge - merge.renormalize is true, - .gitattributes = "* text=auto" - core.eol = crlf Merge a blob with CRLF "first line\r\nsame line\r\n" and a blob with LF "first line\nsame line\n". The expected result of the merge is "first line\nsame line\n". The content in the working tree is "first line\r\nsame line\r\n", and ce_compare_data() should find that the content is clean and return 0. Deep down crlf_to_git() is invoked, to check if CRLF are converted or not. The "new safer autocrlf handling" calls blob_has_cr(). Instead of using the sha1 of the blob, (CRLF in this example), the function get_sha1_from_index() is invoked. get_sha1_from_index() decides to return "ours" when in the middle of the merge, which is LF. As a result, the CRLF in the worktree are converted into LF before the comparison. The contents of LF and CRLF don't match any more. The problem is that ce_compare_data() has ce->sha1, but the sha1 is lost on it's way into blob_has_cr(). Forwarding ce->sha1 from ce_compare_data() into crlf_to_git() makes sure that blob_has_cr() looks at the appropriate blob. Add a new parameter index_blob_sha1 to convert_to_git(), and forward the sha1 from ce_compare_data() into convert_to_git(). Other callers use NULL for index_blob_sha1, and the sha1 is determined from path using get_sha1_from_cache(path). This is the same handling as before. In the same spirit, forward the sha1 into would_convert_to_git(). While at it, rename has_cr_in_index() into blob_has_cr() and replace 0 with SAFE_CRLF_FALSE. Add a TC in t6038 to have a test coverage under Linux. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 0e1d4b0893..c4fa8842e3 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1053,7 +1053,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
if (is_file) {
struct strbuf buf = STRBUF_INIT;
- if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
+ if (convert_to_git(elem->path, result, len,
+ &buf, safe_crlf, NULL)) {
free(result);
result = strbuf_detach(&buf, &len);
result_size = len;