summaryrefslogtreecommitdiff
path: root/t/t4150-am.sh
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-09-02 22:39:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-09-03 22:16:18 (GMT)
commit2c65d90f7579a0e2a6460eebce44795587e87043 (patch)
tree6b51679f6aaf76f1dd2a3eda6d2bdc6ef75928bb /t/t4150-am.sh
parentce17feb1b3ecfb0344af9b9111a4b4d313d51d7a (diff)
downloadgit-2c65d90f7579a0e2a6460eebce44795587e87043.zip
git-2c65d90f7579a0e2a6460eebce44795587e87043.tar.gz
git-2c65d90f7579a0e2a6460eebce44795587e87043.tar.bz2
am: reload .gitattributes after patching it
When applying multiple patches with git am, or when rebasing using the am backend, it's possible that one of our patches has updated a gitattributes file. Currently, we cache this information, so if a file in a subsequent patch has attributes applied, the file will be written out with the attributes in place as of the time we started the rebase or am operation, not with the attributes applied by the previous patch. This problem does not occur when using the -m or -i flags to rebase. To ensure we write the correct data into the working tree, expire the cache after each patch that touches a path ending in ".gitattributes". Since we load these attributes in multiple separate files, we must expire them accordingly. Verify that both the am and rebase code paths work correctly, including the conflict marker size with am -3. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4150-am.sh')
-rwxr-xr-xt/t4150-am.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 3f7f750..4f1e24e 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -1061,4 +1061,56 @@ test_expect_success 'am --quit keeps HEAD where it is' '
test_cmp expected actual
'
+test_expect_success 'am and .gitattibutes' '
+ test_create_repo attributes &&
+ (
+ cd attributes &&
+ test_commit init &&
+ git config filter.test.clean "sed -e '\''s/smudged/clean/g'\''" &&
+ git config filter.test.smudge "sed -e '\''s/clean/smudged/g'\''" &&
+
+ test_commit second &&
+ git checkout -b test HEAD^ &&
+
+ echo "*.txt filter=test conflict-marker-size=10" >.gitattributes &&
+ git add .gitattributes &&
+ test_commit third &&
+
+ echo "This text is smudged." >a.txt &&
+ git add a.txt &&
+ test_commit fourth &&
+
+ git checkout -b removal HEAD^ &&
+ git rm .gitattributes &&
+ git add -u &&
+ test_commit fifth &&
+ git cherry-pick test &&
+
+ git checkout -b conflict third &&
+ echo "This text is different." >a.txt &&
+ git add a.txt &&
+ test_commit sixth &&
+
+ git checkout test &&
+ git format-patch --stdout master..HEAD >patches &&
+ git reset --hard master &&
+ git am patches &&
+ grep "smudged" a.txt &&
+
+ git checkout removal &&
+ git reset --hard &&
+ git format-patch --stdout master..HEAD >patches &&
+ git reset --hard master &&
+ git am patches &&
+ grep "clean" a.txt &&
+
+ git checkout conflict &&
+ git reset --hard &&
+ git format-patch --stdout master..HEAD >patches &&
+ git reset --hard fourth &&
+ test_must_fail git am -3 patches &&
+ grep "<<<<<<<<<<" a.txt
+ )
+'
+
test_done