mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-04 23:57:33 +00:00
Merge pull request #4151 from novalis/dturner/rebase-submodule-untracked
rebase: ignore untracked files in submodules
This commit is contained in:
commit
ffd4df6bf2
@ -546,7 +546,9 @@ static int rebase_ensure_not_dirty(
|
||||
}
|
||||
|
||||
if (check_workdir) {
|
||||
if ((error = git_diff_index_to_workdir(&diff, repo, index, NULL)) < 0)
|
||||
git_diff_options diff_opts = GIT_DIFF_OPTIONS_INIT;
|
||||
diff_opts.ignore_submodules = GIT_SUBMODULE_IGNORE_UNTRACKED;
|
||||
if ((error = git_diff_index_to_workdir(&diff, repo, index, &diff_opts)) < 0)
|
||||
goto done;
|
||||
|
||||
if (git_diff_num_deltas(diff) > 0) {
|
||||
|
65
tests/rebase/submodule.c
Normal file
65
tests/rebase/submodule.c
Normal file
@ -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);
|
||||
}
|
BIN
tests/resources/rebase-submodule/.gitmodules
vendored
Normal file
BIN
tests/resources/rebase-submodule/.gitmodules
vendored
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/HEAD
Normal file
BIN
tests/resources/rebase-submodule/.gitted/HEAD
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/ORIG_HEAD
Normal file
BIN
tests/resources/rebase-submodule/.gitted/ORIG_HEAD
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/config
Normal file
BIN
tests/resources/rebase-submodule/.gitted/config
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/description
Normal file
BIN
tests/resources/rebase-submodule/.gitted/description
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/index
Normal file
BIN
tests/resources/rebase-submodule/.gitted/index
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/info/exclude
Normal file
BIN
tests/resources/rebase-submodule/.gitted/info/exclude
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/info/refs
Normal file
BIN
tests/resources/rebase-submodule/.gitted/info/refs
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/packed-refs
Normal file
BIN
tests/resources/rebase-submodule/.gitted/packed-refs
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/refs/heads/asparagus
Normal file
BIN
tests/resources/rebase-submodule/.gitted/refs/heads/asparagus
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/.gitted/refs/heads/master
Normal file
BIN
tests/resources/rebase-submodule/.gitted/refs/heads/master
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/asparagus.txt
Normal file
BIN
tests/resources/rebase-submodule/asparagus.txt
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/beef.txt
Normal file
BIN
tests/resources/rebase-submodule/beef.txt
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/bouilli.txt
Normal file
BIN
tests/resources/rebase-submodule/bouilli.txt
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/gravy.txt
Normal file
BIN
tests/resources/rebase-submodule/gravy.txt
Normal file
Binary file not shown.
1
tests/resources/rebase-submodule/my-submodule
Submodule
1
tests/resources/rebase-submodule/my-submodule
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit efad0b11c47cb2f0220cbd6f5b0f93bb99064b00
|
BIN
tests/resources/rebase-submodule/oyster.txt
Normal file
BIN
tests/resources/rebase-submodule/oyster.txt
Normal file
Binary file not shown.
BIN
tests/resources/rebase-submodule/veal.txt
Normal file
BIN
tests/resources/rebase-submodule/veal.txt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user