diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-10-11 12:25:50 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-09 00:01:58 +0100 |
commit | 64e3e6d43acbbf6cc8f8a4c612547c5a575c4031 (patch) | |
tree | 18c5db63b5253a0a1261abc0a9cde9dc3ab51ebb /tests | |
parent | 6eb9e39ce03e4db1fb39ff9fa8ed771463fca1bd (diff) | |
download | libgit2-64e3e6d43acbbf6cc8f8a4c612547c5a575c4031.tar.gz |
remote: use configured push refspecs if none are givencmn/remote-push
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')
-rw-r--r-- | tests/online/push.c | 42 |
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(¬e_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); +} |