(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'Test various path utilities'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: norm_path
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:expected)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: (C {<test-path-utils>} {<print_path>} {(DQ ($ Id.VSub_Number '$2'))})
                      )
                    }
                  spids: [31]
                )
              ]
            )
            (C {<test_expect_success>} {($ Id.VSub_Number '$3')} 
              {(DQ <'normalize path: '> ($ Id.VSub_Number '$1') <' => '> ($ Id.VSub_Number '$2'))} 
              {
                (DQ <'test '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <'(test-path-utils normalize_path_copy \''> ($ Id.VSub_Number '$1') <'\')'> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' = \''> ($ Id.VSub_DollarName '$expected') <'\''>
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: relative_path
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:expected)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: (C {<test-path-utils>} {<print_path>} {(DQ ($ Id.VSub_Number '$3'))})
                      )
                    }
                  spids: [79]
                )
              ]
            )
            (C {<test_expect_success>} {($ Id.VSub_Number '$4')} 
              {
                (DQ <'relative path: '> ($ Id.VSub_Number '$1') <' '> ($ Id.VSub_Number '$2') <' => '> 
                  ($ Id.VSub_Number '$3')
                )
              } 
              {
                (DQ <'test '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <'(test-path-utils relative_path \''> ($ Id.VSub_Number '$1') <'\' \''> ($ Id.VSub_Number '$2') <'\')'> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' = \''> ($ Id.VSub_DollarName '$expected') <'\''>
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: test_submodule_relative_url
      body: 
        (BraceGroup
          children: [
            (C {<test_expect_success>} 
              {
                (DQ <'test_submodule_relative_url: '> ($ Id.VSub_Number '$1') <' '> 
                  ($ Id.VSub_Number '$2') <' '> ($ Id.VSub_Number '$3') <' => '> ($ Id.VSub_Number '$4')
                )
              } 
              {
                (DQ <'\n'> <'\t\tactual='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) 
                  <'(git submodule--helper resolve-relative-url-test \''> ($ Id.VSub_Number '$1') <'\' \''> ($ Id.VSub_Number '$2') <'\' \''> ($ Id.VSub_Number '$3') <'\') &&\n'> 
                  <'\t\ttest '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <actual> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' = \''> ($ Id.VSub_Number '$4') 
                  <'\'\n'> <'\t'>
                )
              }
            )
          ]
        )
    )
    (command.ShFunction
      name: test_git_path
      body: 
        (BraceGroup
          children: [
            (C {<test_expect_success>} 
              {
                (DQ <'git-path '> ($ Id.VSub_Number '$1') <' '> ($ Id.VSub_Number '$2') <' => '> 
                  ($ Id.VSub_Number '$3')
                )
              } 
              {
                (DQ <'\n'> <'\t\t'> ($ Id.VSub_Number '$1') <' git rev-parse --git-path '> 
                  ($ Id.VSub_Number '$2') <' >actual &&\n'> <'\t\techo '> ($ Id.VSub_Number '$3') <' >expect &&\n'> 
                  <'\t\ttest_cmp expect actual\n'> <'\t'>
                )
              }
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:rootoff)
          op: assign_op.Equal
          rhs: 
            {
              (command_sub
                left_token: <Id.Left_DollarParen '$('>
                child: 
                  (command.Pipeline
                    children: [(C {<test-path-utils>} {<normalize_path_copy>} {<'/'>}) (C {<wc>} {<-c>})]
                    negated: F
                  )
              )
            }
          spids: [213]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Sentence
              child: (C {<test>} {($ Id.VSub_DollarName '$rootoff')} {<Id.Lit_Equals '='>} {<2>})
              terminator: <Id.Op_Semi _>
            )
          ]
          action: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:rootoff)
                  op: assign_op.Equal
                  rhs: (word.Empty)
                  spids: [245]
                )
              ]
            )
          ]
          spids: [231 242]
        )
      ]
      else_action: [
        (command.ShAssignment
          pairs: [
            (assign_pair
              lhs: (sh_lhs_expr.Name name:rootoff)
              op: assign_op.Equal
              rhs: 
                {
                  (word_part.ArithSub
                    anode: 
                      (arith_expr.Binary
                        op_id: Id.Arith_Minus
                        left: {($ Id.VSub_DollarName '$rootoff')}
                        right: {<Id.Lit_Digits 1>}
                      )
                  )
                }
              spids: [253]
            )
          ]
        )
        (command.Case
          to_match: 
            {
              (DQ 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: (C {<test-path-utils>} {<print_path>} {<'/'>})
                )
              )
            }
          arms: [
            (case_arm
              pat_list: [{<Id.Lit_Star '*'> <'/'>}]
              action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rootslash)
                      op: assign_op.Equal
                      rhs: {<1>}
                      spids: [293]
                    )
                  ]
                )
              ]
              spids: [289 291 295 -1]
            )
            (case_arm
              pat_list: [{<Id.Lit_Star '*'>}]
              action: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rootslash)
                      op: assign_op.Equal
                      rhs: {<0>}
                      spids: [301]
                    )
                  ]
                )
              ]
              spids: [298 299 303 -1]
            )
          ]
        )
      ]
    )
    (command.ShFunction
      name: ancestor
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:expected)
                  op: assign_op.Equal
                  rhs: {($ Id.VSub_Number '$3')}
                  spids: [322]
                )
              ]
            )
            (command.If
              arms: [
                (if_arm
                  cond: [
                    (command.Sentence
                      child: 
                        (command.AndOr
                          ops: [Id.Op_DAmp]
                          children: [
                            (C {<test>} {<-n>} {(DQ ($ Id.VSub_DollarName '$rootoff'))})
                            (C {<test>} {(DQ <x> ($ Id.VSub_DollarName '$expected'))} 
                              {<Id.KW_Bang '!'> <Id.Lit_Equals '='>} {<x-1>}
                            )
                          ]
                        )
                      terminator: <Id.Op_Semi _>
                    )
                  ]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:expected)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (word_part.ArithSub
                                anode: 
                                  (arith_expr.Binary
                                    op_id: Id.Arith_Minus
                                    left: {($ Id.VSub_DollarName '$expected')}
                                    right: {($ Id.VSub_DollarName '$rootslash')}
                                  )
                              )
                            }
                          spids: [354]
                        )
                      ]
                    )
                    (command.AndOr
                      ops: [Id.Op_DPipe]
                      children: [
                        (C {<test>} {($ Id.VSub_DollarName '$expected')} {<-lt>} {<0>})
                        (command.ShAssignment
                          pairs: [
                            (assign_pair
                              lhs: (sh_lhs_expr.Name name:expected)
                              op: assign_op.Equal
                              rhs: 
                                {
                                  (word_part.ArithSub
                                    anode: 
                                      (arith_expr.Binary
                                        op_id: Id.Arith_Plus
                                        left: {($ Id.VSub_DollarName '$expected')}
                                        right: {($ Id.VSub_DollarName '$rootoff')}
                                      )
                                  )
                                }
                              spids: [374]
                            )
                          ]
                        )
                      ]
                    )
                  ]
                  spids: [326 351]
                )
              ]
            )
            (C {<test_expect_success>} 
              {
                (DQ <'longest ancestor: '> ($ Id.VSub_Number '$1') <' '> ($ Id.VSub_Number '$2') <' => '> 
                  ($ Id.VSub_DollarName '$expected')
                )
              } 
              {
                (DQ <'actual='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) 
                  <'(test-path-utils longest_ancestor_length \''> ($ Id.VSub_Number '$1') <'\' \''> ($ Id.VSub_Number '$2') <'\') &&\n'> <'\t test '> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <actual> 
                  (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' = \''> ($ Id.VSub_DollarName '$expected') <'\''>
                )
              }
            )
          ]
        )
    )
    (command.Case
      to_match: {(command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<uname>} {<-s>}))}
      arms: [
        (case_arm
          pat_list: [{<Id.Lit_Star '*'> <MINGW> <Id.Lit_Star '*'>}]
          spids: [436 439 442 -1]
        )
        (case_arm
          pat_list: [{<Id.Lit_Star '*'>}]
          action: [(C {<test_set_prereq>} {<POSIX>})]
          spids: [444 445 453 -1]
        )
      ]
    )
    (C {<test_expect_success>} {<basename>} {(SQ <'test-path-utils basename'>)})
    (C {<test_expect_success>} {<dirname>} {(SQ <'test-path-utils dirname'>)})
    (C {<norm_path>} {(DQ )} {(DQ )})
    (C {<norm_path>} {<.>} {(DQ )})
    (C {<norm_path>} {<'./'>} {(DQ )})
    (C {<norm_path>} {<'./.'>} {(DQ )})
    (C {<norm_path>} {<'./..'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>}
    )
    (C {<norm_path>} {<'../.'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>}
    )
    (C {<norm_path>} {<'./.././/'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>}
    )
    (C {<norm_path>} {<'dir/..'>} {(DQ )})
    (C {<norm_path>} {<'dir/sub/../..'>} {(DQ )})
    (C {<norm_path>} {<'dir/sub/../../..'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>}
    )
    (C {<norm_path>} {<dir>} {<dir>})
    (C {<norm_path>} {<'dir//'>} {<'dir/'>})
    (C {<norm_path>} {<'./dir'>} {<dir>})
    (C {<norm_path>} {<'dir/.'>} {<'dir/'>})
    (C {<norm_path>} {<'dir///./'>} {<'dir/'>})
    (C {<norm_path>} {<'dir//sub/..'>} {<'dir/'>})
    (C {<norm_path>} {<'dir/sub/../'>} {<'dir/'>})
    (C {<norm_path>} {<'dir/sub/../.'>} {<'dir/'>})
    (C {<norm_path>} {<'dir/s1/../s2/'>} {<'dir/s2/'>})
    (C {<norm_path>} {<'d1/s1///s2/..//../s3/'>} {<'d1/s3/'>})
    (C {<norm_path>} {<'d1/s1//../s2/../../d2'>} {<d2>})
    (C {<norm_path>} {<'d1/.../d2'>} {<'d1/.../d2'>})
    (C {<norm_path>} {<'d1/..././../d2'>} {<'d1/d2'>})
    (C {<norm_path>} {<'/'>} {<'/'>})
    (C {<norm_path>} {<'//'>} {<'/'>} {<POSIX>})
    (C {<norm_path>} {<'///'>} {<'/'>} {<POSIX>})
    (C {<norm_path>} {<'/.'>} {<'/'>})
    (C {<norm_path>} {<'/./'>} {<'/'>} {<POSIX>})
    (C {<norm_path>} {<'/./..'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>} {<POSIX>}
    )
    (C {<norm_path>} {<'/../.'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>}
    )
    (C {<norm_path>} {<'/./.././/'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>} {<POSIX>}
    )
    (C {<norm_path>} {<'/dir/..'>} {<'/'>} {<POSIX>})
    (C {<norm_path>} {<'/dir/sub/../..'>} {<'/'>} {<POSIX>})
    (C {<norm_path>} {<'/dir/sub/../../..'>} 
      {<Id.Lit_Other '+'> <Id.Lit_Other '+'> <failed> <Id.Lit_Other '+'> <Id.Lit_Other '+'>} {<POSIX>}
    )
    (C {<norm_path>} {<'/dir'>} {<'/dir'>})
    (C {<norm_path>} {<'/dir//'>} {<'/dir/'>})
    (C {<norm_path>} {<'/./dir'>} {<'/dir'>})
    (C {<norm_path>} {<'/dir/.'>} {<'/dir/'>})
    (C {<norm_path>} {<'/dir///./'>} {<'/dir/'>})
    (C {<norm_path>} {<'/dir//sub/..'>} {<'/dir/'>})
    (C {<norm_path>} {<'/dir/sub/../'>} {<'/dir/'>})
    (C {<norm_path>} {<'//dir/sub/../.'>} {<'/dir/'>} {<POSIX>})
    (C {<norm_path>} {<'/dir/s1/../s2/'>} {<'/dir/s2/'>})
    (C {<norm_path>} {<'/d1/s1///s2/..//../s3/'>} {<'/d1/s3/'>})
    (C {<norm_path>} {<'/d1/s1//../s2/../../d2'>} {<'/d2'>})
    (C {<norm_path>} {<'/d1/.../d2'>} {<'/d1/.../d2'>})
    (C {<norm_path>} {<'/d1/..././../d2'>} {<'/d1/d2'>})
    (C {<ancestor>} {<'/'>} {<'/'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/'>} {<0>})
    (C {<ancestor>} {<'/foo'>} {<'/fo'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/foo'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/bar'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/foo/bar'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/foo'> <Id.Lit_Colon ':'> <'/bar'>} {<-1>})
    (C {<ancestor>} {<'/foo'>} {<'/'> <Id.Lit_Colon ':'> <'/foo'> <Id.Lit_Colon ':'> <'/bar'>} {<0>})
    (C {<ancestor>} {<'/foo'>} {<'/foo'> <Id.Lit_Colon ':'> <'/'> <Id.Lit_Colon ':'> <'/bar'>} {<0>})
    (C {<ancestor>} {<'/foo'>} {<'/'> <Id.Lit_Colon ':'> <'/bar'> <Id.Lit_Colon ':'> <'/foo'>} {<0>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/'>} {<0>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/fo'>} {<-1>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo/ba'>} {<-1>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/'> <Id.Lit_Colon ':'> <'/fo'>} {<0>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'> <Id.Lit_Colon ':'> <'/foo/ba'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/bar'>} {<-1>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/fo'>} {<-1>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'> <Id.Lit_Colon ':'> <'/bar'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/'> <Id.Lit_Colon ':'> <'/foo'> <Id.Lit_Colon ':'> <'/bar'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'> <Id.Lit_Colon ':'> <'/'> <Id.Lit_Colon ':'> <'/bar'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/'> <Id.Lit_Colon ':'> <'/bar'> <Id.Lit_Colon ':'> <'/fo'>} {<0>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/'> <Id.Lit_Colon ':'> <'/bar'>} {<0>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/foo'> <Id.Lit_Colon ':'> <'/bar'>} {<4>})
    (C {<ancestor>} {<'/foo/bar'>} {<'/bar'>} {<-1>})
    (C {<test_expect_success>} {(SQ <strip_path_suffix>)} 
      {
        (SQ <'\n'> <'\ttest c:/msysgit = $(test-path-utils strip_path_suffix \\\n'> 
          <'\t\tc:/msysgit/libexec//git-core libexec/git-core)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'absolute path rejects the empty string'>)} 
      {(SQ <'\n'> <'\ttest_must_fail test-path-utils absolute_path ""\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'real path rejects the empty string'>)} 
      {(SQ <'\n'> <'\ttest_must_fail test-path-utils real_path ""\n'>)}
    )
    (C {<test_expect_success>} {<POSIX>} {(SQ <'real path works on absolute paths 1'>)} 
      {
        (SQ <'\n'> <'\tnopath="hopefully-absent-path" &&\n'> 
          <'\ttest "/" = "$(test-path-utils real_path "/")" &&\n'> <'\ttest "/$nopath" = "$(test-path-utils real_path "/$nopath")"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'real path works on absolute paths 2'>)} 
      {
        (SQ <'\n'> <'\tnopath="hopefully-absent-path" &&\n'> 
          <'\t# Find an existing top-level directory for the remaining tests:\n'> <'\td=$(pwd -P | sed -e "s|^\\([^/]*/[^/]*\\)/.*|\\1|") &&\n'> 
          <'\ttest "$d" = "$(test-path-utils real_path "$d")" &&\n'> <'\ttest "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"\n'>
        )
      }
    )
    (C {<test_expect_success>} {<POSIX>} {(SQ <'real path removes extra leading slashes'>)} 
      {
        (SQ <'\n'> <'\tnopath="hopefully-absent-path" &&\n'> 
          <'\ttest "/" = "$(test-path-utils real_path "///")" &&\n'> <'\ttest "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&\n'> 
          <'\t# Find an existing top-level directory for the remaining tests:\n'> <'\td=$(pwd -P | sed -e "s|^\\([^/]*/[^/]*\\)/.*|\\1|") &&\n'> 
          <'\ttest "$d" = "$(test-path-utils real_path "//$d")" &&\n'> <'\ttest "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'real path removes other extra slashes'>)} 
      {
        (SQ <'\n'> <'\tnopath="hopefully-absent-path" &&\n'> 
          <'\t# Find an existing top-level directory for the remaining tests:\n'> <'\td=$(pwd -P | sed -e "s|^\\([^/]*/[^/]*\\)/.*|\\1|") &&\n'> 
          <'\ttest "$d" = "$(test-path-utils real_path "$d///")" &&\n'> <'\ttest "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS>} {(SQ <'real path works on symlinks'>)} 
      {
        (SQ <'\n'> <'\tmkdir first &&\n'> <'\tln -s ../.git first/.git &&\n'> <'\tmkdir second &&\n'> 
          <'\tln -s ../first second/other &&\n'> <'\tmkdir third &&\n'> <'\tdir="$(cd .git; pwd -P)" &&\n'> <'\tdir2=third/../second/other/.git &&\n'> 
          <'\ttest "$dir" = "$(test-path-utils real_path $dir2)" &&\n'> <'\tfile="$dir"/index &&\n'> <'\ttest "$file" = "$(test-path-utils real_path $dir2/index)" &&\n'> 
          <'\tbasename=blub &&\n'> <'\ttest "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" &&\n'> 
          <'\tln -s ../first/file .git/syml &&\n'> <'\tsym="$(cd first; pwd -P)"/file &&\n'> 
          <'\ttest "$sym" = "$(test-path-utils real_path "$dir2/syml")"\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS>} 
      {(SQ <'prefix_path works with absolute paths to work tree symlinks'>)} 
      {
        (SQ <'\n'> <'\tln -s target symlink &&\n'> 
          <'\ttest "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'prefix_path works with only absolute path to work tree'>)} 
      {
        (SQ <'\n'> <'\techo "" >expected &&\n'> 
          <'\ttest-path-utils prefix_path prefix "$(pwd)" >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'prefix_path rejects absolute path to dir with same beginning as work tree'>)} {(SQ <'\n'> <'\ttest_must_fail test-path-utils prefix_path prefix "$(pwd)a"\n'>)}
    )
    (C {<test_expect_success>} {<SYMLINKS>} 
      {
        (SQ 
          <
'prefix_path works with absolute path to a symlink to work tree having  same beginning as work tree'
          >
        )
      } 
      {
        (SQ <'\n'> <'\tgit init repo &&\n'> <'\tln -s repo repolink &&\n'> 
          <
'\ttest "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"\n'
          >
        )
      }
    )
    (C {<relative_path>} {<'/foo/a/b/c/'>} {<'/foo/a/b/'>} {<'c/'>})
    (C {<relative_path>} {<'/foo/a/b/c/'>} {<'/foo/a/b'>} {<'c/'>})
    (C {<relative_path>} {<'/foo/a//b//c/'>} {<'///foo/a/b//'>} {<'c/'>} {<POSIX>})
    (C {<relative_path>} {<'/foo/a/b'>} {<'/foo/a/b'>} {<'./'>})
    (C {<relative_path>} {<'/foo/a/b/'>} {<'/foo/a/b'>} {<'./'>})
    (C {<relative_path>} {<'/foo/a'>} {<'/foo/a/b'>} {<'../'>})
    (C {<relative_path>} {<'/'>} {<'/foo/a/b/'>} {<'../../../'>})
    (C {<relative_path>} {<'/foo/a/c'>} {<'/foo/a/b/'>} {<'../c'>})
    (C {<relative_path>} {<'/foo/a/c'>} {<'/foo/a/b'>} {<'../c'>})
    (C {<relative_path>} {<'/foo/x/y'>} {<'/foo/a/b/'>} {<'../../x/y'>})
    (C {<relative_path>} {<'/foo/a/b'>} {(DQ <'<empty>'>)} {<'/foo/a/b'>})
    (C {<relative_path>} {<'/foo/a/b'>} {(DQ <'<null>'>)} {<'/foo/a/b'>})
    (C {<relative_path>} {<'foo/a/b/c/'>} {<'foo/a/b/'>} {<'c/'>})
    (C {<relative_path>} {<'foo/a/b/c/'>} {<'foo/a/b'>} {<'c/'>})
    (C {<relative_path>} {<'foo/a/b//c'>} {<'foo/a//b'>} {<c>})
    (C {<relative_path>} {<'foo/a/b/'>} {<'foo/a/b/'>} {<'./'>})
    (C {<relative_path>} {<'foo/a/b/'>} {<'foo/a/b'>} {<'./'>})
    (C {<relative_path>} {<'foo/a'>} {<'foo/a/b'>} {<'../'>})
    (C {<relative_path>} {<'foo/x/y'>} {<'foo/a/b'>} {<'../../x/y'>})
    (C {<relative_path>} {<'foo/a/c'>} {<'foo/a/b'>} {<'../c'>})
    (C {<relative_path>} {<'foo/a/b'>} {<'/foo/x/y'>} {<'foo/a/b'>})
    (C {<relative_path>} {<'/foo/a/b'>} {<'foo/x/y'>} {<'/foo/a/b'>})
    (C {<relative_path>} {<d> <Id.Lit_Colon ':'> <'/a/b'>} {<D> <Id.Lit_Colon ':'> <'/a/c'>} {<'../b'>} 
      {<MINGW>}
    )
    (C {<relative_path>} {<C> <Id.Lit_Colon ':'> <'/a/b'>} {<D> <Id.Lit_Colon ':'> <'/a/c'>} 
      {<C> <Id.Lit_Colon ':'> <'/a/b'>} {<MINGW>}
    )
    (C {<relative_path>} {<'foo/a/b'>} {(DQ <'<empty>'>)} {<'foo/a/b'>})
    (C {<relative_path>} {<'foo/a/b'>} {(DQ <'<null>'>)} {<'foo/a/b'>})
    (C {<relative_path>} {(DQ <'<empty>'>)} {<'/foo/a/b'>} {<'./'>})
    (C {<relative_path>} {(DQ <'<empty>'>)} {(DQ <'<empty>'>)} {<'./'>})
    (C {<relative_path>} {(DQ <'<empty>'>)} {(DQ <'<null>'>)} {<'./'>})
    (C {<relative_path>} {(DQ <'<null>'>)} {(DQ <'<empty>'>)} {<'./'>})
    (C {<relative_path>} {(DQ <'<null>'>)} {(DQ <'<null>'>)} {<'./'>})
    (C {<relative_path>} {(DQ <'<null>'>)} {<'/foo/a/b'>} {<'./'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'A='> <B>} {<'info/grafts'>} {<'.git/info/grafts'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_GRAFT_FILE='> <foo>} {<'info/grafts'>} {<foo>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_GRAFT_FILE='> <foo>} {<'info/////grafts'>} {<foo>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_INDEX_FILE='> <foo>} {<index>} {<foo>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_INDEX_FILE='> <foo>} {<'index/foo'>} {<'.git/index/foo'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_INDEX_FILE='> <foo>} {<index2>} {<'.git/index2'>})
    (C {<test_expect_success>} {(SQ <'setup fake objects directory foo'>)} {(SQ <'mkdir foo'>)})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_OBJECT_DIRECTORY='> <foo>} {<objects>} {<foo>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_OBJECT_DIRECTORY='> <foo>} {<'objects/foo'>} {<'foo/foo'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_OBJECT_DIRECTORY='> <foo>} {<objects2>} 
      {<'.git/objects2'>}
    )
    (C {<test_expect_success>} {(SQ <'setup common repository'>)} {(SQ <'git --git-dir=bar init'>)})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<index>} {<'.git/index'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<HEAD>} {<'.git/HEAD'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/HEAD'>} {<'.git/logs/HEAD'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/refs/bisect/foo'>} 
      {<'.git/logs/refs/bisect/foo'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/refs/bisec/foo'>} 
      {<'bar/logs/refs/bisec/foo'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/refs/bisec'>} 
      {<'bar/logs/refs/bisec'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/refs/bisectfoo'>} 
      {<'bar/logs/refs/bisectfoo'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<objects>} {<'bar/objects'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'objects/bar'>} 
      {<'bar/objects/bar'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'info/exclude'>} 
      {<'bar/info/exclude'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'info/grafts'>} 
      {<'bar/info/grafts'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'info/sparse-checkout'>} 
      {<'.git/info/sparse-checkout'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'info//sparse-checkout'>} 
      {<'.git/info//sparse-checkout'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'remotes/bar'>} 
      {<'bar/remotes/bar'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'branches/bar'>} 
      {<'bar/branches/bar'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'logs/refs/heads/master'>} 
      {<'bar/logs/refs/heads/master'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'refs/heads/master'>} 
      {<'bar/refs/heads/master'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'refs/bisect/foo'>} 
      {<'.git/refs/bisect/foo'>}
    )
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<'hooks/me'>} {<'bar/hooks/me'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<config>} {<'bar/config'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<packed-refs>} {<'bar/packed-refs'>})
    (C {<test_git_path>} {<Id.Lit_VarLike 'GIT_COMMON_DIR='> <bar>} {<shallow>} {<'bar/shallow'>})
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'../foo'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../../submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'../foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'../foo/submodule'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'./foo'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'./foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../../../'>)} {(DQ <'../foo/bar'>)} {(DQ <'../sub/a/b/c'>)} 
      {(DQ <'../../../../foo/sub/a/b/c'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/addtest'>)} {(DQ <'../repo'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/repo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <'foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'../'>)} {(DQ <foo>)} {(DQ <'../submodule'>)} 
      {(DQ <'../submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo/bar'>)} {(DQ <'../sub/a/b/c'>)} 
      {(DQ <'../foo/sub/a/b/c'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo/bar'>)} {(DQ <'../sub/a/b/c/'>)} 
      {(DQ <'../foo/sub/a/b/c'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo/bar/'>)} {(DQ <'../sub/a/b/c'>)} 
      {(DQ <'../foo/sub/a/b/c'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo/submodule'>)} 
      {(DQ <'../submodule'>)} {(DQ <'../foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'../foo'>)} {(DQ <'../submodule'>)} 
      {(DQ <'../submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'./foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'./foo'>)} {(DQ <'../submodule'>)} 
      {(DQ <submodule>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'//somewhere else/repo'>)} 
      {(DQ <'../subrepo'>)} {(DQ <'//somewhere else/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/subsuper_update_r'>
        )
      } {(DQ <'../subsubsuper_update_r'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/subsubsuper_update_r'>
        )
      }
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/super_update_r2'>)
      } {(DQ <'../subsuper_update_r'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/subsuper_update_r'>
        )
      }
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/.'>)} {(DQ <'../.'>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/.'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})))} {(DQ <'./.'>)} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/.'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/addtest'>)} {(DQ <'../repo'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/repo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})))} {(DQ <'./å äö'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/å äö'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/.'>)} {(DQ <'../submodule'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/submodule'>)} {(DQ <'../submodule'>)} 
      {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/home2/../remote'>)
      } {(DQ <'../bundle1'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/home2/../bundle1'>
        )
      }
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/submodule_update_repo'>
        )
      } {(DQ <'./.'>)} 
      {
        (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) 
          <'/submodule_update_repo/.'>
        )
      }
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'file:///tmp/repo'>)} {(DQ <'../subrepo'>)} 
      {(DQ <'file:///tmp/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'foo/bar'>)} {(DQ <'../submodule'>)} 
      {(DQ <'foo/submodule'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <foo>)} {(DQ <'../submodule'>)} 
      {(DQ <submodule>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'helper:://hostname/repo'>)} 
      {(DQ <'../subrepo'>)} {(DQ <'helper:://hostname/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'ssh://hostname/repo'>)} 
      {(DQ <'../subrepo'>)} {(DQ <'ssh://hostname/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'ssh://hostname:22/repo'>)} 
      {(DQ <'../subrepo'>)} {(DQ <'ssh://hostname:22/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'user@host:path/to/repo'>)} 
      {(DQ <'../subrepo'>)} {(DQ <'user@host:path/to/subrepo'>)}
    )
    (C {<test_submodule_relative_url>} {(DQ <'(null)'>)} {(DQ <'user@host:repo'>)} {(DQ <'../subrepo'>)} 
      {(DQ <'user@host:subrepo'>)}
    )
    (C {<test_done>})
  ]
)