#!/bin/sh global test_description := ''check output directory names used by git-clone'' source ./test-lib.sh # we use a fake ssh wrapper that ignores the arguments # entirely; we really only care that we get _some_ repo, # as the real test is what clone does on the local side test_expect_success 'setup ssh wrapper' ' write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF && git upload-pack "$TRASH_DIRECTORY" EOF GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" && export GIT_SSH && export TRASH_DIRECTORY ' # make sure that cloning $1 results in local directory $2 proc test_clone_dir { global url := $1; shift global dir := $1; shift global expect := 'success' global bare := 'non-bare' global clone_opts := '' for i in [@Argv] { matchstr $i { fail { global expect := 'failure' } bare { global bare := 'bare' global clone_opts := '--bare' } } } test_expect_$expect "clone of $url goes to $dir ($bare)" " rm -rf $dir && git clone $clone_opts $url && test_path_is_dir $dir " } # basic syntax with bare and non-bare variants test_clone_dir host:foo foo test_clone_dir host:foo foo.git bare test_clone_dir host:foo.git foo test_clone_dir host:foo.git foo.git bare test_clone_dir host:foo/.git foo test_clone_dir host:foo/.git foo.git bare # similar, but using ssh URL rather than host:path syntax test_clone_dir ssh://host/foo foo test_clone_dir ssh://host/foo foo.git bare test_clone_dir ssh://host/foo.git foo test_clone_dir ssh://host/foo.git foo.git bare test_clone_dir ssh://host/foo/.git foo test_clone_dir ssh://host/foo/.git foo.git bare # we should remove trailing slashes and .git suffixes test_clone_dir ssh://host/foo/ foo test_clone_dir ssh://host/foo/// foo test_clone_dir ssh://host/foo/.git/ foo test_clone_dir ssh://host/foo.git/ foo test_clone_dir ssh://host/foo.git/// foo test_clone_dir ssh://host/foo///.git/ foo test_clone_dir ssh://host/foo/.git/// foo test_clone_dir host:foo/ foo test_clone_dir host:foo/// foo test_clone_dir host:foo.git/ foo test_clone_dir host:foo/.git/ foo test_clone_dir host:foo.git/// foo test_clone_dir host:foo///.git/ foo test_clone_dir host:foo/.git/// foo # omitting the path should default to the hostname test_clone_dir ssh://host/ host test_clone_dir ssh://host:1234/ host test_clone_dir ssh://user@host/ host test_clone_dir host:/ host # auth materials should be redacted test_clone_dir ssh://user:password@host/ host test_clone_dir ssh://user:password@host:1234/ host test_clone_dir ssh://user:passw@rd@host:1234/ host test_clone_dir user@host:/ host test_clone_dir user:password@host:/ host test_clone_dir user:passw@rd@host:/ host # auth-like material should not be dropped test_clone_dir ssh://host/foo@bar foo@bar test_clone_dir ssh://host/foo@bar.git foo@bar test_clone_dir ssh://user:password@host/foo@bar foo@bar test_clone_dir ssh://user:passw@rd@host/foo@bar.git foo@bar test_clone_dir host:/foo@bar foo@bar test_clone_dir host:/foo@bar.git foo@bar test_clone_dir user:password@host:/foo@bar foo@bar test_clone_dir user:passw@rd@host:/foo@bar.git foo@bar # trailing port-like numbers should not be stripped for paths test_clone_dir ssh://user:password@host/test:1234 1234 test_clone_dir ssh://user:password@host/test:1234.git 1234 test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"check output directory names used by git-clone">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"setup ssh wrapper">)} { (SQ <"\n"> <"\twrite_script \"$TRASH_DIRECTORY/ssh-wrapper\" <<-\\EOF &&\n"> <"\tgit upload-pack \"$TRASH_DIRECTORY\"\n"> <"\tEOF\n"> <"\tGIT_SSH=\"$TRASH_DIRECTORY/ssh-wrapper\" &&\n"> <"\texport GIT_SSH &&\n"> <"\texport TRASH_DIRECTORY\n"> ) } ) (FuncDef name: test_clone_dir body: (BraceGroup children: [ (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:url) op: Equal rhs: {($ VSub_Number "$1")} spids: [51] ) ] spids: [51] ) terminator: ) (C {(shift)}) (Sentence child: (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dir) op: Equal rhs: {($ VSub_Number "$1")} spids: [58] ) ] spids: [58] ) terminator: ) (C {(shift)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:expect) op:Equal rhs:{(success)} spids:[65])] spids: [65] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:bare) op:Equal rhs:{(non-bare)} spids:[69])] spids: [69] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:clone_opts) op:Equal rhs:{(SQ )} spids:[73])] spids: [73] ) (ForEach iter_name: i iter_words: [{(DQ ($ VSub_At "$@"))}] do_arg_iter: False body: (DoGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$i"))} arms: [ (case_arm pat_list: [{(fail)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect) op: Equal rhs: {(failure)} spids: [103] ) ] spids: [103] ) ] spids: [99 100 107 -1] ) (case_arm pat_list: [{(bare)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bare) op: Equal rhs: {(bare)} spids: [114] ) ] spids: [114] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:clone_opts) op: Equal rhs: {(--bare)} spids: [118] ) ] spids: [118] ) ] spids: [110 111 122 -1] ) ] spids: [90 96 125] ) ] spids: [87 128] ) spids: [81 -1] ) (C {(test_expect_) ($ VSub_Name "$expect")} { (DQ ("clone of ") ($ VSub_Name "$url") (" goes to ") ($ VSub_Name "$dir") (" (") ($ VSub_Name "$bare") (")") ) } { (DQ ("\n") ("\t\trm -rf ") ($ VSub_Name "$dir") (" &&\n") ("\t\tgit clone ") ($ VSub_Name "$clone_opts") (" ") ($ VSub_Name "$url") (" &&\n") ("\t\ttest_path_is_dir ") ($ VSub_Name "$dir") ("\n") ("\t") ) } ) ] spids: [48] ) spids: [43 47] ) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo.git)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo.git)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo/.git)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo/.git)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo.git)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo.git)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo/.git)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo/.git)} {(foo.git)} {(bare)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo/)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo///)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo/.git/)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo.git/)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo.git///)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo///.git/)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo/.git///)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo/)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo///)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo.git/)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo/.git/)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo.git///)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo///.git/)} {(foo)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (foo/.git///)} {(foo)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/)} {(host)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host) (Lit_Other ":") (1234/)} {(host)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other "@") (host/)} {(host)}) (C {(test_clone_dir)} {(host) (Lit_Other ":") (/)} {(host)}) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (password) (Lit_Other "@") (host/)} {(host)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (password) (Lit_Other "@") (host) (Lit_Other ":") (1234/) } {(host)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (passw) (Lit_Other "@") (rd) (Lit_Other "@") (host) (Lit_Other ":") (1234/) } {(host)} ) (C {(test_clone_dir)} {(user) (Lit_Other "@") (host) (Lit_Other ":") (/)} {(host)}) (C {(test_clone_dir)} {(user) (Lit_Other ":") (password) (Lit_Other "@") (host) (Lit_Other ":") (/)} {(host)} ) (C {(test_clone_dir)} {(user) (Lit_Other ":") (passw) (Lit_Other "@") (rd) (Lit_Other "@") (host) (Lit_Other ":") (/)} {(host)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo) (Lit_Other "@") (bar)} {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//host/foo) (Lit_Other "@") (bar.git)} {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (password) (Lit_Other "@") (host/foo) (Lit_Other "@") (bar) } {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (passw) (Lit_Other "@") (rd) (Lit_Other "@") (host/foo) (Lit_Other "@") (bar.git) } {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(host) (Lit_Other ":") (/foo) (Lit_Other "@") (bar)} {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(host) (Lit_Other ":") (/foo) (Lit_Other "@") (bar.git)} {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(user) (Lit_Other ":") (password) (Lit_Other "@") (host) (Lit_Other ":") (/foo) (Lit_Other "@") (bar) } {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(user) (Lit_Other ":") (passw) (Lit_Other "@") (rd) (Lit_Other "@") (host) (Lit_Other ":") (/foo) (Lit_Other "@") (bar.git) } {(foo) (Lit_Other "@") (bar)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (password) (Lit_Other "@") (host/test) (Lit_Other ":") (1234) } {(1234)} ) (C {(test_clone_dir)} {(ssh) (Lit_Other ":") (//user) (Lit_Other ":") (password) (Lit_Other "@") (host/test) (Lit_Other ":") (1234.git) } {(1234)} ) (C {(test_done)}) ] )