1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 15:16:11 +02:00

Merge branch 'js/merge-recursive'

* js/merge-recursive:
  merge-recursive: respect core.autocrlf when writing out the result
  Add testcase for merging in a CRLF repo
This commit is contained in:
Junio C Hamano 2008-06-09 16:13:10 -07:00
commit ea81e10ff4
2 changed files with 63 additions and 0 deletions

View File

@ -555,9 +555,19 @@ static void update_file_flags(const unsigned char *sha,
die("cannot read object %s '%s'", sha1_to_hex(sha), path);
if (type != OBJ_BLOB)
die("blob expected for %s '%s'", sha1_to_hex(sha), path);
if (S_ISREG(mode)) {
struct strbuf strbuf;
strbuf_init(&strbuf, 0);
if (convert_to_working_tree(path, buf, size, &strbuf)) {
free(buf);
size = strbuf.len;
buf = strbuf_detach(&strbuf, NULL);
}
}
if (make_room_for_path(path) < 0) {
update_wd = 0;
free(buf);
goto update_index;
}
if (S_ISREG(mode) || (!has_symlinks && S_ISLNK(mode))) {
@ -580,6 +590,7 @@ static void update_file_flags(const unsigned char *sha,
} else
die("do not know what to do with %06o %s '%s'",
mode, sha1_to_hex(sha), path);
free(buf);
}
update_index:
if (update_cache)

52
t/t6033-merge-crlf.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh
append_cr () {
sed -e 's/$/Q/' | tr Q '\015'
}
remove_cr () {
tr '\015' Q | sed -e 's/Q$//'
}
test_description='merge conflict in crlf repo
b---M
/ /
initial---a
'
. ./test-lib.sh
test_expect_success setup '
git config core.autocrlf true &&
echo foo | append_cr >file &&
git add file &&
git commit -m "Initial" &&
git tag initial &&
git branch side &&
echo line from a | append_cr >file &&
git commit -m "add line from a" file &&
git tag a &&
git checkout side &&
echo line from b | append_cr >file &&
git commit -m "add line from b" file &&
git tag b &&
git checkout master
'
test_expect_success 'Check "ours" is CRLF' '
git reset --hard initial &&
git merge side -s ours &&
cat file | remove_cr | append_cr >file.temp &&
test_cmp file file.temp
'
test_expect_success 'Check that conflict file is CRLF' '
git reset --hard a &&
test_must_fail git merge side &&
cat file | remove_cr | append_cr >file.temp &&
test_cmp file file.temp
'
test_done