Commit efc9e670 by Vicent Martí

Merge pull request #1856 from libgit2/cmn/no-orphans

No such thing as an orphan branch
parents 38fba837 605da51a
...@@ -71,7 +71,7 @@ static void show_branch(git_repository *repo, int format) ...@@ -71,7 +71,7 @@ static void show_branch(git_repository *repo, int format)
error = git_repository_head(&head, repo); error = git_repository_head(&head, repo);
if (error == GIT_EORPHANEDHEAD || error == GIT_ENOTFOUND) if (error == GIT_EUNBORNBRANCH || error == GIT_ENOTFOUND)
branch = NULL; branch = NULL;
else if (!error) { else if (!error) {
branch = git_reference_name(head); branch = git_reference_name(head);
......
...@@ -249,7 +249,7 @@ typedef struct git_checkout_opts { ...@@ -249,7 +249,7 @@ typedef struct git_checkout_opts {
* *
* @param repo repository to check out (must be non-bare) * @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL) * @param opts specifies checkout options (may be NULL)
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
* branch, GIT_ERROR otherwise (use giterr_last for information * branch, GIT_ERROR otherwise (use giterr_last for information
* about the error) * about the error)
*/ */
......
...@@ -27,7 +27,7 @@ typedef enum { ...@@ -27,7 +27,7 @@ typedef enum {
GIT_EBUFS = -6, GIT_EBUFS = -6,
GIT_EUSER = -7, GIT_EUSER = -7,
GIT_EBAREREPO = -8, GIT_EBAREREPO = -8,
GIT_EORPHANEDHEAD = -9, GIT_EUNBORNBRANCH = -9,
GIT_EUNMERGED = -10, GIT_EUNMERGED = -10,
GIT_ENONFASTFORWARD = -11, GIT_ENONFASTFORWARD = -11,
GIT_EINVALIDSPEC = -12, GIT_EINVALIDSPEC = -12,
......
...@@ -297,7 +297,7 @@ GIT_EXTERN(int) git_repository_init_ext( ...@@ -297,7 +297,7 @@ GIT_EXTERN(int) git_repository_init_ext(
* @param out pointer to the reference which will be retrieved * @param out pointer to the reference which will be retrieved
* @param repo a repository object * @param repo a repository object
* *
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
* branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise * branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
*/ */
GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo); GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
...@@ -315,16 +315,16 @@ GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo); ...@@ -315,16 +315,16 @@ GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
GIT_EXTERN(int) git_repository_head_detached(git_repository *repo); GIT_EXTERN(int) git_repository_head_detached(git_repository *repo);
/** /**
* Check if the current branch is an orphan * Check if the current branch is unborn
* *
* An orphan branch is one named from HEAD but which doesn't exist in * An unborn branch is one named from HEAD but which doesn't exist in
* the refs namespace, because it doesn't have any commit to point to. * the refs namespace, because it doesn't have any commit to point to.
* *
* @param repo Repo to test * @param repo Repo to test
* @return 1 if the current branch is an orphan, 0 if it's not; error * @return 1 if the current branch is unborn, 0 if it's not; error
* code if there was an error * code if there was an error
*/ */
GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo); GIT_EXTERN(int) git_repository_head_unborn(git_repository *repo);
/** /**
* Check if a repository is empty * Check if a repository is empty
...@@ -611,7 +611,7 @@ GIT_EXTERN(int) git_repository_set_head_detached( ...@@ -611,7 +611,7 @@ GIT_EXTERN(int) git_repository_set_head_detached(
* Otherwise, the HEAD will be detached and point to the peeled Commit. * Otherwise, the HEAD will be detached and point to the peeled Commit.
* *
* @param repo Repository pointer * @param repo Repository pointer
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing * @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
* branch or an error code * branch or an error code
*/ */
GIT_EXTERN(int) git_repository_detach_head( GIT_EXTERN(int) git_repository_detach_head(
......
...@@ -585,7 +585,7 @@ int git_branch_is_head( ...@@ -585,7 +585,7 @@ int git_branch_is_head(
error = git_repository_head(&head, git_reference_owner(branch)); error = git_repository_head(&head, git_reference_owner(branch));
if (error == GIT_EORPHANEDHEAD || error == GIT_ENOTFOUND) if (error == GIT_EUNBORNBRANCH || error == GIT_ENOTFOUND)
return false; return false;
if (error < 0) if (error < 0)
......
...@@ -1232,7 +1232,7 @@ static int checkout_data_init( ...@@ -1232,7 +1232,7 @@ static int checkout_data_init(
error = checkout_lookup_head_tree(&data->opts.baseline, repo); error = checkout_lookup_head_tree(&data->opts.baseline, repo);
if (error == GIT_EORPHANEDHEAD) { if (error == GIT_EUNBORNBRANCH) {
error = 0; error = 0;
giterr_clear(); giterr_clear();
} }
......
...@@ -415,7 +415,7 @@ static bool should_checkout( ...@@ -415,7 +415,7 @@ static bool should_checkout(
if (opts->checkout_strategy == GIT_CHECKOUT_NONE) if (opts->checkout_strategy == GIT_CHECKOUT_NONE)
return false; return false;
return !git_repository_head_orphan(repo); return !git_repository_head_unborn(repo);
} }
static void normalize_options(git_clone_options *dst, const git_clone_options *src, git_repository_init_options *initOptions) static void normalize_options(git_clone_options *dst, const git_clone_options *src, git_repository_init_options *initOptions)
......
...@@ -806,7 +806,7 @@ static int remote_head_for_ref(git_remote_head **out, git_refspec *spec, git_vec ...@@ -806,7 +806,7 @@ static int remote_head_for_ref(git_remote_head **out, git_refspec *spec, git_vec
(!git_reference_is_branch(resolved_ref)) || (!git_reference_is_branch(resolved_ref)) ||
(error = git_branch_upstream(&tracking_ref, resolved_ref)) < 0 || (error = git_branch_upstream(&tracking_ref, resolved_ref)) < 0 ||
(error = git_refspec_transform_l(&remote_name, spec, git_reference_name(tracking_ref))) < 0) { (error = git_refspec_transform_l(&remote_name, spec, git_reference_name(tracking_ref))) < 0) {
/* Not an error if HEAD is orphaned or no tracking branch */ /* Not an error if HEAD is unborn or no tracking branch */
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND)
error = 0; error = 0;
......
...@@ -1451,10 +1451,10 @@ int git_repository_head(git_reference **head_out, git_repository *repo) ...@@ -1451,10 +1451,10 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1); error = git_reference_lookup_resolved(head_out, repo, git_reference_symbolic_target(head), -1);
git_reference_free(head); git_reference_free(head);
return error == GIT_ENOTFOUND ? GIT_EORPHANEDHEAD : error; return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error;
} }
int git_repository_head_orphan(git_repository *repo) int git_repository_head_unborn(git_repository *repo)
{ {
git_reference *ref = NULL; git_reference *ref = NULL;
int error; int error;
...@@ -1462,7 +1462,7 @@ int git_repository_head_orphan(git_repository *repo) ...@@ -1462,7 +1462,7 @@ int git_repository_head_orphan(git_repository *repo)
error = git_repository_head(&ref, repo); error = git_repository_head(&ref, repo);
git_reference_free(ref); git_reference_free(ref);
if (error == GIT_EORPHANEDHEAD) if (error == GIT_EUNBORNBRANCH)
return 1; return 1;
if (error < 0) if (error < 0)
......
...@@ -27,7 +27,7 @@ static int retrieve_head(git_reference **out, git_repository *repo) ...@@ -27,7 +27,7 @@ static int retrieve_head(git_reference **out, git_repository *repo)
{ {
int error = git_repository_head(out, repo); int error = git_repository_head(out, repo);
if (error == GIT_EORPHANEDHEAD) if (error == GIT_EUNBORNBRANCH)
return create_error(error, "You do not have the initial commit yet."); return create_error(error, "You do not have the initial commit yet.");
return error; return error;
......
...@@ -252,7 +252,7 @@ int git_status_list_new( ...@@ -252,7 +252,7 @@ int git_status_list_new(
/* if there is no HEAD, that's okay - we'll make an empty iterator */ /* if there is no HEAD, that's okay - we'll make an empty iterator */
if (((error = git_repository_head_tree(&head, repo)) < 0) && if (((error = git_repository_head_tree(&head, repo)) < 0) &&
error != GIT_ENOTFOUND && error != GIT_EORPHANEDHEAD) { error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) {
git_index_free(index); /* release index */ git_index_free(index); /* release index */
return error; return error;
} }
......
...@@ -1557,7 +1557,7 @@ static void submodule_get_wd_status( ...@@ -1557,7 +1557,7 @@ static void submodule_get_wd_status(
if (ign == GIT_SUBMODULE_IGNORE_NONE) if (ign == GIT_SUBMODULE_IGNORE_NONE)
opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
/* if we don't have an orphaned head, check diff with index */ /* if we don't have an unborn head, check diff with index */
if (git_repository_head_tree(&sm_head, sm_repo) < 0) if (git_repository_head_tree(&sm_head, sm_repo) < 0)
giterr_clear(); giterr_clear();
else { else {
......
...@@ -16,11 +16,11 @@ void test_checkout_head__cleanup(void) ...@@ -16,11 +16,11 @@ void test_checkout_head__cleanup(void)
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
void test_checkout_head__orphaned_head_returns_GIT_EORPHANEDHEAD(void) void test_checkout_head__unborn_head_returns_GIT_EUNBORNBRANCH(void)
{ {
make_head_orphaned(g_repo, NON_EXISTING_HEAD); make_head_unborn(g_repo, NON_EXISTING_HEAD);
cl_assert_equal_i(GIT_EORPHANEDHEAD, git_checkout_head(g_repo, NULL)); cl_assert_equal_i(GIT_EUNBORNBRANCH, git_checkout_head(g_repo, NULL));
} }
void test_checkout_head__with_index_only_tree(void) void test_checkout_head__with_index_only_tree(void)
......
...@@ -44,7 +44,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) ...@@ -44,7 +44,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
g_options.bare = true; g_options.bare = true;
cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options)); cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options));
/* Although the HEAD is orphaned... */ /* Although the HEAD is unborn... */
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, local_name)); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, local_name));
/* ...one can still retrieve the name of the remote tracking reference */ /* ...one can still retrieve the name of the remote tracking reference */
...@@ -59,7 +59,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) ...@@ -59,7 +59,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
cl_assert_equal_s(expected_remote_name, buffer); cl_assert_equal_s(expected_remote_name, buffer);
/* ...even when the remote HEAD is orphaned as well */ /* ...even when the remote HEAD is unborn as well */
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned,
expected_tracked_branch_name)); expected_tracked_branch_name));
} }
......
...@@ -228,7 +228,7 @@ void test_clone_nonetwork__can_checkout_given_branch(void) ...@@ -228,7 +228,7 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
g_options.checkout_branch = "test"; g_options.checkout_branch = "test";
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
cl_assert_equal_i(0, git_repository_head_orphan(g_repo)); cl_assert_equal_i(0, git_repository_head_unborn(g_repo));
cl_git_pass(git_repository_head(&g_ref, g_repo)); cl_git_pass(git_repository_head(&g_ref, g_repo));
cl_assert_equal_s(git_reference_name(g_ref), "refs/heads/test"); cl_assert_equal_s(git_reference_name(g_ref), "refs/heads/test");
......
...@@ -69,7 +69,7 @@ void test_online_clone__empty_repository(void) ...@@ -69,7 +69,7 @@ void test_online_clone__empty_repository(void)
cl_git_pass(git_clone(&g_repo, LIVE_EMPTYREPO_URL, "./foo", &g_options)); cl_git_pass(git_clone(&g_repo, LIVE_EMPTYREPO_URL, "./foo", &g_options));
cl_assert_equal_i(true, git_repository_is_empty(g_repo)); cl_assert_equal_i(true, git_repository_is_empty(g_repo));
cl_assert_equal_i(true, git_repository_head_orphan(g_repo)); cl_assert_equal_i(true, git_repository_head_unborn(g_repo));
cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE)); cl_git_pass(git_reference_lookup(&head, g_repo, GIT_HEAD_FILE));
cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head)); cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
......
...@@ -57,11 +57,11 @@ void test_refs_branches_delete__can_delete_a_branch_even_if_HEAD_is_missing(void ...@@ -57,11 +57,11 @@ void test_refs_branches_delete__can_delete_a_branch_even_if_HEAD_is_missing(void
git_reference_free(branch); git_reference_free(branch);
} }
void test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_orphaned(void) void test_refs_branches_delete__can_delete_a_branch_when_HEAD_is_unborn(void)
{ {
git_reference *branch; git_reference *branch;
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL)); cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
cl_git_pass(git_branch_delete(branch)); cl_git_pass(git_branch_delete(branch));
......
...@@ -26,13 +26,13 @@ void test_refs_branches_ishead__can_tell_if_a_branch_is_pointed_at_by_HEAD(void) ...@@ -26,13 +26,13 @@ void test_refs_branches_ishead__can_tell_if_a_branch_is_pointed_at_by_HEAD(void)
cl_assert_equal_i(true, git_branch_is_head(branch)); cl_assert_equal_i(true, git_branch_is_head(branch));
} }
void test_refs_branches_ishead__can_properly_handle_orphaned_HEAD(void) void test_refs_branches_ishead__can_properly_handle_unborn_HEAD(void)
{ {
git_repository_free(repo); git_repository_free(repo);
repo = cl_git_sandbox_init("testrepo.git"); repo = cl_git_sandbox_init("testrepo.git");
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master"));
......
...@@ -32,20 +32,20 @@ void test_repo_head__head_detached(void) ...@@ -32,20 +32,20 @@ void test_repo_head__head_detached(void)
cl_assert_equal_i(false, git_repository_head_detached(repo)); cl_assert_equal_i(false, git_repository_head_detached(repo));
} }
void test_repo_head__head_orphan(void) void test_repo_head__unborn_head(void)
{ {
git_reference *ref; git_reference *ref;
cl_git_pass(git_repository_head_detached(repo)); cl_git_pass(git_repository_head_detached(repo));
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert(git_repository_head_orphan(repo) == 1); cl_assert(git_repository_head_unborn(repo) == 1);
/* take the repo back to it's original state */ /* take the repo back to it's original state */
cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1)); cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1));
cl_assert(git_repository_head_orphan(repo) == 0); cl_assert(git_repository_head_unborn(repo) == 0);
git_reference_free(ref); git_reference_free(ref);
} }
...@@ -58,7 +58,7 @@ void test_repo_head__set_head_Attaches_HEAD_to_un_unborn_branch_when_the_branch_ ...@@ -58,7 +58,7 @@ void test_repo_head__set_head_Attaches_HEAD_to_un_unborn_branch_when_the_branch_
cl_assert_equal_i(false, git_repository_head_detached(repo)); cl_assert_equal_i(false, git_repository_head_detached(repo));
cl_assert_equal_i(GIT_EORPHANEDHEAD, git_repository_head(&head, repo)); cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_head(&head, repo));
} }
void test_repo_head__set_head_Returns_ENOTFOUND_when_the_reference_doesnt_exist(void) void test_repo_head__set_head_Returns_ENOTFOUND_when_the_reference_doesnt_exist(void)
...@@ -163,20 +163,20 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void ...@@ -163,20 +163,20 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
git_reference_free(head); git_reference_free(head);
} }
void test_repo_head__detaching_an_orphaned_head_returns_GIT_EORPHANEDHEAD(void) void test_repo_head__detaching_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
{ {
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert_equal_i(GIT_EORPHANEDHEAD, git_repository_detach_head(repo)); cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo));
} }
void test_repo_head__retrieving_an_orphaned_head_returns_GIT_EORPHANEDHEAD(void) void test_repo_head__retrieving_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
{ {
git_reference *head; git_reference *head;
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert_equal_i(GIT_EORPHANEDHEAD, git_repository_head(&head, repo)); cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_head(&head, repo));
} }
void test_repo_head__retrieving_a_missing_head_returns_GIT_ENOTFOUND(void) void test_repo_head__retrieving_a_missing_head_returns_GIT_ENOTFOUND(void)
...@@ -188,9 +188,9 @@ void test_repo_head__retrieving_a_missing_head_returns_GIT_ENOTFOUND(void) ...@@ -188,9 +188,9 @@ void test_repo_head__retrieving_a_missing_head_returns_GIT_ENOTFOUND(void)
cl_assert_equal_i(GIT_ENOTFOUND, git_repository_head(&head, repo)); cl_assert_equal_i(GIT_ENOTFOUND, git_repository_head(&head, repo));
} }
void test_repo_head__can_tell_if_an_orphaned_head_is_detached(void) void test_repo_head__can_tell_if_an_unborn_head_is_detached(void)
{ {
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert_equal_i(false, git_repository_head_detached(repo)); cl_assert_equal_i(false, git_repository_head_detached(repo));
} }
...@@ -36,13 +36,13 @@ void test_repo_headtree__can_retrieve_the_root_tree_from_a_non_detached_head(voi ...@@ -36,13 +36,13 @@ void test_repo_headtree__can_retrieve_the_root_tree_from_a_non_detached_head(voi
cl_assert(git_oid_streq(git_tree_id(tree), "az")); cl_assert(git_oid_streq(git_tree_id(tree), "az"));
} }
void test_repo_headtree__when_head_is_orphaned_returns_EORPHANEDHEAD(void) void test_repo_headtree__when_head_is_unborn_returns_EUNBORNBRANCH(void)
{ {
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert_equal_i(true, git_repository_head_orphan(repo)); cl_assert_equal_i(true, git_repository_head_unborn(repo));
cl_assert_equal_i(GIT_EORPHANEDHEAD, git_repository_head_tree(&tree, repo)); cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_head_tree(&tree, repo));
} }
void test_repo_headtree__when_head_is_missing_returns_ENOTFOUND(void) void test_repo_headtree__when_head_is_missing_returns_ENOTFOUND(void)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "repo_helpers.h" #include "repo_helpers.h"
#include "posix.h" #include "posix.h"
void make_head_orphaned(git_repository* repo, const char *target) void make_head_unborn(git_repository* repo, const char *target)
{ {
git_reference *head; git_reference *head;
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
#define NON_EXISTING_HEAD "refs/heads/hide/and/seek" #define NON_EXISTING_HEAD "refs/heads/hide/and/seek"
extern void make_head_orphaned(git_repository* repo, const char *target); extern void make_head_unborn(git_repository* repo, const char *target);
extern void delete_head(git_repository* repo); extern void delete_head(git_repository* repo);
...@@ -95,19 +95,19 @@ void test_reset_soft__cannot_reset_to_a_tag_not_pointing_at_a_commit(void) ...@@ -95,19 +95,19 @@ void test_reset_soft__cannot_reset_to_a_tag_not_pointing_at_a_commit(void)
cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT)); cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
} }
void test_reset_soft__resetting_against_an_orphaned_head_repo_makes_the_head_no_longer_orphaned(void) void test_reset_soft__resetting_against_an_unborn_head_repo_makes_the_head_no_longer_unborn(void)
{ {
git_reference *head; git_reference *head;
retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO); retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
make_head_orphaned(repo, NON_EXISTING_HEAD); make_head_unborn(repo, NON_EXISTING_HEAD);
cl_assert_equal_i(true, git_repository_head_orphan(repo)); cl_assert_equal_i(true, git_repository_head_unborn(repo));
cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT)); cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
cl_assert_equal_i(false, git_repository_head_orphan(repo)); cl_assert_equal_i(false, git_repository_head_unborn(repo));
cl_git_pass(git_reference_lookup(&head, repo, NON_EXISTING_HEAD)); cl_git_pass(git_reference_lookup(&head, repo, NON_EXISTING_HEAD));
cl_assert_equal_i(0, git_oid_streq(git_reference_target(head), KNOWN_COMMIT_IN_BARE_REPO)); cl_assert_equal_i(0, git_oid_streq(git_reference_target(head), KNOWN_COMMIT_IN_BARE_REPO));
......
...@@ -194,7 +194,7 @@ void test_stash_save__cannot_stash_against_an_unborn_branch(void) ...@@ -194,7 +194,7 @@ void test_stash_save__cannot_stash_against_an_unborn_branch(void)
cl_git_pass(git_reference_symbolic_create(&head, repo, "HEAD", "refs/heads/unborn", 1)); cl_git_pass(git_reference_symbolic_create(&head, repo, "HEAD", "refs/heads/unborn", 1));
cl_assert_equal_i(GIT_EORPHANEDHEAD, cl_assert_equal_i(GIT_EUNBORNBRANCH,
git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT)); git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));
git_reference_free(head); git_reference_free(head);
......
...@@ -114,15 +114,15 @@ void test_submodule_lookup__foreach(void) ...@@ -114,15 +114,15 @@ void test_submodule_lookup__foreach(void)
cl_assert_equal_i(8, data.count); cl_assert_equal_i(8, data.count);
} }
void test_submodule_lookup__lookup_even_with_orphaned_head(void) void test_submodule_lookup__lookup_even_with_unborn_head(void)
{ {
git_reference *orphan; git_reference *head;
git_submodule *sm; git_submodule *sm;
/* orphan the head */ /* put us on an unborn branch */
cl_git_pass(git_reference_symbolic_create( cl_git_pass(git_reference_symbolic_create(
&orphan, g_repo, "HEAD", "refs/heads/garbage", 1)); &head, g_repo, "HEAD", "refs/heads/garbage", 1));
git_reference_free(orphan); git_reference_free(head);
/* lookup existing */ /* lookup existing */
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment