|
721 | 721 | '
|
722 | 722 | done
|
723 | 723 |
|
| 724 | +# Test fsmonitor interaction with submodules. |
| 725 | +# |
| 726 | +# If we start the daemon in the super, it will see FS events for |
| 727 | +# everything in the working directory cone and this includes any |
| 728 | +# files/directories contained *within* the submodules. |
| 729 | +# |
| 730 | +# A `git status` at top level will get events for items within the |
| 731 | +# submodule and ignore them, since they aren't named in the index |
| 732 | +# of the super repo. This makes the fsmonitor response a little |
| 733 | +# noisy, but it doesn't alter the correctness of the state of the |
| 734 | +# super-proper. |
| 735 | +# |
| 736 | +# When we have submodules, `git status` normally does a recursive |
| 737 | +# status on each of the submodules and adds a summary row for any |
| 738 | +# dirty submodules. (See the "S..." bits in porcelain V2 output.) |
| 739 | +# |
| 740 | +# It is therefore important that the top level status not be tricked |
| 741 | +# by the FSMonitor response to skip those recursive calls. |
| 742 | + |
| 743 | +my_match_and_clean () { |
| 744 | + git -C super --no-optional-locks status --porcelain=v2 >actual.with && |
| 745 | + git -C super --no-optional-locks -c core.fsmonitor=false \ |
| 746 | + status --porcelain=v2 >actual.without && |
| 747 | + test_cmp actual.with actual.without && |
| 748 | + |
| 749 | + git -C super/dir_1/dir_2/sub reset --hard && |
| 750 | + git -C super/dir_1/dir_2/sub clean -d -f |
| 751 | +} |
| 752 | + |
| 753 | +test_expect_success "Submodule" ' |
| 754 | + test_when_finished "git -C super fsmonitor--daemon stop" && |
| 755 | +
|
| 756 | + git init "super" && |
| 757 | + echo x >super/file_1 && |
| 758 | + echo y >super/file_2 && |
| 759 | + echo z >super/file_3 && |
| 760 | + mkdir super/dir_1 && |
| 761 | + echo a >super/dir_1/file_11 && |
| 762 | + echo b >super/dir_1/file_12 && |
| 763 | + mkdir super/dir_1/dir_2 && |
| 764 | + echo a >super/dir_1/dir_2/file_21 && |
| 765 | + echo b >super/dir_1/dir_2/file_22 && |
| 766 | + git -C super add . && |
| 767 | + git -C super commit -m "initial super commit" && |
| 768 | +
|
| 769 | + git init "sub" && |
| 770 | + echo x >sub/file_x && |
| 771 | + echo y >sub/file_y && |
| 772 | + echo z >sub/file_z && |
| 773 | + mkdir sub/dir_x && |
| 774 | + echo a >sub/dir_x/file_a && |
| 775 | + echo b >sub/dir_x/file_b && |
| 776 | + mkdir sub/dir_x/dir_y && |
| 777 | + echo a >sub/dir_x/dir_y/file_a && |
| 778 | + echo b >sub/dir_x/dir_y/file_b && |
| 779 | + git -C sub add . && |
| 780 | + git -C sub commit -m "initial sub commit" && |
| 781 | +
|
| 782 | + git -C super submodule add ../sub ./dir_1/dir_2/sub && |
| 783 | + git -C super commit -m "add sub" && |
| 784 | +
|
| 785 | + start_daemon -C super && |
| 786 | + git -C super config core.fsmonitor true && |
| 787 | + git -C super update-index --fsmonitor && |
| 788 | + git -C super status && |
| 789 | +
|
| 790 | + # Now run pairs of commands w/ and w/o FSMonitor while we make |
| 791 | + # some dirt in the submodule and confirm matching output. |
| 792 | +
|
| 793 | + # Completely clean status. |
| 794 | + my_match_and_clean && |
| 795 | +
|
| 796 | + # .M S..U |
| 797 | + echo z >super/dir_1/dir_2/sub/dir_x/dir_y/foobar_u && |
| 798 | + my_match_and_clean && |
| 799 | +
|
| 800 | + # .M S.M. |
| 801 | + echo z >super/dir_1/dir_2/sub/dir_x/dir_y/foobar_m && |
| 802 | + git -C super/dir_1/dir_2/sub add . && |
| 803 | + my_match_and_clean && |
| 804 | +
|
| 805 | + # .M S.M. |
| 806 | + echo z >>super/dir_1/dir_2/sub/dir_x/dir_y/file_a && |
| 807 | + git -C super/dir_1/dir_2/sub add . && |
| 808 | + my_match_and_clean && |
| 809 | +
|
| 810 | + # .M SC.. |
| 811 | + echo z >>super/dir_1/dir_2/sub/dir_x/dir_y/file_a && |
| 812 | + git -C super/dir_1/dir_2/sub add . && |
| 813 | + git -C super/dir_1/dir_2/sub commit -m "SC.." && |
| 814 | + my_match_and_clean |
| 815 | +' |
| 816 | + |
724 | 817 | test_done
|
0 commit comments