Skip to content

Instantly share code, notes, and snippets.

@max630 max630/mktest.sh
Created Nov 5, 2016

Embed
What would you like to do?
pr3436 vs submodules
#!/bin/sh
set -e
mkdir -p /tmp/pr3436/sub_origin
cd /tmp/pr3436/sub_origin
git init /tmp/pr3436/sub_origin
mkdir subdir
seq 1 10 >subdir/f
git add subdir/f
git commit -m 'subdir/f' -q
mkdir -p /tmp/pr3436/super_main
cd /tmp/pr3436/super_main
git init /tmp/pr3436/super_main
git submodule add /tmp/pr3436/sub_origin sub
cd sub
git worktree add -B master2 /tmp/pr3436/sub_worktree master
//// rest of the file
void test_worktree_worktree__submodule_worktree_open_as_repo(void)
{
git_buf repo_path = GIT_BUF_INIT;
git_repository *repo;
cl_git_pass(git_repository_discover(&repo_path, "/tmp/pr3436/sub_worktree/subdir", 1, NULL));
fprintf(stderr, "discovered: %s\n", repo_path.ptr);
cl_git_pass(git_repository_open(&repo, repo_path.ptr));
fprintf(stderr, "worktree: %s\n", git_repository_workdir(repo));
cl_assert_equal_s(git_repository_workdir(repo), "/tmp/pr3436/sub_worktree");
git_repository_free(repo);
git_buf_free(&repo_path);
}
//// rest of the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.