commit - 81c5a344a23a3e14f0d970c5ce29234bcdcb995e
commit + e7303626967ed721dd323a8a6ea6c638aed46c50
blob - c77f4d708ad9d8b4be8f6b2d4f47d197a81ea872
blob + 030ece4e122124a89fa7523bf23c419719dcb231
--- regress/cmdline/add.sh
+++ regress/cmdline/add.sh
(cd $testroot/wt && got add tree2/foo > $testroot/stdout)
echo 'A tree2/foo' > $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_add_clashes_with_submodule {
+ local testroot=`test_init add_clashes_with_submodule`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ # Atttempt to add a file clashes with a submodule
+ echo "This is a file called repo2" > $testroot/wt/repo2
+ (cd $testroot/wt && got add repo2 > /dev/null)
+ (cd $testroot/wt && got status > $testroot/stdout)
+ echo "A repo2" > $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
test_done "$testroot" "$ret"
return 1
fi
+
+ # Update for good measure; see the error below.
+ (cd $testroot/wt && got update > /dev/null)
+
+ # This currently fails with "work tree must be updated"...
+ (cd $testroot/wt && got commit -m 'add file repo2' \
+ > $testroot/stdout 2> $testroot/stderr)
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "commit succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ echo -n "got: work tree must be updated " > $testroot/stderr.expected
+ echo "before these changes can be committed" >> $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ fi
test_done "$testroot" "$ret"
}
run_test test_add_file_in_new_subdir
run_test test_add_deleted
run_test test_add_directory
+run_test test_add_clashes_with_submodule
blob - 33d4c773bd77f62c42b299dd8477a9daa3142ddb
blob + 9e0475af05cac63a02818ca77164c2355cf2428e
--- regress/cmdline/blame.sh
+++ regress/cmdline/blame.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_blame_submodule {
+ local testroot=`test_init blame_submodule`
+ local commit_id0=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ # Attempt a (nonsensical) blame of a submodule.
+ got blame -r $testroot/repo repo2 \
+ > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "blame command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
fi
+ local submodule_id=$(got tree -r $testroot/repo -i | \
+ grep 'repo2\$$' | cut -d ' ' -f1)
+ echo "got: object $submodule_id not found" > $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ fi
test_done "$testroot" "$ret"
}
run_test test_blame_commit_subsumed
run_test test_blame_blame_h
run_test test_blame_added_on_branch
+run_test test_blame_submodule
blob - e94f00225a6d92aed87516ccb71ed5c81a284b32
blob + 3c88697b0b4d38195808b7f3667068dc92dc3b5f
--- regress/cmdline/cat.sh
+++ regress/cmdline/cat.sh
test_done "$testroot" "$ret"
}
+function test_cat_submodule {
+ local testroot=`test_init cat_submodule`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ got cat -r $testroot/repo repo2 > $testroot/stdout \
+ > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "cat command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ local submodule_id=$(got tree -r $testroot/repo -i | \
+ grep 'repo2\$$' | cut -d ' ' -f1)
+ echo "got: object $submodule_id not found" > $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_cat_submodule_of_same_repo {
+ local testroot=`test_init cat_submodule_of_same_repo`
+ local commit_id0=`git_show_head $testroot/repo`
+ local author_time=`git_show_author_time $testroot/repo`
+
+ (cd $testroot && git clone -q repo repo2 >/dev/null)
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ # 'got cat' shows the commit object which the submodule points to
+ # because a commit with the same ID exists in the outer repository
+ got cat -r $testroot/repo $commit_id0 | grep ^tree > $testroot/stdout.expected
+ echo "numparents 0" >> $testroot/stdout.expected
+ echo "author $GOT_AUTHOR $author_time +0000" >> $testroot/stdout.expected
+ echo "committer $GOT_AUTHOR $author_time +0000" \
+ >> $testroot/stdout.expected
+ echo "messagelen 22" >> $testroot/stdout.expected
+ printf "\nadding the test tree\n" >> $testroot/stdout.expected
+
+ got cat -r $testroot/repo repo2 > $testroot/stdout
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+
+ test_done "$testroot" "$ret"
+}
+
run_test test_cat_basic
run_test test_cat_path
+run_test test_cat_submodule
+run_test test_cat_submodule_of_same_repo
blob - 6d3a99a2cce157075a82450a18aaa39d48615932
blob + abba81a65d3c964e736faa7f7c27c92fd429bb1f
--- regress/cmdline/checkout.sh
+++ regress/cmdline/checkout.sh
function test_checkout_ignores_submodules {
local testroot=`test_init checkout_ignores_submodules`
- (cd $testroot && git clone -q repo repo2 >/dev/null)
+ make_single_file_repo $testroot/repo2 foo
+
(cd $testroot/repo && git submodule -q add ../repo2)
(cd $testroot/repo && git commit -q -m 'adding submodule')
blob - 8cca1c73d2210b4fca11501a822a550ddc379362
blob + 15366064a879e3cb8137061a6408c3504af03578
--- regress/cmdline/cherrypick.sh
+++ regress/cmdline/cherrypick.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/content.expected $testroot/wt/alpha
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_cherrypick_modified_submodule {
+ local testroot=`test_init cherrypick_modified_submodules`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ echo "modified foo" > $testroot/repo2/foo
+ (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
+
+ (cd $testroot/repo && git checkout -q -b newbranch)
+ # Update the repo/repo2 submodule link on newbranch
+ (cd $testroot/repo && git -C repo2 pull -q)
+ (cd $testroot/repo && git add repo2)
+ git_commit $testroot/repo -m "modified submodule link"
+ local commit_id=`git_show_head $testroot/repo`
+
+ # This cherrypick is a no-op because Got's file index
+ # does not track submodules.
+ (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
+
+ echo -n > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_cherrypick_added_submodule {
+ local testroot=`test_init cherrypick_added_submodules`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ make_single_file_repo $testroot/repo2 foo
+
+ # Add the repo/repo2 submodule on newbranch
+ (cd $testroot/repo && git checkout -q -b newbranch)
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+ local commit_id=`git_show_head $testroot/repo`
+
+ (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
+
+ echo "A .gitmodules" > $testroot/stdout.expected
+ echo "Merged commit $commit_id" >> $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
fi
test_done "$testroot" "$ret"
}
+function test_cherrypick_conflict_wt_file_vs_repo_submodule {
+ local testroot=`test_init cherrypick_conflict_wt_file_vs_repo_submodule`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ # Add a file which will clash with the submodule
+ echo "This is a file called repo2" > $testroot/wt/repo2
+ (cd $testroot/wt && got add repo2 > /dev/null)
+ (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "commit failed unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ make_single_file_repo $testroot/repo2 foo
+
+ # Add the repo/repo2 submodule on newbranch
+ (cd $testroot/repo && git checkout -q -b newbranch)
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+ local commit_id=`git_show_head $testroot/repo`
+
+ # Modify the clashing file such that any modifications brought
+ # in by 'got cherrypick' would require a merge.
+ echo "This file was changed" > $testroot/wt/repo2
+
+ (cd $testroot/wt && got update >/dev/null)
+ (cd $testroot/wt && got cherrypick $commit_id > $testroot/stdout)
+
+ echo "A .gitmodules" > $testroot/stdout.expected
+ echo "Merged commit $commit_id" >> $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got status > $testroot/stdout)
+
+ echo "A .gitmodules" > $testroot/stdout.expected
+ echo "M repo2" >> $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
run_test test_cherrypick_basic
run_test test_cherrypick_root_commit
run_test test_cherrypick_into_work_tree_with_conflicts
+run_test test_cherrypick_modified_submodule
+run_test test_cherrypick_added_submodule
+run_test test_cherrypick_conflict_wt_file_vs_repo_submodule
blob - aafe14583ef36fe909f7c1ce1608fe5ae98bb5a1
blob + 3c8e833ec7ad8718957fd61f1be12dd5eceabd1f
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
done
if [ "$ret" != "0" ]; then
test_done "$testroot" "$ret"
+ return 1
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_commit_with_unrelated_submodule {
+ local testroot=`test_init commit_with_unrelated_submodule`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "modified alpha" > $testroot/wt/alpha
+
+ # Currently fails with "bad file type" error
+ (cd $testroot/wt && got commit -m 'modify alpha' \
+ > $testroot/stdout 2> $testroot/stderr)
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "commit succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
return 1
fi
+ echo "got: bad file type" > $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ return 1
+ fi
test_done "$testroot" "$ret"
}
run_test test_commit_gitconfig_author
run_test test_commit_xbit_change
run_test test_commit_normalizes_filemodes
+run_test test_commit_with_unrelated_submodule
blob - ff453b223f4e883bf285ec5a0e4e0c465ba3dd3c
blob + 5104375e287f0e845051a912863028d3e6a4d86c
--- regress/cmdline/common.sh
+++ regress/cmdline/common.sh
echo zeta > $repo/epsilon/zeta
}
+function make_single_file_repo
+{
+ repo="$1"
+ file="$2"
+
+ mkdir $repo
+ git_init $repo
+ echo "this is file $file" > $repo/$file
+ (cd $repo && git add .)
+ git_commit $repo -m "intialize $repo with file $file"
+}
+
+function get_loose_object_path
+{
+ local repo="$1"
+ local id="$2"
+ local id0=`trim_obj_id 38 $id`
+ local idrest=`echo ${id#[0-9a-f][0-9a-f]}`
+ echo "$repo/.git/objects/$id0/$idrest"
+}
+
function get_blob_id
{
repo="$1"
blob - 6fb2ea68d14402fd1574c7ba4c85ff2feb11fb8f
blob + a3f99c8779d3bd933ae0f0f14741563fad6794a7
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_diff_submodule_of_same_repo {
+ local testroot=`test_init diff_submodule_of_same_repo`
+
+ (cd $testroot && git clone -q repo repo2 >/dev/null)
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
+ cut -d ' ' -f 1)
+ submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
+ cut -d ' ' -f 1)
+
+ # Attempt a (nonsensical) diff between a tree object and a submodule.
+ # Currently fails with "wrong type of object" error
+ got diff -r $testroot/repo $epsilon_id $submodule_id \
+ > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "diff command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
fi
+ echo "got: wrong type of object" > $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ return 1
+ fi
test_done "$testroot" "$ret"
}
run_test test_diff_tag
run_test test_diff_lightweight_tag
run_test test_diff_ignore_whitespace
+run_test test_diff_submodule_of_same_repo
blob - d88d0fa11e29a8dc0efae3812238dcf959a1891b
blob + c563ee1744ab12c961f2d4a98fcb8a56e3f2df3f
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
echo " A beta" >> $testroot/stdout.expected
echo " A epsilon/zeta" >> $testroot/stdout.expected
echo " A gamma/delta" >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_log_submodule {
+ local testroot=`test_init log_submodule`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+ local head_commit=`git_show_head $testroot/repo`
+
+ echo "commit $head_commit (master)" > $testroot/stdout.expected
+
+ got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo " A .gitmodules" > $testroot/stdout.expected
+
+ got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
+ > $testroot/stdout
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got log -p -r $testroot/repo -l1 repo2 \
+ > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "log command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ local submodule_id=$(got tree -r $testroot/repo -i | \
+ grep 'repo2\$$' | cut -d ' ' -f1)
+ echo "got: object $submodule_id not found" > $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "modified foo" > $testroot/repo2/foo
+ (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
+
+ # Update the repo/repo2 submodule link
+ (cd $testroot/repo && git -C repo2 pull -q)
+ (cd $testroot/repo && git add repo2)
+ git_commit $testroot/repo -m "changed submodule link"
+
+ # log -P does not show the changed submodule path
+ got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "log command failed unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
+
+ echo -n > $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
run_test test_log_reverse_display
run_test test_log_in_worktree_different_repo
run_test test_log_changed_paths
+run_test test_log_submodule
blob - 5a9d63de84c2b6a4ded2565e9eca228c844eeafd
blob + 44be74f368edca7e5c51454b4911ab4fc3a71465
--- regress/cmdline/tree.sh
+++ regress/cmdline/tree.sh
test_done "$testroot" "$ret"
}
+function test_tree_submodule {
+ local testroot=`test_init tree_submodule`
+
+ make_single_file_repo $testroot/repo2 foo
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ local submodule_id=$(got tree -r $testroot/repo -i | \
+ grep 'repo2\$$' | cut -d ' ' -f1)
+ local objpath=`get_loose_object_path $testroot/repo $submodule_id`
+
+ # Currently fails in open(2)
+ got tree -r $testroot/repo repo2 > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "tree command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ echo "got: open: $objpath: No such file or directory" \
+ > $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ return 1
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_tree_submodule_of_same_repo {
+ local testroot=`test_init tree_submodule_of_same_repo`
+
+ (cd $testroot && git clone -q repo repo2 >/dev/null)
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ # Currently fails with "bad object data"
+ got tree -r $testroot/repo repo2 > $testroot/stdout 2> $testroot/stderr
+ ret="$?"
+ if [ "$ret" == "0" ]; then
+ echo "tree command succeeded unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+ echo "got-read-tree: bad object data" > $testroot/stderr.expected
+ echo "got: bad object data" >> $testroot/stderr.expected
+
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ return 1
+ fi
+ test_done "$testroot" "$ret"
+}
+
run_test test_tree_basic
run_test test_tree_branch
+run_test test_tree_submodule
+run_test test_tree_submodule_of_same_repo
blob - 05fd291f00dbf87bd49689c4a514adf28e7a09f8
blob + 60a1a2ab40ff159845a71f43bd69ec3145dfa795
--- regress/cmdline/update.sh
+++ regress/cmdline/update.sh
fi
test_done "$testroot" "$ret"
}
+
+function test_update_modified_submodules {
+ local testroot=`test_init update_modified_submodules`
+
+ make_single_file_repo $testroot/repo2 foo
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ echo "modified foo" > $testroot/repo2/foo
+ (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
+
+ # Update the repo/repo2 submodule link
+ (cd $testroot/repo && git -C repo2 pull -q)
+ (cd $testroot/repo && git add repo2)
+ git_commit $testroot/repo -m "modified submodule link"
+
+ # This update only records the new base commit. Otherwise it is a
+ # no-op change because Got's file index does not track submodules.
+ echo -n "Updated to commit " > $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_update_adds_submodule {
+ local testroot=`test_init update_adds_submodule`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ make_single_file_repo $testroot/repo2 foo
+
+ echo "modified foo" > $testroot/repo2/foo
+ (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ echo "A .gitmodules" > $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_update_conflict_wt_file_vs_repo_submodule {
+ local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+
+ make_single_file_repo $testroot/repo2 foo
+
+ # Add a file which will clash with the submodule
+ echo "This is a file called repo2" > $testroot/wt/repo2
+ (cd $testroot/wt && got add repo2 > /dev/null)
+ (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ echo "commit failed unexpectedly" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ (cd $testroot/repo && git submodule -q add ../repo2)
+ (cd $testroot/repo && git commit -q -m 'adding submodule')
+
+ # Modify the clashing file such that any modifications brought
+ # in by 'got update' would require a merge.
+ echo "This file was changed" > $testroot/wt/repo2
+
+ # No conflict occurs because 'got update' ignores the submodule
+ # and leaves the clashing file as it was.
+ echo "A .gitmodules" > $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ (cd $testroot/wt && got status > $testroot/stdout)
+
+ echo "M repo2" > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+
run_test test_update_basic
run_test test_update_adds_file
run_test test_update_deletes_file
run_test test_update_tag
run_test test_update_toggles_xbit
run_test test_update_preserves_conflicted_file
+run_test test_update_modified_submodules
+run_test test_update_adds_submodule
+run_test test_update_conflict_wt_file_vs_repo_submodule