File tree Expand file tree Collapse file tree 2 files changed +64
-1
lines changed
Expand file tree Collapse file tree 2 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -570,7 +570,7 @@ static void update_file_flags(const unsigned char *sha,
570570 if (type != OBJ_BLOB )
571571 die ("blob expected for %s '%s'" , sha1_to_hex (sha ), path );
572572
573- if (S_ISREG (mode )) {
573+ if (S_ISREG (mode ) || (! has_symlinks && S_ISLNK ( mode )) ) {
574574 int fd ;
575575 if (mkdir_p (path , 0777 ))
576576 die ("failed to create path %s: %s" , path , strerror (errno ));
@@ -591,6 +591,7 @@ static void update_file_flags(const unsigned char *sha,
591591 mkdir_p (path , 0777 );
592592 unlink (path );
593593 symlink (lnk , path );
594+ free (lnk );
594595 } else
595596 die ("do not know what to do with %06o %s '%s'" ,
596597 mode , sha1_to_hex (sha ), path );
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ #
3+ # Copyright (c) 2007 Johannes Sixt
4+ #
5+
6+ test_description=' merging symlinks on filesystem w/o symlink support.
7+
8+ This tests that git-merge-recursive writes merge results as plain files
9+ if core.symlinks is false.'
10+
11+ . ./test-lib.sh
12+
13+ test_expect_success \
14+ ' setup' '
15+ git-config core.symlinks false &&
16+ > file &&
17+ git-add file &&
18+ git-commit -m initial &&
19+ git-branch b-symlink &&
20+ git-branch b-file &&
21+ l=$(echo -n file | git-hash-object -t blob -w --stdin) &&
22+ echo "120000 $l symlink" | git-update-index --index-info &&
23+ git-commit -m master &&
24+ git-checkout b-symlink &&
25+ l=$(echo -n file-different | git-hash-object -t blob -w --stdin) &&
26+ echo "120000 $l symlink" | git-update-index --index-info &&
27+ git-commit -m b-symlink &&
28+ git-checkout b-file &&
29+ echo plain-file > symlink &&
30+ git-add symlink &&
31+ git-commit -m b-file'
32+
33+ test_expect_failure \
34+ ' merge master into b-symlink, which has a different symbolic link' '
35+ ! git-checkout b-symlink ||
36+ git-merge master'
37+
38+ test_expect_success \
39+ ' the merge result must be a file' '
40+ test -f symlink'
41+
42+ test_expect_failure \
43+ ' merge master into b-file, which has a file instead of a symbolic link' '
44+ ! (git-reset --hard &&
45+ git-checkout b-file) ||
46+ git-merge master'
47+
48+ test_expect_success \
49+ ' the merge result must be a file' '
50+ test -f symlink'
51+
52+ test_expect_failure \
53+ ' merge b-file, which has a file instead of a symbolic link, into master' '
54+ ! (git-reset --hard &&
55+ git-checkout master) ||
56+ git-merge b-file'
57+
58+ test_expect_success \
59+ ' the merge result must be a file' '
60+ test -f symlink'
61+
62+ test_done
You can’t perform that action at this time.
0 commit comments