Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-10-11 14:25:50 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2014-11-09 02:01:58 +0300
commit64e3e6d43acbbf6cc8f8a4c612547c5a575c4031 (patch)
tree18c5db63b5253a0a1261abc0a9cde9dc3ab51ebb /tests/online
parent6eb9e39ce03e4db1fb39ff9fa8ed771463fca1bd (diff)
remote: use configured push refspecs if none are given
If the user does not pass any refspecs to push, try to use those configured via the configuration or via add_push().
Diffstat (limited to 'tests/online')
-rw-r--r--tests/online/push.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/online/push.c b/tests/online/push.c
index ec213dbed..ddc46f63b 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -463,7 +463,7 @@ static void do_push(
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
size_t i;
int error;
- git_strarray specs;
+ git_strarray specs = {0};
git_signature *pusher;
git_remote_callbacks callbacks;
record_callbacks_data *data;
@@ -482,9 +482,11 @@ static void do_push(
callbacks.push_update_reference = record_push_status_cb;
cl_git_pass(git_remote_set_callbacks(_remote, &callbacks));
- specs.count = refspecs_len;
- specs.strings = git__calloc(refspecs_len, sizeof(char *));
- cl_assert(specs.strings);
+ if (refspecs_len) {
+ specs.count = refspecs_len;
+ specs.strings = git__calloc(refspecs_len, sizeof(char *));
+ cl_assert(specs.strings);
+ }
for (i = 0; i < refspecs_len; i++)
specs.strings[i] = (char *) refspecs[i];
@@ -878,3 +880,35 @@ void test_online_push__notes(void)
git_signature_free(signature);
}
+
+void test_online_push__configured(void)
+{
+ git_oid note_oid, *target_oid, expected_oid;
+ git_signature *signature;
+ const char *specs[] = { "refs/notes/commits:refs/notes/commits" };
+ push_status exp_stats[] = { { "refs/notes/commits", 1 } };
+ expected_ref exp_refs[] = { { "refs/notes/commits", &expected_oid } };
+ const char *specs_del[] = { ":refs/notes/commits" };
+
+ git_oid_fromstr(&expected_oid, "8461a99b27b7043e58ff6e1f5d2cf07d282534fb");
+
+ target_oid = &_oid_b6;
+
+ cl_git_pass(git_remote_add_push(_remote, specs[0]));
+
+ /* Create note to push */
+ cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */
+ cl_git_pass(git_note_create(&note_oid, _repo, signature, signature, NULL, target_oid, "hello world\n", 0));
+
+ do_push(NULL, 0,
+ exp_stats, ARRAY_SIZE(exp_stats),
+ exp_refs, ARRAY_SIZE(exp_refs), 0, 1, 1);
+
+ /* And make sure to delete the note */
+
+ do_push(specs_del, ARRAY_SIZE(specs_del),
+ exp_stats, 1,
+ NULL, 0, 0, 0, 0);
+
+ git_signature_free(signature);
+}