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:
commit
ea81e10ff4
@ -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
52
t/t6033-merge-crlf.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user