|
55 | 55 | ancestor() {
|
56 | 56 | # We do some math with the expected ancestor length.
|
57 | 57 | expected=$3
|
58 |
| - if test -n "$rootoff" && test "x$expected" != x-1; then |
59 |
| - expected=$(($expected-$rootslash)) |
60 |
| - test $expected -lt 0 || |
61 |
| - expected=$(($expected+$rootoff)) |
62 |
| - fi |
63 |
| - test_expect_success "longest ancestor: $1 $2 => $expected" \ |
| 58 | + case "$rootoff,$expected,$2" in |
| 59 | + *,*,//*) ;; # leave UNC paths alone |
| 60 | + [0-9]*,[0-9]*,/*) |
| 61 | + # On Windows, expect MSYS2 pseudo root translation for |
| 62 | + # Unix-style absolute paths |
| 63 | + expected=$(($expected-$rootslash+$rootoff)) |
| 64 | + ;; |
| 65 | + esac |
| 66 | + test_expect_success $4 "longest ancestor: $1 $2 => $expected" \ |
64 | 67 | "actual=\$(test-tool path-utils longest_ancestor_length '$1' '$2') &&
|
65 | 68 | test \"\$actual\" = '$expected'"
|
66 | 69 | }
|
@@ -156,6 +159,11 @@ ancestor /foo/bar /foo 4
|
156 | 159 | ancestor /foo/bar /foo:/bar 4
|
157 | 160 | ancestor /foo/bar /bar -1
|
158 | 161 |
|
| 162 | +# Windows-specific: DOS drives, network shares |
| 163 | +ancestor C:/Users/me C:/ 2 MINGW |
| 164 | +ancestor D:/Users/me C:/ -1 MINGW |
| 165 | +ancestor //server/share/my-directory //server/share/ 14 MINGW |
| 166 | + |
159 | 167 | test_expect_success 'strip_path_suffix' '
|
160 | 168 | test c:/msysgit = $(test-tool path-utils strip_path_suffix \
|
161 | 169 | c:/msysgit/libexec//git-core libexec/git-core)
|
|
0 commit comments