This series makes rebase --am honor the .gitattributes file for
subsequent patches when a patch changes it.
Changes from v3:
* Check for both addition and removal of .gitattributes files.
* Switch from "test_config" to "git config".
Changes from v2:
* Rename has_path_suffix to ends_with_path_components.
Changes from v1:
* Add has_path_suffix in a separate commit.
brian m. carlson (2):
path: add a function to check for path suffix
apply: reload .gitattributes after patching it
apply.c | 7 +++++++
convert.c | 9 ++++++++-
convert.h | 6 ++++++
path.c | 39 ++++++++++++++++++++++++++++++---------
path.h | 3 +++
t/t3400-rebase.sh | 36 ++++++++++++++++++++++++++++++++++++
6 files changed, 90 insertions(+), 10 deletions(-)
Range-diff against v3:
1: 5f4402b38d ! 1: fa825e4b40 apply: reload .gitattributes after patching it
@@ apply.c: static int apply_patch(struct apply_state *state,
*listp = patch;
listp = &patch->next;
+
-+ if (!flush_attributes && patch->new_name &&
-+ ends_with_path_components(patch->new_name,
GITATTRIBUTES_FILE))
++ if ((patch->new_name &&
ends_with_path_components(patch->new_name, GITATTRIBUTES_FILE)) ||
++ (patch->old_name &&
ends_with_path_components(patch->old_name, GITATTRIBUTES_FILE)))
+ flush_attributes = 1;
}
else {
@@ t/t3400-rebase.sh: test_expect_success 'rebase --am and
--show-current-patch' '
+ (
+ cd attributes &&
+ test_commit init &&
-+ test_config filter.test.clean "sed -e
'\''s/smudged/clean/g'\''" &&
-+ test_config filter.test.smudge "sed -e
'\''s/clean/smudged/g'\''" &&
++ 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^ &&
@@ t/t3400-rebase.sh: test_expect_success 'rebase --am and
--show-current-patch' '
+ 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 test &&
+ git rebase master &&
-+ grep "smudged" a.txt
++ grep "smudged" a.txt &&
++
++ git checkout removal &&
++ git reset --hard &&
++ git rebase master &&
++ grep "clean" a.txt
+ )
+'
+