summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-07 16:14:17 -0800
committerRussell Belfer <rb@github.com>2014-02-07 16:14:17 -0800
commit2d9291943c253e9e1520f87b13abb1e81cffdb29 (patch)
tree653489f8d29124bb0a6d32d14dfed9d9974bc267
parent57c47af107b45b73a46a1d157f8f758edd536bc7 (diff)
parentdb55bb73ff4bccbaccbb4c3a7f6b1fcf09498df7 (diff)
downloadlibgit2-2d9291943c253e9e1520f87b13abb1e81cffdb29.tar.gz
Merge pull request #2099 from libgit2/bs/more-reflog-stuff
More reflogness
-rw-r--r--examples/network/fetch.c2
-rw-r--r--include/git2/push.h8
-rw-r--r--include/git2/remote.h17
-rw-r--r--include/git2/repository.h6
-rw-r--r--include/git2/reset.h13
-rwxr-xr-xscript/cibuild.sh2
-rw-r--r--src/clone.c2
-rw-r--r--src/commit.c23
-rw-r--r--src/push.c9
-rw-r--r--src/refs.c4
-rw-r--r--src/remote.c37
-rw-r--r--src/repository.c7
-rw-r--r--src/reset.c12
-rw-r--r--tests/checkout/conflict.c7
-rw-r--r--tests/checkout/tree.c2
-rw-r--r--tests/commit/write.c15
-rw-r--r--tests/index/names.c8
-rw-r--r--tests/index/reuc.c14
-rw-r--r--tests/merge/workdir/dirty.c6
-rw-r--r--tests/merge/workdir/renames.c7
-rw-r--r--tests/merge/workdir/simple.c11
-rw-r--r--tests/merge/workdir/submodules.c4
-rw-r--r--tests/network/fetchlocal.c4
-rw-r--r--tests/network/remote/local.c95
-rw-r--r--tests/online/clone.c14
-rw-r--r--tests/online/fetch.c4
-rw-r--r--tests/online/fetchhead.c2
-rw-r--r--tests/online/push.c20
-rw-r--r--tests/refs/branches/create.c9
-rw-r--r--tests/refs/branches/delete.c2
-rw-r--r--tests/repo/head.c35
-rw-r--r--tests/repo/headtree.c2
-rw-r--r--tests/repo/state.c2
-rw-r--r--tests/reset/hard.c44
-rw-r--r--tests/reset/mixed.c34
-rw-r--r--tests/reset/reset_helpers.c18
-rw-r--r--tests/reset/reset_helpers.h3
-rw-r--r--tests/reset/soft.c61
-rw-r--r--tests/revert/workdir.c35
-rw-r--r--tests/stash/save.c2
40 files changed, 472 insertions, 130 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 474b45bbb..ad16f2793 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -156,7 +156,7 @@ int fetch(git_repository *repo, int argc, char **argv)
// right commits. This may be needed even if there was no packfile
// to download, which can happen e.g. when the branches have been
// changed but all the neede objects are available locally.
- if (git_remote_update_tips(remote) < 0)
+ if (git_remote_update_tips(remote, NULL, NULL) < 0)
return -1;
git_remote_free(remote);
diff --git a/include/git2/push.h b/include/git2/push.h
index 12f0e7f2c..67702aca2 100644
--- a/include/git2/push.h
+++ b/include/git2/push.h
@@ -103,10 +103,16 @@ GIT_EXTERN(int) git_push_add_refspec(git_push *push, const char *refspec);
* Update remote tips after a push
*
* @param push The push object
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ * default is "update by push".
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_push_update_tips(git_push *push);
+GIT_EXTERN(int) git_push_update_tips(
+ git_push *push,
+ const git_signature *signature,
+ const char *reflog_message);
/**
* Actually push all given refspecs
diff --git a/include/git2/remote.h b/include/git2/remote.h
index eba6ca7f9..238b6fd4f 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -355,9 +355,16 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
* Update the tips to the new state
*
* @param remote the remote to update
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ * default is "fetch <name>", where <name> is the name of
+ * the remote (or its url, for in-memory remotes).
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
+GIT_EXTERN(int) git_remote_update_tips(
+ git_remote *remote,
+ const git_signature *signature,
+ const char *reflog_message);
/**
* Download new data and update tips
@@ -366,9 +373,15 @@ GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
* disconnect and update the remote-tracking branches.
*
* @param remote the remote to fetch from
+ * @param signature The identity to use when updating reflogs
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
+ * default is "fetch"
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_remote_fetch(git_remote *remote);
+GIT_EXTERN(int) git_remote_fetch(
+ git_remote *remote,
+ const git_signature *signature,
+ const char *reflog_message);
/**
* Return whether a string is a valid remote URL
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 648667cd6..bf12c7a69 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -615,11 +615,15 @@ GIT_EXTERN(int) git_repository_set_head_detached(
* Otherwise, the HEAD will be detached and point to the peeled Commit.
*
* @param repo Repository pointer
+ * @param signature The identity that will used to populate the reflog entry
+ * @param log_message The one line long message to be appended to the reflog
* @return 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
* branch or an error code
*/
GIT_EXTERN(int) git_repository_detach_head(
- git_repository* repo);
+ git_repository* repo,
+ const git_signature *signature,
+ const char *reflog_message);
typedef enum {
GIT_REPOSITORY_STATE_NONE,
diff --git a/include/git2/reset.h b/include/git2/reset.h
index c36781722..1759cc036 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -48,10 +48,21 @@ typedef enum {
*
* @param reset_type Kind of reset operation to perform.
*
+ * @param signature The identity that will used to populate the reflog entry
+ *
+ * @param log_message The one line long message to be appended to the reflog.
+ * The reflog is only updated if the affected direct reference is actually
+ * changing. If NULL, the default is "reset: moving"; if you want something more
+ * useful, provide a message.
+ *
* @return 0 on success or an error code
*/
GIT_EXTERN(int) git_reset(
- git_repository *repo, git_object *target, git_reset_t reset_type);
+ git_repository *repo,
+ git_object *target,
+ git_reset_t reset_type,
+ git_signature *signature,
+ const char *log_message);
/**
* Updates some entries in the index from the target commit tree.
diff --git a/script/cibuild.sh b/script/cibuild.sh
index 5c0584a80..1f15e851e 100755
--- a/script/cibuild.sh
+++ b/script/cibuild.sh
@@ -34,5 +34,5 @@ export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
export GITTEST_REMOTE_SSH_PASSPHRASE=""
if [ -e ./libgit2_clar ]; then
- ./libgit2_clar -sonline::push
+ ./libgit2_clar -sonline::push -sonline::clone::cred_callback_failure
fi
diff --git a/src/clone.c b/src/clone.c
index 3443528f7..bcc38678f 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -360,7 +360,7 @@ int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_
git_remote_set_update_fetchhead(remote, 0);
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote)) != 0)
+ if ((error = git_remote_fetch(remote, signature, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
if (branch)
diff --git a/src/commit.c b/src/commit.c
index 730fa6403..d66cf0c6a 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -111,8 +111,27 @@ int git_commit_create_from_ids(
git_buf_free(&commit);
- if (update_ref != NULL)
- return git_reference__update_terminal(repo, update_ref, oid, NULL, NULL);
+ if (update_ref != NULL) {
+ int error;
+ git_commit *c;
+ const char *shortmsg;
+ git_buf reflog_msg = GIT_BUF_INIT;
+
+ if (git_commit_lookup(&c, repo, oid) < 0)
+ goto on_error;
+
+ shortmsg = git_commit_summary(c);
+ git_buf_printf(&reflog_msg, "commit%s: %s",
+ git_commit_parentcount(c) == 0 ? " (initial)" : "",
+ shortmsg);
+ git_commit_free(c);
+
+ error = git_reference__update_terminal(repo, update_ref, oid,
+ committer, git_buf_cstr(&reflog_msg));
+
+ git_buf_free(&reflog_msg);
+ return error;
+ }
return 0;
diff --git a/src/push.c b/src/push.c
index d39a27182..c2947808e 100644
--- a/src/push.c
+++ b/src/push.c
@@ -194,7 +194,10 @@ int git_push_add_refspec(git_push *push, const char *refspec)
return 0;
}
-int git_push_update_tips(git_push *push)
+int git_push_update_tips(
+ git_push *push,
+ const git_signature *signature,
+ const char *reflog_message)
{
git_buf remote_ref_name = GIT_BUF_INIT;
size_t i, j;
@@ -241,7 +244,9 @@ int git_push_update_tips(git_push *push)
giterr_clear();
else
goto on_error;
- } else if ((error = git_reference_create(NULL, push->remote->repo, git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, NULL, NULL)) < 0)
+ } else if ((error = git_reference_create(NULL, push->remote->repo,
+ git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature,
+ reflog_message ? reflog_message : "update by push")) < 0)
goto on_error;
}
diff --git a/src/refs.c b/src/refs.c
index bdf2da37e..3ba4b0a84 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1082,8 +1082,10 @@ static int reference__update_terminal(
nesting+1, signature, log_message);
git_reference_free(ref);
} else {
+ /* If we're not moving the target, don't recreate the ref */
+ if (0 != git_oid_cmp(git_reference_target(ref), oid))
+ error = git_reference_create(NULL, repo, ref_name, oid, 1, signature, log_message);
git_reference_free(ref);
- error = git_reference_create(NULL, repo, ref_name, oid, 1, signature, log_message);
}
return error;
diff --git a/src/remote.c b/src/remote.c
index f33f5ef3c..f320f4a52 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -845,9 +845,13 @@ int git_remote_download(git_remote *remote)
return git_fetch_download_pack(remote);
}
-int git_remote_fetch(git_remote *remote)
+int git_remote_fetch(
+ git_remote *remote,
+ const git_signature *signature,
+ const char *reflog_message)
{
int error;
+ git_buf reflog_msg_buf = GIT_BUF_INIT;
/* Connect and download everything */
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) != 0)
@@ -859,8 +863,18 @@ int git_remote_fetch(git_remote *remote)
/* We don't need to be connected anymore */
git_remote_disconnect(remote);
+ /* Default reflog message */
+ if (reflog_message)
+ git_buf_sets(&reflog_msg_buf, reflog_message);
+ else {
+ git_buf_printf(&reflog_msg_buf, "fetch %s",
+ remote->name ? remote->name : remote->url);
+ }
+
/* Create "remote/foo" branches for all remote branches */
- return git_remote_update_tips(remote);
+ error = git_remote_update_tips(remote, signature, git_buf_cstr(&reflog_msg_buf));
+ git_buf_free(&reflog_msg_buf);
+ return error;
}
static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *update_heads, const char *fetchspec_src)
@@ -978,7 +992,12 @@ cleanup:
return error;
}
-static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vector *refs)
+static int update_tips_for_spec(
+ git_remote *remote,
+ git_refspec *spec,
+ git_vector *refs,
+ const git_signature *signature,
+ const char *log_message)
{
int error = 0, autotag;
unsigned int i = 0;
@@ -1045,7 +1064,8 @@ static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vecto
continue;
/* In autotag mode, don't overwrite any locally-existing tags */
- error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag, NULL, NULL);
+ error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
+ signature, log_message);
if (error < 0 && error != GIT_EEXISTS)
goto on_error;
@@ -1074,7 +1094,10 @@ on_error:
}
-int git_remote_update_tips(git_remote *remote)
+int git_remote_update_tips(
+ git_remote *remote,
+ const git_signature *signature,
+ const char *reflog_message)
{
git_refspec *spec, tagspec;
git_vector refs;
@@ -1089,7 +1112,7 @@ int git_remote_update_tips(git_remote *remote)
goto out;
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
- error = update_tips_for_spec(remote, &tagspec, &refs);
+ error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message);
goto out;
}
@@ -1097,7 +1120,7 @@ int git_remote_update_tips(git_remote *remote)
if (spec->push)
continue;
- if ((error = update_tips_for_spec(remote, spec, &refs)) < 0)
+ if ((error = update_tips_for_spec(remote, spec, &refs, signature, reflog_message)) < 0)
goto out;
}
diff --git a/src/repository.c b/src/repository.c
index 44d0f0b7d..9f0c2f68f 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1891,7 +1891,9 @@ cleanup:
}
int git_repository_detach_head(
- git_repository* repo)
+ git_repository* repo,
+ const git_signature *signature,
+ const char *reflog_message)
{
git_reference *old_head = NULL,
*new_head = NULL;
@@ -1906,7 +1908,8 @@ int git_repository_detach_head(
if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJ_COMMIT)) < 0)
goto cleanup;
- error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head), 1, NULL, NULL);
+ error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_reference_target(old_head),
+ 1, signature, reflog_message);
cleanup:
git_object_free(object);
diff --git a/src/reset.c b/src/reset.c
index 15f7fe13a..07fd08863 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -94,13 +94,16 @@ cleanup:
int git_reset(
git_repository *repo,
git_object *target,
- git_reset_t reset_type)
+ git_reset_t reset_type,
+ git_signature *signature,
+ const char *log_message)
{
git_object *commit = NULL;
git_index *index = NULL;
git_tree *tree = NULL;
int error = 0;
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
+ git_buf log_message_buf = GIT_BUF_INIT;
assert(repo && target);
@@ -129,9 +132,14 @@ int git_reset(
goto cleanup;
}
+ if (log_message)
+ git_buf_sets(&log_message_buf, log_message);
+ else
+ git_buf_sets(&log_message_buf, "reset: moving");
+
/* move HEAD to the new target */
if ((error = git_reference__update_terminal(repo, GIT_HEAD_FILE,
- git_object_id(commit), NULL, NULL)) < 0)
+ git_object_id(commit), signature, git_buf_cstr(&log_message_buf))) < 0)
goto cleanup;
if (reset_type == GIT_RESET_HARD) {
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index a8b93b28d..2fea511da 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -61,12 +61,19 @@ struct checkout_name_entry {
void test_checkout_conflict__initialize(void)
{
+ git_config *cfg;
+
g_repo = cl_git_sandbox_init(TEST_REPO_PATH);
git_repository_index(&g_index, g_repo);
cl_git_rewritefile(
TEST_REPO_PATH "/.gitattributes",
"* text eol=lf\n");
+
+ /* Ensure that the user's merge.conflictstyle doesn't interfere */
+ cl_git_pass(git_repository_config(&cfg, g_repo));
+ cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+ git_config_free(cfg);
}
void test_checkout_conflict__cleanup(void)
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 407908ad3..f433b2698 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -571,7 +571,7 @@ void test_checkout_tree__donot_update_deleted_file_by_default(void)
cl_git_pass(git_oid_fromstr(&old_id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
cl_git_pass(git_commit_lookup(&old_commit, g_repo, &old_id));
- cl_git_pass(git_reset(g_repo, (git_object *)old_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(g_repo, (git_object *)old_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(p_unlink("testrepo/branch_file.txt"));
cl_git_pass(git_index_remove_bypath(index ,"branch_file.txt"));
diff --git a/tests/commit/write.c b/tests/commit/write.c
index 8e5b67f2f..b1cdf4485 100644
--- a/tests/commit/write.c
+++ b/tests/commit/write.c
@@ -7,6 +7,8 @@ static const char *commit_message = "This commit has been created in memory\n\
static const char *tree_oid = "1810dff58d8a660512d4832e740f692884338ccd";
static const char *root_commit_message = "This is a root commit\n\
This is a root commit and should be the only one in this branch\n";
+static const char *root_reflog_message = "commit (initial): This is a root commit \
+ This is a root commit and should be the only one in this branch";
static char *head_old;
static git_reference *head, *branch;
static git_commit *commit;
@@ -101,6 +103,8 @@ void test_commit_write__root(void)
git_signature *author, *committer;
const char *branch_name = "refs/heads/root-commit-branch";
git_tree *tree;
+ git_reflog *log;
+ const git_reflog_entry *entry;
git_oid_fromstr(&tree_id, tree_oid);
cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
@@ -130,7 +134,6 @@ void test_commit_write__root(void)
0));
git_object_free((git_object *)tree);
- git_signature_free(committer);
git_signature_free(author);
/*
@@ -144,4 +147,14 @@ void test_commit_write__root(void)
branch_oid = git_reference_target(branch);
cl_git_pass(git_oid_cmp(branch_oid, &commit_id));
cl_assert_equal_s(root_commit_message, git_commit_message(commit));
+
+ cl_git_pass(git_reflog_read(&log, g_repo, branch_name));
+ cl_assert_equal_i(1, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+ cl_assert_equal_s(committer->email, git_reflog_entry_committer(entry)->email);
+ cl_assert_equal_s(committer->name, git_reflog_entry_committer(entry)->name);
+ cl_assert_equal_s(root_reflog_message, git_reflog_entry_message(entry));
+
+ git_signature_free(committer);
+ git_reflog_free(log);
}
diff --git a/tests/index/names.c b/tests/index/names.c
index 9007b1b15..4723449d9 100644
--- a/tests/index/names.c
+++ b/tests/index/names.c
@@ -86,10 +86,10 @@ void test_index_names__cleaned_on_reset_hard(void)
{
git_object *target;
- retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+ cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
test_index_names__add();
- cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
cl_assert(git_index_name_entrycount(repo_index) == 0);
git_object_free(target);
@@ -99,10 +99,10 @@ void test_index_names__cleaned_on_reset_mixed(void)
{
git_object *target;
- retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+ cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
test_index_names__add();
- cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
cl_assert(git_index_name_entrycount(repo_index) == 0);
git_object_free(target);
diff --git a/tests/index/reuc.c b/tests/index/reuc.c
index a18d5602e..bf051c827 100644
--- a/tests/index/reuc.c
+++ b/tests/index/reuc.c
@@ -295,10 +295,10 @@ void test_index_reuc__cleaned_on_reset_hard(void)
{
git_object *target;
- retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+ cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
test_index_reuc__add();
- cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
cl_assert(reuc_entry_exists() == false);
git_object_free(target);
@@ -308,10 +308,10 @@ void test_index_reuc__cleaned_on_reset_mixed(void)
{
git_object *target;
- retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+ cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
test_index_reuc__add();
- cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
cl_assert(reuc_entry_exists() == false);
git_object_free(target);
@@ -321,12 +321,12 @@ void test_index_reuc__retained_on_reset_soft(void)
{
git_object *target;
- retrieve_target_from_oid(&target, repo, "3a34580a35add43a4cf361e8e9a30060a905c876");
+ cl_git_pass(git_revparse_single(&target, repo, "3a34580"));
- git_reset(repo, target, GIT_RESET_HARD);
+ git_reset(repo, target, GIT_RESET_HARD, NULL, NULL);
test_index_reuc__add();
- cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
cl_assert(reuc_entry_exists() == true);
git_object_free(target);
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index 625d3d01a..a77f9b205 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -183,7 +183,7 @@ static void stage_content(char *content[])
cl_git_pass(git_repository_head(&head, repo));
cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
for (i = 0, filename = content[i], text = content[++i];
filename && text;
@@ -212,7 +212,7 @@ static int merge_dirty_files(char *dirty_files[])
cl_git_pass(git_repository_head(&head, repo));
cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
write_files(dirty_files);
@@ -234,7 +234,7 @@ static int merge_differently_filtered_files(char *files[])
cl_git_pass(git_repository_head(&head, repo));
cl_git_pass(git_reference_peel(&head_object, head, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, head_object, GIT_RESET_HARD, NULL, NULL));
write_files(files);
hack_index(files);
diff --git a/tests/merge/workdir/renames.c b/tests/merge/workdir/renames.c
index d38397983..27747720e 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/merge/workdir/renames.c
@@ -17,7 +17,14 @@ static git_repository *repo;
// Fixture setup and teardown
void test_merge_workdir_renames__initialize(void)
{
+ git_config *cfg;
+
repo = cl_git_sandbox_init(TEST_REPO_PATH);
+
+ /* Ensure that the user's merge.conflictstyle doesn't interfere */
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+ git_config_free(cfg);
}
void test_merge_workdir_renames__cleanup(void)
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 4ff761cf8..a9a63651c 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -116,8 +116,15 @@ static git_index *repo_index;
// Fixture setup and teardown
void test_merge_workdir_simple__initialize(void)
{
+ git_config *cfg;
+
repo = cl_git_sandbox_init(TEST_REPO_PATH);
git_repository_index(&repo_index, repo);
+
+ /* Ensure that the user's merge.conflictstyle doesn't interfere */
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+ git_config_free(cfg);
}
void test_merge_workdir_simple__cleanup(void)
@@ -585,7 +592,7 @@ void test_merge_workdir_simple__directory_file(void)
cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, GIT_REFS_HEADS_DIR OURS_DIRECTORY_FILE, 1, NULL, NULL));
cl_git_pass(git_reference_name_to_id(&head_commit_id, repo, GIT_HEAD_FILE));
cl_git_pass(git_commit_lookup(&head_commit, repo, &head_commit_id));
- cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
@@ -684,7 +691,7 @@ void test_merge_workdir_simple__binary(void)
cl_git_pass(git_oid_fromstr(&their_oid, "ad01aebfdf2ac13145efafe3f9fcf798882f1730"));
cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
- cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index f01faac43..42451bde7 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -46,7 +46,7 @@ void test_merge_workdir_submodules__automerge(void)
cl_git_pass(git_reference_lookup(&our_ref, repo, "refs/heads/" SUBMODULE_MAIN_BRANCH));
cl_git_pass(git_commit_lookup(&our_commit, repo, git_reference_target(our_ref)));
- cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
@@ -82,7 +82,7 @@ void test_merge_workdir_submodules__take_changed(void)
cl_git_pass(git_reference_lookup(&our_ref, repo, "refs/heads/" SUBMODULE_MAIN_BRANCH));
cl_git_pass(git_commit_lookup(&our_commit, repo, git_reference_target(our_ref)));
- cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)our_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 28c7115bf..4c39394bb 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -37,7 +37,7 @@ void test_network_fetchlocal__complete(void)
git_remote_set_callbacks(origin, &callbacks);
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin));
- cl_git_pass(git_remote_update_tips(origin));
+ cl_git_pass(git_remote_update_tips(origin, NULL, NULL));
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(19, (int)refnames.count);
@@ -75,7 +75,7 @@ void test_network_fetchlocal__partial(void)
git_remote_set_callbacks(origin, &callbacks);
cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(origin));
- cl_git_pass(git_remote_update_tips(origin));
+ cl_git_pass(git_remote_update_tips(origin, NULL, NULL));
git_strarray_free(&refnames);
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 9b9f716b9..589e6ac9b 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -115,7 +115,7 @@ void test_network_remote_local__shorthand_fetch_refspec0(void)
cl_git_pass(git_remote_add_fetch(remote, refspec2));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
git_reference_free(ref);
@@ -137,7 +137,7 @@ void test_network_remote_local__shorthand_fetch_refspec1(void)
cl_git_pass(git_remote_add_fetch(remote, refspec2));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
@@ -152,7 +152,7 @@ void test_network_remote_local__tagopt(void)
git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master"));
@@ -171,7 +171,7 @@ void test_network_remote_local__push_to_bare_remote(void)
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
/* Set up an empty bare repo to push into */
@@ -208,7 +208,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
/* Set up an empty bare repo to push into */
@@ -248,7 +248,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
connect_to_local_repository(cl_fixture("testrepo.git"));
cl_git_pass(git_remote_add_fetch(remote, "master:master"));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
/* Set up an empty non-bare repo to push into */
@@ -273,3 +273,86 @@ void test_network_remote_local__push_to_non_bare_remote(void)
git_remote_free(localremote);
cl_fixture_cleanup("localbare.git");
}
+
+void test_network_remote_local__fetch(void)
+{
+ const char *refspec = "master:remotes/sloppy/master";
+
+ git_reflog *log;
+ const git_reflog_entry *entry;
+ git_signature *sig;
+ git_reference *ref;
+
+ cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+ connect_to_local_repository(cl_fixture("testrepo.git"));
+ cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+ cl_git_pass(git_remote_fetch(remote, sig, "UPDAAAAAATE!!"));
+
+ cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master"));
+ git_reference_free(ref);
+
+ cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+ cl_assert_equal_i(1, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+ cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+ cl_assert_equal_s("UPDAAAAAATE!!", git_reflog_entry_message(entry));
+
+ git_reflog_free(log);
+ git_signature_free(sig);
+}
+
+void test_network_remote_local__reflog(void)
+{
+ const char *refspec = "master:remotes/sloppy/master";
+
+ git_reflog *log;
+ const git_reflog_entry *entry;
+ git_signature *sig;
+
+ cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+ connect_to_local_repository(cl_fixture("testrepo.git"));
+ cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+ cl_git_pass(git_remote_download(remote));
+ cl_git_pass(git_remote_update_tips(remote, sig, "UPDAAAAAATE!!"));
+
+ cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+ cl_assert_equal_i(1, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+ cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+ cl_assert_equal_s("UPDAAAAAATE!!", git_reflog_entry_message(entry));
+
+ git_reflog_free(log);
+ git_signature_free(sig);
+}
+
+void test_network_remote_local__fetch_default_reflog_message(void)
+{
+ const char *refspec = "master:remotes/sloppy/master";
+
+ git_reflog *log;
+ const git_reflog_entry *entry;
+ git_signature *sig;
+ char expected_reflog_msg[1024];
+
+ cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
+
+ connect_to_local_repository(cl_fixture("testrepo.git"));
+ cl_git_pass(git_remote_add_fetch(remote, refspec));
+
+ cl_git_pass(git_remote_fetch(remote, sig, NULL));
+
+ cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master"));
+ cl_assert_equal_i(1, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+ cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+
+ sprintf(expected_reflog_msg, "fetch %s", git_remote_url(remote));
+ cl_assert_equal_s(expected_reflog_msg, git_reflog_entry_message(entry));
+
+ git_reflog_free(log);
+ git_signature_free(sig);
+}
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 1222d174d..fa2408a75 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -192,30 +192,28 @@ static int cred_failure_cb(
{
GIT_UNUSED(cred); GIT_UNUSED(url); GIT_UNUSED(username_from_url);
GIT_UNUSED(allowed_types); GIT_UNUSED(data);
- return -1;
+ return -172;
}
-void test_online_clone__cred_callback_failure_is_euser(void)
+void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
{
const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
const char *remote_user = cl_getenv("GITTEST_REMOTE_USER");
- const char *remote_default = cl_getenv("GITTEST_REMOTE_DEFAULT");
- int error;
if (!remote_url) {
printf("GITTEST_REMOTE_URL unset; skipping clone test\n");
return;
}
- if (!remote_user && !remote_default) {
- printf("GITTEST_REMOTE_USER and GITTEST_REMOTE_DEFAULT unset; skipping clone test\n");
+ if (!remote_user) {
+ printf("GITTEST_REMOTE_USER unset; skipping clone test\n");
return;
}
g_options.remote_callbacks.credentials = cred_failure_cb;
- cl_git_fail(error = git_clone(&g_repo, remote_url, "./foo", &g_options));
- cl_assert_equal_i(error, GIT_EUSER);
+ /* TODO: this should expect -172. */
+ cl_git_fail_with(git_clone(&g_repo, remote_url, "./foo", &g_options), -1);
}
void test_online_clone__credentials(void)
diff --git a/tests/online/fetch.c b/tests/online/fetch.c
index 8f71cf3f5..cb84e846c 100644
--- a/tests/online/fetch.c
+++ b/tests/online/fetch.c
@@ -48,7 +48,7 @@ static void do_fetch(const char *url, git_remote_autotag_option_t flag, int n)
git_remote_set_autotag(remote, flag);
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
cl_assert_equal_i(counter, n);
cl_assert(bytes_received > 0);
@@ -117,7 +117,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date
cl_assert_equal_i(false, invoked);
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
git_remote_free(remote);
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index 57b183f88..0b3f20db1 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -51,7 +51,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(remote));
- cl_git_pass(git_remote_update_tips(remote));
+ cl_git_pass(git_remote_update_tips(remote, NULL, NULL));
git_remote_disconnect(remote);
git_remote_free(remote);
diff --git a/tests/online/push.c b/tests/online/push.c
index 8efe21e0e..55b97b282 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -351,7 +351,7 @@ void test_online_push__initialize(void)
/* Now that we've deleted everything, fetch from the remote */
cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_FETCH));
cl_git_pass(git_remote_download(_remote));
- cl_git_pass(git_remote_update_tips(_remote));
+ cl_git_pass(git_remote_update_tips(_remote, NULL, NULL));
git_remote_disconnect(_remote);
} else
printf("GITTEST_REMOTE_URL unset; skipping push test\n");
@@ -414,11 +414,13 @@ static void do_push(
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
size_t i;
int pack_progress_calls = 0, transfer_progress_calls = 0;
+ git_signature *pusher;
if (_remote) {
/* Auto-detect the number of threads to use */
opts.pb_parallelism = 0;
+ cl_git_pass(git_signature_now(&pusher, "Foo Bar", "foo@example.com"));
cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH));
cl_git_pass(git_push_new(&push, _remote));
@@ -455,13 +457,15 @@ static void do_push(
verify_refs(_remote, expected_refs, expected_refs_len);
- cl_git_pass(git_push_update_tips(push));
+ cl_git_pass(git_push_update_tips(push, pusher, "test push"));
verify_tracking_branches(_remote, expected_refs, expected_refs_len);
git_push_free(push);
git_remote_disconnect(_remote);
+ git_signature_free(pusher);
}
+
}
/* Call push_finish() without ever calling git_push_add_refspec() */
@@ -528,6 +532,9 @@ void test_online_push__b5_cancel(void)
void test_online_push__multi(void)
{
+ git_reflog *log;
+ const git_reflog_entry *entry;
+
const char *specs[] = {
"refs/heads/b1:refs/heads/b1",
"refs/heads/b2:refs/heads/b2",
@@ -552,6 +559,15 @@ void test_online_push__multi(void)
do_push(specs, ARRAY_SIZE(specs),
exp_stats, ARRAY_SIZE(exp_stats),
exp_refs, ARRAY_SIZE(exp_refs), 0, 1);
+
+ cl_git_pass(git_reflog_read(&log, _repo, "refs/remotes/test/b1"));
+ entry = git_reflog_entry_byindex(log, 0);
+ if (entry) {
+ cl_assert_equal_s("test push", git_reflog_entry_message(entry));
+ cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
+ }
+
+ git_reflog_free(log);
}
void test_online_push__implicit_tgt(void)
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index abe5f5940..94ecc0bca 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -29,15 +29,16 @@ void test_refs_branches_create__cleanup(void)
static void retrieve_target_from_oid(git_commit **out, git_repository *repo, const char *sha)
{
- git_oid oid;
+ git_object *obj;
- cl_git_pass(git_oid_fromstr(&oid, sha));
- cl_git_pass(git_commit_lookup(out, repo, &oid));
+ cl_git_pass(git_revparse_single(&obj, repo, sha));
+ cl_git_pass(git_commit_lookup(out, repo, git_object_id(obj)));
+ git_object_free(obj);
}
static void retrieve_known_commit(git_commit **commit, git_repository *repo)
{
- retrieve_target_from_oid(commit, repo, "e90810b8df3e80c413d903f631643c716887138d");
+ retrieve_target_from_oid(commit, repo, "e90810b8df3");
}
#define NEW_BRANCH_NAME "new-branch-on-the-block"
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index 7d1d400c8..ed5f1627b 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -78,7 +78,7 @@ void test_refs_branches_delete__can_delete_a_branch_pointed_at_by_detached_HEAD(
git_reference_free(head);
/* Detach HEAD and make it target the commit that "master" points to */
- git_repository_detach_head(repo);
+ git_repository_detach_head(repo, NULL, NULL);
cl_git_pass(git_branch_lookup(&branch, repo, "master", GIT_BRANCH_LOCAL));
cl_git_pass(git_branch_delete(branch));
diff --git a/tests/repo/head.c b/tests/repo/head.c
index 127176d12..c5965fac6 100644
--- a/tests/repo/head.c
+++ b/tests/repo/head.c
@@ -15,21 +15,42 @@ void test_repo_head__cleanup(void)
cl_git_sandbox_cleanup();
}
+static void check_last_reflog_entry(const char *email, const char *message)
+{
+ git_reflog *log;
+ const git_reflog_entry *entry;
+
+ cl_git_pass(git_reflog_read(&log, repo, GIT_HEAD_FILE));
+ cl_assert(git_reflog_entrycount(log) > 0);
+ entry = git_reflog_entry_byindex(log, 0);
+ if (email)
+ cl_assert_equal_s(email, git_reflog_entry_committer(entry)->email);
+ if (message)
+ cl_assert_equal_s(message, git_reflog_entry_message(entry));
+ git_reflog_free(log);
+}
+
void test_repo_head__head_detached(void)
{
git_reference *ref;
+ git_signature *sig;
- cl_git_pass(git_repository_head_detached(repo));
+ cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com"));
- cl_git_pass(git_repository_detach_head(repo));
+ cl_assert_equal_i(false, git_repository_head_detached(repo));
+ cl_git_pass(git_repository_detach_head(repo, sig, "CABLE DETACHED"));
+ check_last_reflog_entry(sig->email, "CABLE DETACHED");
cl_assert_equal_i(true, git_repository_head_detached(repo));
- /* take the reop back to it's original state */
- cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master", 1, NULL, NULL));
+ /* take the repo back to it's original state */
+ cl_git_pass(git_reference_symbolic_create(&ref, repo, "HEAD", "refs/heads/master",
+ true, sig, "REATTACH"));
git_reference_free(ref);
+ check_last_reflog_entry(sig->email, "REATTACH");
cl_assert_equal_i(false, git_repository_head_detached(repo));
+ git_signature_free(sig);
}
void test_repo_head__unborn_head(void)
@@ -147,7 +168,7 @@ void test_repo_head__detach_head_Detaches_HEAD_and_make_it_point_to_the_peeled_c
{
cl_assert_equal_i(false, git_repository_head_detached(repo));
- cl_git_pass(git_repository_detach_head(repo));
+ cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
assert_head_is_correctly_detached();
}
@@ -158,7 +179,7 @@ void test_repo_head__detach_head_Fails_if_HEAD_and_point_to_a_non_commitish(void
cl_git_pass(git_reference_symbolic_create(&head, repo, GIT_HEAD_FILE, "refs/tags/point_to_blob", 1, NULL, NULL));
- cl_git_fail(git_repository_detach_head(repo));
+ cl_git_fail(git_repository_detach_head(repo, NULL, NULL));
git_reference_free(head);
}
@@ -167,7 +188,7 @@ void test_repo_head__detaching_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
{
make_head_unborn(repo, NON_EXISTING_HEAD);
- cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo));
+ cl_assert_equal_i(GIT_EUNBORNBRANCH, git_repository_detach_head(repo, NULL, NULL));
}
void test_repo_head__retrieving_an_unborn_branch_returns_GIT_EUNBORNBRANCH(void)
diff --git a/tests/repo/headtree.c b/tests/repo/headtree.c
index e899ac399..79d88c0a7 100644
--- a/tests/repo/headtree.c
+++ b/tests/repo/headtree.c
@@ -20,7 +20,7 @@ void test_repo_headtree__cleanup(void)
void test_repo_headtree__can_retrieve_the_root_tree_from_a_detached_head(void)
{
- cl_git_pass(git_repository_detach_head(repo));
+ cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
cl_git_pass(git_repository_head_tree(&tree, repo));
diff --git a/tests/repo/state.c b/tests/repo/state.c
index 5a0a5f360..5e7227205 100644
--- a/tests/repo/state.c
+++ b/tests/repo/state.c
@@ -37,7 +37,7 @@ void test_repo_state__none_with_HEAD_attached(void)
void test_repo_state__none_with_HEAD_detached(void)
{
- cl_git_pass(git_repository_detach_head(_repo));
+ cl_git_pass(git_repository_detach_head(_repo, NULL, NULL));
assert_repo_state(GIT_REPOSITORY_STATE_NONE);
}
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index 0f80d32df..d4c7db45f 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -69,10 +69,9 @@ void test_reset_hard__resetting_reverts_modified_files(void)
cl_assert_equal_s(before[i], content.ptr);
}
- retrieve_target_from_oid(
- &target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f");
+ cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
- cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
for (i = 0; i < 4; ++i) {
cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
@@ -95,9 +94,9 @@ void test_reset_hard__cannot_reset_in_a_bare_repository(void)
cl_git_pass(git_repository_open(&bare, cl_fixture("testrepo.git")));
cl_assert(git_repository_is_bare(bare) == true);
- retrieve_target_from_oid(&target, bare, KNOWN_COMMIT_IN_BARE_REPO);
+ cl_git_pass(git_revparse_single(&target, bare, KNOWN_COMMIT_IN_BARE_REPO));
- cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_HARD));
+ cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_HARD, NULL, NULL));
git_repository_free(bare);
}
@@ -152,8 +151,8 @@ void test_reset_hard__resetting_reverts_unmerged(void)
unmerged_index_init(index, entries);
cl_git_pass(git_index_write(index));
- retrieve_target_from_oid(&target, repo, "26a125ee1bfc5df1e1b2e9441bbe63c8a7ae989f");
- cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+ cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
cl_assert(git_path_exists("status/conflicting_file") == 0);
@@ -183,8 +182,8 @@ void test_reset_hard__cleans_up_merge(void)
cl_git_pass(git_buf_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
cl_git_mkfile(git_buf_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
- retrieve_target_from_oid(&target, repo, "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
- cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+ cl_git_pass(git_revparse_single(&target, repo, "0017bd4"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
cl_assert(!git_path_exists(git_buf_cstr(&merge_head_path)));
cl_assert(!git_path_exists(git_buf_cstr(&merge_msg_path)));
@@ -198,3 +197,30 @@ void test_reset_hard__cleans_up_merge(void)
git_buf_free(&merge_mode_path);
git_buf_free(&orig_head_path);
}
+
+void test_reset_hard__reflog_is_correct(void)
+{
+ const char *exp_msg = "commit: Add a file which name should appear before the "
+ "\"subdir/\" folder while being dealt with by the treewalker";
+
+ reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 3, "emeric.fermas@gmail.com", exp_msg);
+
+ /* Branch not moving, no reflog entry */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
+ reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 3, "emeric.fermas@gmail.com", exp_msg);
+
+ /* Moved branch, expect default message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
+ reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 4, NULL, "reset: moving");
+
+ /* Moved branch, expect custom message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, "message1"));
+ reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 5, NULL, "message1");
+}
diff --git a/tests/reset/mixed.c b/tests/reset/mixed.c
index 7b90c23f1..25272a75c 100644
--- a/tests/reset/mixed.c
+++ b/tests/reset/mixed.c
@@ -27,9 +27,9 @@ void test_reset_mixed__cannot_reset_in_a_bare_repository(void)
cl_git_pass(git_repository_open(&bare, cl_fixture("testrepo.git")));
cl_assert(git_repository_is_bare(bare) == true);
- retrieve_target_from_oid(&target, bare, KNOWN_COMMIT_IN_BARE_REPO);
+ cl_git_pass(git_revparse_single(&target, bare, KNOWN_COMMIT_IN_BARE_REPO));
- cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_MIXED));
+ cl_assert_equal_i(GIT_EBAREREPO, git_reset(bare, target, GIT_RESET_MIXED, NULL, NULL));
git_repository_free(bare);
}
@@ -40,10 +40,36 @@ void test_reset_mixed__resetting_refreshes_the_index_to_the_commit_tree(void)
cl_git_pass(git_status_file(&status, repo, "macro_bad"));
cl_assert(status == GIT_STATUS_CURRENT);
- retrieve_target_from_oid(&target, repo, "605812ab7fe421fdd325a935d35cb06a9234a7d7");
+ cl_git_pass(git_revparse_single(&target, repo, "605812a"));
- cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
cl_git_pass(git_status_file(&status, repo, "macro_bad"));
cl_assert(status == GIT_STATUS_WT_NEW);
}
+
+void test_reset_mixed__reflog_is_correct(void)
+{
+ const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";
+
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+ /* Branch not moving, no reflog entry */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+ /* Moved branch, expect default message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, NULL));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 10, NULL, "reset: moving");
+
+ /* Moved branch, expect custom message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL, "message1"));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 11, NULL, "message1");
+}
diff --git a/tests/reset/reset_helpers.c b/tests/reset/reset_helpers.c
index 17edca4e9..7a335a600 100644
--- a/tests/reset/reset_helpers.c
+++ b/tests/reset/reset_helpers.c
@@ -1,10 +1,20 @@
#include "clar_libgit2.h"
#include "reset_helpers.h"
-void retrieve_target_from_oid(git_object **object_out, git_repository *repo, const char *sha)
+void reflog_check(git_repository *repo, const char *refname,
+ size_t exp_count, const char *exp_email, const char *exp_msg)
{
- git_oid oid;
+ git_reflog *log;
+ const git_reflog_entry *entry;
- cl_git_pass(git_oid_fromstr(&oid, sha));
- cl_git_pass(git_object_lookup(object_out, repo, &oid, GIT_OBJ_ANY));
+ cl_git_pass(git_reflog_read(&log, repo, refname));
+ cl_assert_equal_i(exp_count, git_reflog_entrycount(log));
+ entry = git_reflog_entry_byindex(log, 0);
+
+ if (exp_email)
+ cl_assert_equal_s(exp_email, git_reflog_entry_committer(entry)->email);
+ if (exp_msg)
+ cl_assert_equal_s(exp_msg, git_reflog_entry_message(entry));
+
+ git_reflog_free(log);
}
diff --git a/tests/reset/reset_helpers.h b/tests/reset/reset_helpers.h
index 5dbe9d2c7..e7e048514 100644
--- a/tests/reset/reset_helpers.h
+++ b/tests/reset/reset_helpers.h
@@ -3,4 +3,5 @@
#define KNOWN_COMMIT_IN_BARE_REPO "e90810b8df3e80c413d903f631643c716887138d"
#define KNOWN_COMMIT_IN_ATTR_REPO "217878ab49e1314388ea2e32dc6fdb58a1b969e0"
-extern void retrieve_target_from_oid(git_object **object_out, git_repository *repo, const char *sha);
+void reflog_check(git_repository *repo, const char *refname,
+ size_t exp_count, const char *exp_email, const char *exp_msg);
diff --git a/tests/reset/soft.c b/tests/reset/soft.c
index bd6fcc205..c889c0355 100644
--- a/tests/reset/soft.c
+++ b/tests/reset/soft.c
@@ -26,12 +26,11 @@ static void assert_reset_soft(bool should_be_detached)
cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_fail(git_oid_streq(&oid, KNOWN_COMMIT_IN_BARE_REPO));
-
- retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+ cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
cl_assert(git_repository_head_detached(repo) == should_be_detached);
- cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
cl_assert(git_repository_head_detached(repo) == should_be_detached);
@@ -46,7 +45,7 @@ void test_reset_soft__can_reset_the_non_detached_Head_to_the_specified_commit(vo
void test_reset_soft__can_reset_the_detached_Head_to_the_specified_commit(void)
{
- git_repository_detach_head(repo);
+ git_repository_detach_head(repo, NULL, NULL);
assert_reset_soft(true);
}
@@ -60,9 +59,9 @@ void test_reset_soft__resetting_to_the_commit_pointed_at_by_the_Head_does_not_ch
git_oid_fmt(raw_head_oid, &oid);
raw_head_oid[GIT_OID_HEXSZ] = '\0';
- retrieve_target_from_oid(&target, repo, raw_head_oid);
+ cl_git_pass(git_revparse_single(&target, repo, raw_head_oid));
- cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
cl_git_pass(git_oid_streq(&oid, raw_head_oid));
@@ -73,9 +72,9 @@ void test_reset_soft__resetting_to_a_tag_sets_the_Head_to_the_peeled_commit(void
git_oid oid;
/* b25fa35 is a tag, pointing to another tag which points to commit e90810b */
- retrieve_target_from_oid(&target, repo, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
+ cl_git_pass(git_revparse_single(&target, repo, "b25fa35"));
- cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
cl_assert(git_repository_head_detached(repo) == false);
cl_git_pass(git_reference_name_to_id(&oid, repo, "HEAD"));
@@ -85,27 +84,27 @@ void test_reset_soft__resetting_to_a_tag_sets_the_Head_to_the_peeled_commit(void
void test_reset_soft__cannot_reset_to_a_tag_not_pointing_at_a_commit(void)
{
/* 53fc32d is the tree of commit e90810b */
- retrieve_target_from_oid(&target, repo, "53fc32d17276939fc79ed05badaef2db09990016");
+ cl_git_pass(git_revparse_single(&target, repo, "53fc32d"));
- cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
git_object_free(target);
/* 521d87c is an annotated tag pointing to a blob */
- retrieve_target_from_oid(&target, repo, "521d87c1ec3aef9824daf6d96cc0ae3710766d91");
- cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT));
+ cl_git_pass(git_revparse_single(&target, repo, "521d87c"));
+ cl_git_fail(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
}
void test_reset_soft__resetting_against_an_unborn_head_repo_makes_the_head_no_longer_unborn(void)
{
git_reference *head;
- retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+ cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
make_head_unborn(repo, NON_EXISTING_HEAD);
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, NULL, NULL));
cl_assert_equal_i(false, git_repository_head_unborn(repo));
@@ -119,13 +118,13 @@ void test_reset_soft__fails_when_merging(void)
{
git_buf merge_head_path = GIT_BUF_INIT;
- cl_git_pass(git_repository_detach_head(repo));
+ cl_git_pass(git_repository_detach_head(repo, NULL, NULL));
cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
- retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
+ cl_git_pass(git_revparse_single(&target, repo, KNOWN_COMMIT_IN_BARE_REPO));
- cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT));
+ cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path)));
git_buf_free(&merge_head_path);
@@ -153,5 +152,31 @@ void test_reset_soft__fails_when_index_contains_conflicts_independently_of_MERGE
cl_git_pass(git_reference_peel(&target, head, GIT_OBJ_COMMIT));
git_reference_free(head);
- cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT));
+ cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+}
+
+void test_reset_soft_reflog_is_correct(void)
+{
+ const char *exp_msg = "commit: Updating test data so we can test inter-hunk-context";
+
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+ /* Branch not moving, no reflog entry */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 9, "yoram.harmelin@gmail.com", exp_msg);
+
+ /* Moved branch, expect default message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, NULL));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 10, NULL, "reset: moving");
+
+ /* Moved branch, expect custom message */
+ cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
+ cl_git_pass(git_reset(repo, target, GIT_RESET_SOFT, NULL, "message1"));
+ reflog_check(repo, "HEAD", 9, "yoram.harmelin@gmail.com", exp_msg);
+ reflog_check(repo, "refs/heads/master", 11, NULL, "message1");
}
diff --git a/tests/revert/workdir.c b/tests/revert/workdir.c
index 5be397c93..47abeb8f0 100644
--- a/tests/revert/workdir.c
+++ b/tests/revert/workdir.c
@@ -15,8 +15,15 @@ static git_index *repo_index;
// Fixture setup and teardown
void test_revert_workdir__initialize(void)
{
+ git_config *cfg;
+
repo = cl_git_sandbox_init(TEST_REPO_PATH);
git_repository_index(&repo_index, repo);
+
+ /* Ensure that the user's merge.conflictstyle doesn't interfere */
+ cl_git_pass(git_repository_config(&cfg, repo));
+ cl_git_pass(git_config_set_string(cfg, "merge.conflictstyle", "merge"));
+ git_config_free(cfg);
}
void test_revert_workdir__cleanup(void)
@@ -41,7 +48,7 @@ void test_revert_workdir__automerge(void)
git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -74,7 +81,7 @@ void test_revert_workdir__conflicts(void)
cl_git_pass(git_repository_head(&head_ref, repo));
cl_git_pass(git_reference_peel((git_object **)&head, head_ref, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
cl_git_pass(git_revert(repo, commit, NULL));
@@ -125,7 +132,7 @@ void test_revert_workdir__orphan(void)
git_oid_fromstr(&head_oid, "39467716290f6df775a91cdb9a4eb39295018145");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "ebb03002cee5d66c7732dd06241119fe72ab96a5");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -160,7 +167,7 @@ void test_revert_workdir__again(void)
cl_git_pass(git_repository_head(&head_ref, repo));
cl_git_pass(git_reference_peel((git_object **)&orig_head, head_ref, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_revert(repo, orig_head, NULL));
@@ -208,7 +215,7 @@ void test_revert_workdir__again_after_automerge(void)
git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -256,7 +263,7 @@ void test_revert_workdir__again_after_edit(void)
cl_git_pass(git_oid_fromstr(&orig_head_oid, "399fb3aba3d9d13f7d40a9254ce4402067ef3149"));
cl_git_pass(git_commit_lookup(&orig_head, repo, &orig_head_oid));
- cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)orig_head, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_oid_fromstr(&revert_oid, "2d440f2b3147d3dc7ad1085813478d6d869d5a4d"));
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -307,7 +314,7 @@ void test_revert_workdir__again_after_edit_two(void)
cl_git_pass(git_oid_fromstr(&head_commit_oid, "e34ef1afe54eb526fd92eec66084125f340f1d65"));
cl_git_pass(git_commit_lookup(&head_commit, repo, &head_commit_oid));
- cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head_commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_oid_fromstr(&revert_commit_oid, "71eb9c2b53dbbf3c45fb28b27c850db4b7fb8011"));
cl_git_pass(git_commit_lookup(&revert_commit, repo, &revert_commit_oid));
@@ -360,7 +367,7 @@ void test_revert_workdir__conflict_use_ours(void)
git_oid_fromstr(&head_oid, "72333f47d4e83616630ff3b0ffe4c0faebcc3c45");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "d1d403d22cbe24592d725f442835cf46fe60c8ac");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -396,7 +403,7 @@ void test_revert_workdir__rename_1_of_2(void)
git_oid_fromstr(&head_oid, "cef56612d71a6af8d8015691e4865f7fece905b5");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "55568c8de5322ff9a95d72747a239cdb64a19965");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -430,7 +437,7 @@ void test_revert_workdir__rename(void)
git_oid_fromstr(&head_oid, "55568c8de5322ff9a95d72747a239cdb64a19965");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
git_oid_fromstr(&revert_oid, "0aa8c7e40d342fff78d60b29a4ba8e993ed79c51");
cl_git_pass(git_commit_lookup(&commit, repo, &revert_oid));
@@ -459,7 +466,7 @@ void test_revert_workdir__head(void)
/* HEAD is 2d440f2b3147d3dc7ad1085813478d6d869d5a4d */
cl_git_pass(git_repository_head(&head, repo));
cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJ_COMMIT));
- cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_revert(repo, commit, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
@@ -496,7 +503,7 @@ void test_revert_workdir__merge_fails_without_mainline_specified(void)
git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
cl_must_fail(git_revert(repo, head, NULL));
cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
@@ -523,7 +530,7 @@ void test_revert_workdir__merge_first_parent(void)
git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_revert(repo, head, &opts));
@@ -548,7 +555,7 @@ void test_revert_workdir__merge_second_parent(void)
git_oid_fromstr(&head_oid, "5acdc74af27172ec491d213ee36cea7eb9ef2579");
cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
- cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD));
+ cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
cl_git_pass(git_revert(repo, head, &opts));
diff --git a/tests/stash/save.c b/tests/stash/save.c
index 293a89a97..b5a793eef 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -196,7 +196,7 @@ void test_stash_save__cannot_stash_against_a_bare_repository(void)
void test_stash_save__can_stash_against_a_detached_head(void)
{
- git_repository_detach_head(repo);
+ git_repository_detach_head(repo, NULL, NULL);
cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));