@matheusbsbs / matheus-bagliano / commits / 555b96abde
Fork 0

t1510: setup case #6

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 26, 2010 at 22:32 UTC 555b96abdeb66c2f193219489c148a0169080c89
1 file changed +291
t/t1510-repo-setup.sh
+291
@@ -580,4 +580,295 @@ EOF
580 test_repo 5/sub
581 '
582
583 +#
584 +# case #6
585 +#
586 +############################################################
587 +#
588 +# Input:
589 +#
590 +# - GIT_WORK_TREE is not set
591 +# - GIT_DIR is set
592 +# - core.worktree is set
593 +# - .git is a directory
594 +# - core.bare is not set, cwd is outside .git
595 +#
596 +# Output:
597 +#
598 +# - worktree is at core.worktree
599 +# - cwd is at worktree root
600 +# - prefix is calculated
601 +# - git_dir is at $GIT_DIR
602 +# - cwd can be outside worktree
603 +
604 +test_expect_success '#6: setup' '
605 + unset GIT_DIR GIT_WORK_TREE &&
606 + mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
607 + cd 6 && git init && cd ..
608 +'
609 +
610 +test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
611 + cat >6/expected <<EOF &&
612 +setup: git_dir: .git
613 +setup: worktree: $TRASH_DIRECTORY/6
614 +setup: cwd: $TRASH_DIRECTORY/6
615 +setup: prefix: (null)
616 +EOF
617 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
618 + test_repo 6 .git
619 +'
620 +
621 +test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
622 + cat >6/expected <<EOF &&
623 +setup: git_dir: .git
624 +setup: worktree: $TRASH_DIRECTORY/6
625 +setup: cwd: $TRASH_DIRECTORY/6
626 +setup: prefix: (null)
627 +EOF
628 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
629 + test_repo 6 .git
630 +'
631 +
632 +test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
633 + cat >6/expected <<EOF &&
634 +setup: git_dir: $TRASH_DIRECTORY/6/.git
635 +setup: worktree: $TRASH_DIRECTORY/6
636 +setup: cwd: $TRASH_DIRECTORY/6
637 +setup: prefix: (null)
638 +EOF
639 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
640 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
641 +'
642 +
643 +test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
644 + cat >6/expected <<EOF &&
645 +setup: git_dir: $TRASH_DIRECTORY/6/.git
646 +setup: worktree: $TRASH_DIRECTORY/6
647 +setup: cwd: $TRASH_DIRECTORY/6
648 +setup: prefix: (null)
649 +EOF
650 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
651 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
652 +'
653 +
654 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
655 + cat >6/sub/sub/expected <<EOF &&
656 +setup: git_dir: $TRASH_DIRECTORY/6/.git
657 +setup: worktree: $TRASH_DIRECTORY/6
658 +setup: cwd: $TRASH_DIRECTORY/6
659 +setup: prefix: sub/sub/
660 +EOF
661 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
662 + test_repo 6/sub/sub ../../.git
663 +'
664 +
665 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
666 + cat >6/sub/sub/expected <<EOF &&
667 +setup: git_dir: $TRASH_DIRECTORY/6/.git
668 +setup: worktree: $TRASH_DIRECTORY/6
669 +setup: cwd: $TRASH_DIRECTORY/6
670 +setup: prefix: sub/sub/
671 +EOF
672 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
673 + test_repo 6/sub/sub ../../.git
674 +'
675 +
676 +test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
677 + cat >6/sub/expected <<EOF &&
678 +setup: git_dir: $TRASH_DIRECTORY/6/.git
679 +setup: worktree: $TRASH_DIRECTORY/6
680 +setup: cwd: $TRASH_DIRECTORY/6
681 +setup: prefix: sub/
682 +EOF
683 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
684 + test_repo 6/sub "$TRASH_DIRECTORY/6/.git"
685 +'
686 +
687 +test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
688 + cat >6/sub/sub/expected <<EOF &&
689 +setup: git_dir: $TRASH_DIRECTORY/6/.git
690 +setup: worktree: $TRASH_DIRECTORY/6
691 +setup: cwd: $TRASH_DIRECTORY/6
692 +setup: prefix: sub/sub/
693 +EOF
694 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
695 + test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
696 +'
697 +
698 +test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
699 + cat >6/expected <<EOF &&
700 +setup: git_dir: .git
701 +setup: worktree: $TRASH_DIRECTORY/6/wt
702 +setup: cwd: $TRASH_DIRECTORY/6
703 +setup: prefix: (null)
704 +EOF
705 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
706 + test_repo 6 .git
707 +'
708 +
709 +test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
710 + cat >6/expected <<EOF &&
711 +setup: git_dir: .git
712 +setup: worktree: $TRASH_DIRECTORY/6/wt
713 +setup: cwd: $TRASH_DIRECTORY/6
714 +setup: prefix: (null)
715 +EOF
716 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
717 + test_repo 6 .git
718 +'
719 +
720 +test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
721 + cat >6/expected <<EOF &&
722 +setup: git_dir: $TRASH_DIRECTORY/6/.git
723 +setup: worktree: $TRASH_DIRECTORY/6/wt
724 +setup: cwd: $TRASH_DIRECTORY/6
725 +setup: prefix: (null)
726 +EOF
727 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
728 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
729 +'
730 +
731 +test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
732 + cat >6/expected <<EOF &&
733 +setup: git_dir: $TRASH_DIRECTORY/6/.git
734 +setup: worktree: $TRASH_DIRECTORY/6/wt
735 +setup: cwd: $TRASH_DIRECTORY/6
736 +setup: prefix: (null)
737 +EOF
738 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
739 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
740 +'
741 +
742 +test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
743 + cat >6/sub/sub/expected <<EOF &&
744 +setup: git_dir: ../../.git
745 +setup: worktree: $TRASH_DIRECTORY/6/wt
746 +setup: cwd: $TRASH_DIRECTORY/6/sub/sub
747 +setup: prefix: (null)
748 +EOF
749 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
750 + test_repo 6/sub/sub ../../.git
751 +'
752 +
753 +test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
754 + cat >6/sub/sub/expected <<EOF &&
755 +setup: git_dir: ../../.git
756 +setup: worktree: $TRASH_DIRECTORY/6/wt
757 +setup: cwd: $TRASH_DIRECTORY/6/sub/sub
758 +setup: prefix: (null)
759 +EOF
760 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
761 + test_repo 6/sub/sub ../../.git
762 +'
763 +
764 +test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
765 + cat >6/sub/sub/expected <<EOF &&
766 +setup: git_dir: $TRASH_DIRECTORY/6/.git
767 +setup: worktree: $TRASH_DIRECTORY/6/wt
768 +setup: cwd: $TRASH_DIRECTORY/6/sub/sub
769 +setup: prefix: (null)
770 +EOF
771 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
772 + test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
773 +'
774 +
775 +test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
776 + cat >6/sub/sub/expected <<EOF &&
777 +setup: git_dir: $TRASH_DIRECTORY/6/.git
778 +setup: worktree: $TRASH_DIRECTORY/6/wt
779 +setup: cwd: $TRASH_DIRECTORY/6/sub/sub
780 +setup: prefix: (null)
781 +EOF
782 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
783 + test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
784 +'
785 +
786 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. at root' '
787 + cat >6/expected <<EOF &&
788 +setup: git_dir: $TRASH_DIRECTORY/6/.git
789 +setup: worktree: $TRASH_DIRECTORY
790 +setup: cwd: $TRASH_DIRECTORY
791 +setup: prefix: 6/
792 +EOF
793 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
794 + test_repo 6 .git
795 +'
796 +
797 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
798 + cat >6/expected <<EOF &&
799 +setup: git_dir: $TRASH_DIRECTORY/6/.git
800 +setup: worktree: $TRASH_DIRECTORY
801 +setup: cwd: $TRASH_DIRECTORY
802 +setup: prefix: 6/
803 +EOF
804 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
805 + test_repo 6 .git
806 +'
807 +
808 +test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
809 + cat >6/expected <<EOF &&
810 +setup: git_dir: $TRASH_DIRECTORY/6/.git
811 +setup: worktree: $TRASH_DIRECTORY
812 +setup: cwd: $TRASH_DIRECTORY
813 +setup: prefix: 6/
814 +EOF
815 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
816 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
817 +'
818 +
819 +test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
820 + cat >6/expected <<EOF &&
821 +setup: git_dir: $TRASH_DIRECTORY/6/.git
822 +setup: worktree: $TRASH_DIRECTORY
823 +setup: cwd: $TRASH_DIRECTORY
824 +setup: prefix: 6/
825 +EOF
826 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
827 + test_repo 6 "$TRASH_DIRECTORY/6/.git"
828 +'
829 +
830 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
831 + cat >6/sub/sub/expected <<EOF &&
832 +setup: git_dir: $TRASH_DIRECTORY/6/.git
833 +setup: worktree: $TRASH_DIRECTORY
834 +setup: cwd: $TRASH_DIRECTORY
835 +setup: prefix: 6/sub/sub/
836 +EOF
837 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
838 + test_repo 6/sub/sub ../../.git
839 +'
840 +
841 +test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
842 + cat >6/sub/sub/expected <<EOF &&
843 +setup: git_dir: $TRASH_DIRECTORY/6/.git
844 +setup: worktree: $TRASH_DIRECTORY
845 +setup: cwd: $TRASH_DIRECTORY
846 +setup: prefix: 6/sub/sub/
847 +EOF
848 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
849 + test_repo 6/sub/sub ../../.git
850 +'
851 +
852 +test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
853 + cat >6/sub/sub/expected <<EOF &&
854 +setup: git_dir: $TRASH_DIRECTORY/6/.git
855 +setup: worktree: $TRASH_DIRECTORY
856 +setup: cwd: $TRASH_DIRECTORY
857 +setup: prefix: 6/sub/sub/
858 +EOF
859 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
860 + test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
861 +'
862 +
863 +test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
864 + cat >6/sub/sub/expected <<EOF &&
865 +setup: git_dir: $TRASH_DIRECTORY/6/.git
866 +setup: worktree: $TRASH_DIRECTORY
867 +setup: cwd: $TRASH_DIRECTORY
868 +setup: prefix: 6/sub/sub/
869 +EOF
870 + git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
871 + test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
872 +'
873 +
874 test_done