diff options
author | David Turner <dturner@twosigma.com> | 2017-03-03 13:27:47 -0500 |
---|---|---|
committer | David Turner <dturner@twosigma.com> | 2017-03-03 15:07:54 -0500 |
commit | 2270ca9f8feecf93fe39a02a6fbde90a22c1a665 (patch) | |
tree | a59cc59dd57531769ad70f1cbb47849c7b44c0e3 /tests/rebase | |
parent | 467185ff13d8995724425506a8ec71fc462a4e0d (diff) | |
download | libgit2-2270ca9f8feecf93fe39a02a6fbde90a22c1a665.tar.gz |
rebase: ignore untracked files in submodules
An untracked file in a submodule should not prevent a rebase from
starting. Even if the submodule's SHA is changed, and that file would
conflict with a new tracked file, it's still OK to start the rebase
and discover the conflict later.
Signed-off-by: David Turner <dturner@twosigma.com>
Diffstat (limited to 'tests/rebase')
-rw-r--r-- | tests/rebase/submodule.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/rebase/submodule.c b/tests/rebase/submodule.c new file mode 100644 index 000000000..7a38ab89f --- /dev/null +++ b/tests/rebase/submodule.c @@ -0,0 +1,65 @@ +#include "clar_libgit2.h" +#include "git2/checkout.h" +#include "git2/rebase.h" +#include "posix.h" +#include "signature.h" + +#include <fcntl.h> + +static git_repository *repo; +static git_signature *signature; + +// Fixture setup and teardown +void test_rebase_submodule__initialize(void) +{ + repo = cl_git_sandbox_init("rebase-submodule"); + cl_git_pass(git_signature_new(&signature, + "Rebaser", "rebaser@rebaser.rb", 1405694510, 0)); +} + +void test_rebase_submodule__cleanup(void) +{ + git_signature_free(signature); + cl_git_sandbox_cleanup(); +} + +void test_rebase_submodule__init_untracked(void) +{ + git_rebase *rebase; + git_reference *branch_ref, *upstream_ref; + git_annotated_commit *branch_head, *upstream_head; + git_buf untracked_path = GIT_BUF_INIT; + FILE *fp; + git_submodule *submodule; + git_config *config; + + cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus")); + cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master")); + + cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref)); + cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref)); + + git_repository_config(&config, repo); + + cl_git_pass(git_config_set_string(config, "submodule.my-submodule.url", git_repository_path(repo))); + + git_config_free(config); + + cl_git_pass(git_submodule_lookup(&submodule, repo, "my-submodule")); + cl_git_pass(git_submodule_update(submodule, 1, NULL)); + + git_buf_printf(&untracked_path, "%s/my-submodule/untracked", git_repository_workdir(repo)); + fp = fopen(git_buf_cstr(&untracked_path), "w"); + fprintf(fp, "An untracked file in a submodule should not block a rebase\n"); + fclose(fp); + git_buf_free(&untracked_path); + + cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL)); + + git_submodule_free(submodule); + git_annotated_commit_free(branch_head); + git_annotated_commit_free(upstream_head); + git_reference_free(branch_ref); + git_reference_free(upstream_ref); + git_rebase_free(rebase); +} |