summaryrefslogtreecommitdiff
path: root/dir.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 /dir.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 'dir.c')
-rw-r--r--dir.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index a4a9d9fae1..8709fc02b5 100644
--- a/dir.c
+++ b/dir.c
@@ -720,7 +720,7 @@ static int add_excludes(const char *fname, const char *base, int baselen,
(pos = cache_name_pos(fname, strlen(fname))) >= 0 &&
!ce_stage(active_cache[pos]) &&
ce_uptodate(active_cache[pos]) &&
- !would_convert_to_git(fname))
+ !would_convert_to_git(fname, NULL))
hashcpy(sha1_stat->sha1, active_cache[pos]->sha1);
else
hash_sha1_file(buf, size, "blob", sha1_stat->sha1);