Commit df705148ecc0d0a4c78f7a3b0903527918e38149

Ben Straub 2012-11-27T13:15:43

API updates for remote.h Includes typedef for git_direction, and renames for GIT_DIR_[FETCH|PUSH] to GIT_DIRECTION_(\1).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 9d1404a..e341d2d 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -25,7 +25,7 @@ static void *download(void *ptr)
 
 	// Connect to the remote end specifying that we want to fetch
 	// information from it.
-	if (git_remote_connect(data->remote, GIT_DIR_FETCH) < 0) {
+	if (git_remote_connect(data->remote, GIT_DIRECTION_FETCH) < 0) {
 		data->ret = -1;
 		goto exit;
 	}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 822d6f6..62131d4 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -27,7 +27,7 @@ static int use_unnamed(git_repository *repo, const char *url)
 
 	// When connecting, the underlying code needs to know wether we
 	// want to push or fetch
-	error = git_remote_connect(remote, GIT_DIR_FETCH);
+	error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
 	if (error < 0)
 		goto cleanup;
 
@@ -49,7 +49,7 @@ static int use_remote(git_repository *repo, char *name)
 	if (error < 0)
 		goto cleanup;
 
-	error = git_remote_connect(remote, GIT_DIR_FETCH);
+	error = git_remote_connect(remote, GIT_DIRECTION_FETCH);
 	if (error < 0)
 		goto cleanup;
 
diff --git a/include/git2/net.h b/include/git2/net.h
index 734ee70..2543ff8 100644
--- a/include/git2/net.h
+++ b/include/git2/net.h
@@ -27,8 +27,10 @@ GIT_BEGIN_DECL
  * gets called.
  */
 
-#define GIT_DIR_FETCH 0
-#define GIT_DIR_PUSH 1
+typedef enum {
+	GIT_DIRECTION_FETCH = 0,
+	GIT_DIRECTION_PUSH  = 1
+} git_direction;
 
 
 /**
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 44390e7..e7d06b6 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -24,6 +24,7 @@
  */
 GIT_BEGIN_DECL
 
+typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
 /*
  * TODO: This functions still need to be implemented:
  * - _listcb/_foreach
@@ -71,7 +72,7 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
  * @param remote the remote
  * @return a pointer to the name
  */
-GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
 
 /**
  * Get the remote's url
@@ -79,7 +80,7 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
  * @param remote the remote
  * @return a pointer to the url
  */
-GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
 
 /**
  * Get the remote's url for pushing
@@ -87,7 +88,7 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
  * @param remote the remote
  * @return a pointer to the url or NULL if no special url for pushing is set
  */
-GIT_EXTERN(const char *) git_remote_pushurl(git_remote *remote);
+GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
 
 /**
  * Set the remote's url
@@ -126,7 +127,7 @@ GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
  * @param remote the remote
  * @return a pointer to the fetch refspec or NULL if it doesn't exist
  */
-GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_fetchspec(const git_remote *remote);
 
 /**
  * Set the remote's push refspec
@@ -144,7 +145,7 @@ GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
  * @return a pointer to the push refspec or NULL if it doesn't exist
  */
 
-GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
+GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
 
 /**
  * Open a connection to a remote
@@ -157,7 +158,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
  * @param direction whether you want to receive or send data
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
+GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
 
 /**
  * Get a list of refs at the remote
@@ -194,7 +195,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void 
 GIT_EXTERN(int) git_remote_download(
 		git_remote *remote,
 		git_transfer_progress_callback progress_cb,
-		void *progress_payload);
+		void *payload);
 
 /**
  * Check whether the remote is connected
@@ -266,11 +267,11 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
  *
  * The string array must be freed by the user.
  *
- * @param remotes_list a string array with the names of the remotes
+ * @param out a string array which receives the names of the remotes
  * @param repo the repository to query
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
+GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
 
 /**
  * Add a remote with the default fetch refspec to the repository's configuration
@@ -340,7 +341,7 @@ struct git_remote_callbacks {
 	void (*progress)(const char *str, int len, void *data);
 	int (*completion)(git_remote_completion_type type, void *data);
 	int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
-	void *data;
+	void *payload;
 };
 
 /**
@@ -398,7 +399,7 @@ GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
 GIT_EXTERN(int) git_remote_rename(
 	git_remote *remote,
 	const char *new_name,
-	int (*callback)(const char *problematic_refspec, void *payload),
+	git_remote_rename_problem_cb callback,
 	void *payload);
 
 /**
diff --git a/src/clone.c b/src/clone.c
index c90d854..7d49b39 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -278,7 +278,7 @@ static int setup_remotes_and_fetch(
 		git_remote_set_update_fetchhead(origin, 0);
 
 		/* Connect and download everything */
-		if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
+		if (!git_remote_connect(origin, GIT_DIRECTION_FETCH)) {
 			if (!git_remote_download(origin, progress_cb, progress_payload)) {
 				/* Create "origin/foo" branches for all remote branches */
 				if (!git_remote_update_tips(origin)) {
diff --git a/src/remote.c b/src/remote.c
index 5035588..2f7c894 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -252,7 +252,7 @@ static int update_config_refspec(
 		&name,
 		"remote.%s.%s",
 		remote_name,
-		git_direction == GIT_DIR_FETCH ? "fetch" : "push") < 0)
+		git_direction == GIT_DIRECTION_FETCH ? "fetch" : "push") < 0)
 			goto cleanup;
 
 	if (git_refspec__serialize(&value, refspec) < 0)
@@ -318,14 +318,14 @@ int git_remote_save(const git_remote *remote)
 		config,
 		remote->name,
 		&remote->fetch,
-		GIT_DIR_FETCH) < 0)
+		GIT_DIRECTION_FETCH) < 0)
 			goto on_error;
 
 	if (update_config_refspec(
 		config,
 		remote->name,
 		&remote->push,
-		GIT_DIR_PUSH) < 0)
+		GIT_DIRECTION_PUSH) < 0)
 			goto on_error;
 
 	/*
@@ -369,13 +369,13 @@ on_error:
 	return -1;
 }
 
-const char *git_remote_name(git_remote *remote)
+const char *git_remote_name(const git_remote *remote)
 {
 	assert(remote);
 	return remote->name;
 }
 
-const char *git_remote_url(git_remote *remote)
+const char *git_remote_url(const git_remote *remote)
 {
 	assert(remote);
 	return remote->url;
@@ -393,7 +393,7 @@ int git_remote_set_url(git_remote *remote, const char* url)
 	return 0;
 }
 
-const char *git_remote_pushurl(git_remote *remote)
+const char *git_remote_pushurl(const git_remote *remote)
 {
 	assert(remote);
 	return remote->pushurl;
@@ -429,7 +429,7 @@ int git_remote_set_fetchspec(git_remote *remote, const char *spec)
 	return 0;
 }
 
-const git_refspec *git_remote_fetchspec(git_remote *remote)
+const git_refspec *git_remote_fetchspec(const git_remote *remote)
 {
 	assert(remote);
 	return &remote->fetch;
@@ -451,7 +451,7 @@ int git_remote_set_pushspec(git_remote *remote, const char *spec)
 	return 0;
 }
 
-const git_refspec *git_remote_pushspec(git_remote *remote)
+const git_refspec *git_remote_pushspec(const git_remote *remote)
 {
 	assert(remote);
 	return &remote->push;
@@ -461,18 +461,18 @@ const char* git_remote__urlfordirection(git_remote *remote, int direction)
 {
 	assert(remote);
 
-	if (direction == GIT_DIR_FETCH) {
+	if (direction == GIT_DIRECTION_FETCH) {
 		return remote->url;
 	}
 
-	if (direction == GIT_DIR_PUSH) {
+	if (direction == GIT_DIRECTION_PUSH) {
 		return remote->pushurl ? remote->pushurl : remote->url;
 	}
 
 	return NULL;
 }
 
-int git_remote_connect(git_remote *remote, int direction)
+int git_remote_connect(git_remote *remote, git_direction direction)
 {
 	git_transport *t;
 	const char *url;
@@ -492,7 +492,7 @@ int git_remote_connect(git_remote *remote, int direction)
 		return -1;
 
 	if (t->set_callbacks &&
-		t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.data) < 0)
+		t->set_callbacks(t, remote->callbacks.progress, NULL, remote->callbacks.payload) < 0)
 		goto on_error;
 	
 	if (!remote->check_cert)
@@ -753,7 +753,7 @@ int git_remote_update_tips(git_remote *remote)
 		git_reference_free(ref);
 
 		if (remote->callbacks.update_tips != NULL) {
-			if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.data) < 0)
+			if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.payload) < 0)
 				goto on_error;
 		}
 	}
@@ -936,7 +936,7 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
 		remote->transport->set_callbacks(remote->transport,
 			remote->callbacks.progress,
 			NULL,
-			remote->callbacks.data);
+			remote->callbacks.payload);
 }
 
 void git_remote_set_cred_acquire_cb(
@@ -1194,7 +1194,7 @@ static int rename_fetch_refspecs(
 	if (git_repository_config__weakptr(&config, remote->repo) < 0)
 		goto cleanup;
 
-	error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIR_FETCH);
+	error = update_config_refspec(config, new_name, &remote->fetch, GIT_DIRECTION_FETCH);
 
 cleanup:
 	git_buf_free(&serialized);
@@ -1205,7 +1205,7 @@ cleanup:
 int git_remote_rename(
 	git_remote *remote,
 	const char *new_name,
-	int (*callback)(const char *problematic_refspec, void *payload),
+	git_remote_rename_problem_cb callback,
 	void *payload)
 {
 	int error;
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 195ea28..e8dbbef 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -73,7 +73,7 @@ static int git_smart__connect(
 	t->flags = flags;
 	t->cred_acquire_cb = cred_acquire_cb;
 
-	if (GIT_DIR_FETCH == direction)
+	if (GIT_DIRECTION_FETCH == direction)
 	{
 		if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK_LS)) < 0)
 			return error;
@@ -159,7 +159,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
 	if (t->rpc)
 		git_smart__reset_stream(t);
 
-	if (GIT_DIR_FETCH == t->direction) {
+	if (GIT_DIRECTION_FETCH == t->direction) {
 		if ((error = t->wrapped->action(&stream, t->wrapped, t->url, GIT_SERVICE_UPLOADPACK)) < 0)
 			return error;
 
diff --git a/tests-clar/fetchhead/network.c b/tests-clar/fetchhead/network.c
index 0710480..46cb977 100644
--- a/tests-clar/fetchhead/network.c
+++ b/tests-clar/fetchhead/network.c
@@ -46,7 +46,7 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet
 	if(fetchspec != NULL)
 		git_remote_set_fetchspec(remote, fetchspec);
 
-	cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(remote, NULL, NULL));
 	cl_git_pass(git_remote_update_tips(remote));
 	git_remote_disconnect(remote);
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index a575b18..81a0eed 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -46,7 +46,7 @@ static void do_fetch(const char *url, int flag, int n)
 	cl_git_pass(git_remote_add(&remote, _repo, "test", url));
 	git_remote_set_callbacks(remote, &callbacks);
 	git_remote_set_autotag(remote, flag);
-	cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(remote, progress, &bytes_received));
 	git_remote_disconnect(remote);
 	cl_git_pass(git_remote_update_tips(remote));
diff --git a/tests-clar/network/fetchlocal.c b/tests-clar/network/fetchlocal.c
index a0369d0..018531c 100644
--- a/tests-clar/network/fetchlocal.c
+++ b/tests-clar/network/fetchlocal.c
@@ -22,7 +22,7 @@ void test_network_fetchlocal__complete(void)
 	cl_git_pass(git_repository_init(&repo, "foo", true));
 
 	cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
-	cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
+	cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
 	cl_git_pass(git_remote_update_tips(origin));
 
@@ -48,7 +48,7 @@ void test_network_fetchlocal__partial(void)
 
 	url = cl_git_fixture_url("testrepo.git");
 	cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
-	cl_git_pass(git_remote_connect(origin, GIT_DIR_FETCH));
+	cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH));
 	cl_git_pass(git_remote_download(origin, transfer_cb, &callcount));
 	cl_git_pass(git_remote_update_tips(origin));
 
diff --git a/tests-clar/network/refspecs.c b/tests-clar/network/refspecs.c
index 3b12817..b3d80fb 100644
--- a/tests-clar/network/refspecs.c
+++ b/tests-clar/network/refspecs.c
@@ -7,7 +7,7 @@ static void assert_refspec(unsigned int direction, const char *input, bool is_ex
 	git_refspec refspec;
 	int error;
 
-	error = git_refspec__parse(&refspec, input, direction == GIT_DIR_FETCH);
+	error = git_refspec__parse(&refspec, input, direction == GIT_DIRECTION_FETCH);
 	git_refspec__free(&refspec);
 
 	if (is_expected_to_be_valid)
@@ -20,19 +20,19 @@ void test_network_refspecs__parsing(void)
 {
 	// Ported from https://github.com/git/git/blob/abd2bde78bd994166900290434a2048e660dabed/t/t5511-refspec.sh
 
-	assert_refspec(GIT_DIR_PUSH, "", false);
-	assert_refspec(GIT_DIR_PUSH, ":", true);
-	assert_refspec(GIT_DIR_PUSH, "::", false);
-	assert_refspec(GIT_DIR_PUSH, "+:", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "", false);
+	assert_refspec(GIT_DIRECTION_PUSH, ":", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "::", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "+:", true);
 
-	assert_refspec(GIT_DIR_FETCH, "", true);
-	assert_refspec(GIT_DIR_PUSH, ":", true);
-	assert_refspec(GIT_DIR_FETCH, "::", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "", true);
+	assert_refspec(GIT_DIRECTION_PUSH, ":", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "::", false);
 
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/*:refs/remotes/frotz", false);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads:refs/remotes/frotz/*", false);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz/*", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*:refs/remotes/frotz", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads:refs/remotes/frotz/*", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
 
 	/*
 	 * These have invalid LHS, but we do not have a formal "valid sha-1
@@ -40,45 +40,45 @@ void test_network_refspecs__parsing(void)
 	 * code.  They will be caught downstream anyway, but we may want to
 	 * have tighter check later...
 	 */
-	//assert_refspec(GIT_DIR_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
-	//assert_refspec(GIT_DIR_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
-
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/*:refs/remotes/frotz", false);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads:refs/remotes/frotz/*", false);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
-
-	assert_refspec(GIT_DIR_PUSH, "master~1:refs/remotes/frotz/backup", true);
-	assert_refspec(GIT_DIR_FETCH, "master~1:refs/remotes/frotz/backup", false);
-	assert_refspec(GIT_DIR_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
-	assert_refspec(GIT_DIR_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
-
-	assert_refspec(GIT_DIR_PUSH, "HEAD", true);
-	assert_refspec(GIT_DIR_FETCH, "HEAD", true);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol", false);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol", false);
-
-	assert_refspec(GIT_DIR_PUSH, "HEAD:", false);
-	assert_refspec(GIT_DIR_FETCH, "HEAD:", true);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/ nitfol:", false);
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/ nitfol:", false);
-
-	assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/deleteme", true);
-	assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
-	assert_refspec(GIT_DIR_PUSH, ":refs/remotes/frotz/delete me", false);
-	assert_refspec(GIT_DIR_FETCH, ":refs/remotes/frotz/HEAD to me", false);
-
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
-
-	assert_refspec(GIT_DIR_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
-
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
-
-	assert_refspec(GIT_DIR_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
-	assert_refspec(GIT_DIR_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
+	//assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
+	//assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz/*", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*:refs/remotes/frotz", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads:refs/remotes/frotz/*", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master:refs/remotes/frotz/xyzzy", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/master::refs/remotes/frotz/xyzzy", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/maste :refs/remotes/frotz/xyzzy", false);
+
+	assert_refspec(GIT_DIRECTION_PUSH, "master~1:refs/remotes/frotz/backup", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "master~1:refs/remotes/frotz/backup", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "HEAD~4:refs/remotes/frotz/new", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "HEAD~4:refs/remotes/frotz/new", false);
+
+	assert_refspec(GIT_DIRECTION_PUSH, "HEAD", true);
+	assert_refspec(GIT_DIRECTION_FETCH, "HEAD", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol", false);
+
+	assert_refspec(GIT_DIRECTION_PUSH, "HEAD:", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "HEAD:", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/ nitfol:", false);
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/ nitfol:", false);
+
+	assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/deleteme", true);
+	assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD-to-me", true);
+	assert_refspec(GIT_DIRECTION_PUSH, ":refs/remotes/frotz/delete me", false);
+	assert_refspec(GIT_DIRECTION_FETCH, ":refs/remotes/frotz/HEAD to me", false);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*-blah", false);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads*/for-linus:refs/remotes/mine/*", false);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/*/for-linus:refs/remotes/mine/*", false);
+
+	assert_refspec(GIT_DIRECTION_FETCH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
+	assert_refspec(GIT_DIRECTION_PUSH, "refs/heads/*/for-linus:refs/remotes/mine/*", true);
 }
diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c
index f7dcfc0..8376b8b 100644
--- a/tests-clar/network/remotelocal.c
+++ b/tests-clar/network/remotelocal.c
@@ -51,7 +51,7 @@ static void connect_to_local_repository(const char *local_repository)
 	git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
 
 	cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
-	cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
+	cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
 
 }
 
diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c
index 4fe3ebe..14fda16 100644
--- a/tests-clar/network/remotes.c
+++ b/tests-clar/network/remotes.c
@@ -33,9 +33,9 @@ void test_network_remotes__parsing(void)
 	cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
 	cl_assert(git_remote_pushurl(_remote) == NULL);
 
-	cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_FETCH),
+	cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_FETCH),
 					  "git://github.com/libgit2/libgit2");
-	cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIR_PUSH),
+	cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_PUSH),
 					  "git://github.com/libgit2/libgit2");
 
 	cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl"));
@@ -43,9 +43,9 @@ void test_network_remotes__parsing(void)
 	cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2");
 	cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2");
 
-	cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_FETCH),
+	cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_FETCH),
 					  "git://github.com/libgit2/fetchlibgit2");
-	cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIR_PUSH),
+	cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_PUSH),
 					  "git://github.com/libgit2/pushlibgit2");
 
 	git_remote_free(_remote2);