t4011: abstract away SHA-1-specific constants
Adjust the test so that it computes variables for object IDs instead of using hard-coded hashes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
32a6707267
commit
840624ff55
|
@ -9,11 +9,24 @@ test_description='Test diff of symlinks.
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||||
|
|
||||||
|
# Print the short OID of a symlink with the given name.
|
||||||
|
symlink_oid () {
|
||||||
|
local oid=$(printf "%s" "$1" | git hash-object --stdin) &&
|
||||||
|
git rev-parse --short "$oid"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print the short OID of the given file.
|
||||||
|
short_oid () {
|
||||||
|
local oid=$(git hash-object "$1") &&
|
||||||
|
git rev-parse --short "$oid"
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success 'diff new symlink and file' '
|
test_expect_success 'diff new symlink and file' '
|
||||||
cat >expected <<-\EOF &&
|
symlink=$(symlink_oid xyzzy) &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
diff --git a/frotz b/frotz
|
diff --git a/frotz b/frotz
|
||||||
new file mode 120000
|
new file mode 120000
|
||||||
index 0000000..7c465af
|
index 0000000..$symlink
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/frotz
|
+++ b/frotz
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
|
@ -21,7 +34,7 @@ test_expect_success 'diff new symlink and file' '
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
diff --git a/nitfol b/nitfol
|
diff --git a/nitfol b/nitfol
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..7c465af
|
index 0000000..$symlink
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/nitfol
|
+++ b/nitfol
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
|
@ -46,10 +59,10 @@ test_expect_success 'diff unchanged symlink and file' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'diff removed symlink and file' '
|
test_expect_success 'diff removed symlink and file' '
|
||||||
cat >expected <<-\EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/frotz b/frotz
|
diff --git a/frotz b/frotz
|
||||||
deleted file mode 120000
|
deleted file mode 120000
|
||||||
index 7c465af..0000000
|
index $symlink..0000000
|
||||||
--- a/frotz
|
--- a/frotz
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1 +0,0 @@
|
@@ -1 +0,0 @@
|
||||||
|
@ -57,7 +70,7 @@ test_expect_success 'diff removed symlink and file' '
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
diff --git a/nitfol b/nitfol
|
diff --git a/nitfol b/nitfol
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
index 7c465af..0000000
|
index $symlink..0000000
|
||||||
--- a/nitfol
|
--- a/nitfol
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1 +0,0 @@
|
@@ -1 +0,0 @@
|
||||||
|
@ -90,9 +103,10 @@ test_expect_success 'diff identical, but newly created symlink and file' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'diff different symlink and file' '
|
test_expect_success 'diff different symlink and file' '
|
||||||
cat >expected <<-\EOF &&
|
new=$(symlink_oid yxyyz) &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
diff --git a/frotz b/frotz
|
diff --git a/frotz b/frotz
|
||||||
index 7c465af..df1db54 120000
|
index $symlink..$new 120000
|
||||||
--- a/frotz
|
--- a/frotz
|
||||||
+++ b/frotz
|
+++ b/frotz
|
||||||
@@ -1 +1 @@
|
@@ -1 +1 @@
|
||||||
|
@ -101,7 +115,7 @@ test_expect_success 'diff different symlink and file' '
|
||||||
+yxyyz
|
+yxyyz
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
diff --git a/nitfol b/nitfol
|
diff --git a/nitfol b/nitfol
|
||||||
index 7c465af..df1db54 100644
|
index $symlink..$new 100644
|
||||||
--- a/nitfol
|
--- a/nitfol
|
||||||
+++ b/nitfol
|
+++ b/nitfol
|
||||||
@@ -1 +1 @@
|
@@ -1 +1 @@
|
||||||
|
@ -137,14 +151,16 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
|
test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
|
||||||
cat >expect <<-\EOF &&
|
file=$(short_oid file.bin) &&
|
||||||
|
link=$(symlink_oid file.bin) &&
|
||||||
|
cat >expect <<-EOF &&
|
||||||
diff --git a/file.bin b/file.bin
|
diff --git a/file.bin b/file.bin
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..d95f3ad
|
index 0000000..$file
|
||||||
Binary files /dev/null and b/file.bin differ
|
Binary files /dev/null and b/file.bin differ
|
||||||
diff --git a/link.bin b/link.bin
|
diff --git a/link.bin b/link.bin
|
||||||
new file mode 120000
|
new file mode 120000
|
||||||
index 0000000..dce41ec
|
index 0000000..$link
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/link.bin
|
+++ b/link.bin
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
|
|
Loading…
Reference in New Issue