Commit b0233216691fc52c6886a7f53c650d56a651cc84

Vicent Marti 2011-06-12T11:40:14

Remove custom backends All the custom backend code will be moved to a separate project, together with the new MySQL backend.

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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
diff --git a/CMakeLists.txt b/CMakeLists.txt
index acac2a6..ace5a79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,28 +32,6 @@ ELSEIF ()
     SET(SHA1_TYPE "builtin" CACHE STRING "Which SHA1 implementation to use: builtin, ppc")
 ENDIF ()
 
-INCLUDE(FindPkgConfig)
-
-# Show SQLite3 settings in GUI (if they won't be found out)
-SET(SQLITE3_INCLUDE_DIRS "" CACHE PATH "SQLite include directory")
-SET(SQLITE3_LIBRARIES "" CACHE FILEPATH "SQLite library")
-
-# Are SQLite3 variables already set up? (poor Windows/no pkg-config/no sqlite3.pc)
-IF (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
-	SET(SQLITE3_FOUND 1)
-ENDIF ()
-
-# Try to find SQLite3 via pkg-config
-IF (PKG_CONFIG_FOUND AND NOT SQLITE3_FOUND)
-	pkg_check_modules(SQLITE3 sqlite3)
-ENDIF ()
-
-# Compile SQLite backend if SQLite3 is available
-IF (SQLITE3_FOUND)
-	ADD_DEFINITIONS(-DGIT2_SQLITE_BACKEND)
-	INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIRS})
-ENDIF ()
-
 # Installation paths
 SET(INSTALL_BIN bin CACHE PATH "Where to install binaries to.")
 SET(INSTALL_LIB lib CACHE PATH "Where to install libraries to.")
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 796d2b9..43a1c2d 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -110,10 +110,8 @@ typedef enum {
 	GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
 } git_odb_streammode;
 
-
 GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
 GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir);
-GIT_EXTERN(int) git_odb_backend_sqlite(git_odb_backend **backend_out, const char *sqlite_db);
 
 GIT_END_DECL
 
diff --git a/src/backends/hiredis.c b/src/backends/hiredis.c
deleted file mode 100644
index 111abf7..0000000
--- a/src/backends/hiredis.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file.  (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "common.h"
-#include "git2/object.h"
-#include "hash.h"
-#include "odb.h"
-
-#include "git2/odb_backend.h"
-
-#ifdef GIT2_HIREDIS_BACKEND
-
-#include <hiredis/hiredis.h>
-
-typedef struct {
-    git_odb_backend parent;
-
-    redisContext *db;
-} hiredis_backend;
-
-int hiredis_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *_backend, const git_oid *oid) {
-    hiredis_backend *backend;
-    int error;
-    redisReply *reply;
-
-    assert(len_p && type_p && _backend && oid);
-
-    backend = (hiredis_backend *) _backend;
-    error = GIT_ERROR;
-
-    reply = redisCommand(backend->db, "HMGET %b %s %s", oid->id, GIT_OID_RAWSZ,
-            "type", "size");
-
-    if (reply && reply->type == REDIS_REPLY_ARRAY) {
-        if (reply->element[0]->type != REDIS_REPLY_NIL &&
-                reply->element[0]->type != REDIS_REPLY_NIL) {
-            *type_p = (git_otype) atoi(reply->element[0]->str);
-            *len_p = (size_t) atoi(reply->element[1]->str);
-            error = GIT_SUCCESS;
-        } else {
-            error = GIT_ENOTFOUND;
-        }
-    } else {
-        error = GIT_ERROR;
-    }
-
-    freeReplyObject(reply);
-    return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to read header");
-}
-
-int hiredis_backend__read(void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *_backend, const git_oid *oid) {
-    hiredis_backend *backend;
-    int error;
-    redisReply *reply;
-
-    assert(data_p && len_p && type_p && _backend && oid);
-
-    backend = (hiredis_backend *) _backend;
-    error = GIT_ERROR;
-
-    reply = redisCommand(backend->db, "HMGET %b %s %s %s", oid->id, GIT_OID_RAWSZ,
-            "type", "size", "data");
-
-    if (reply && reply->type == REDIS_REPLY_ARRAY) {
-        if (reply->element[0]->type != REDIS_REPLY_NIL &&
-                reply->element[1]->type != REDIS_REPLY_NIL &&
-                reply->element[2]->type != REDIS_REPLY_NIL) {
-            *type_p = (git_otype) atoi(reply->element[0]->str);
-            *len_p = (size_t) atoi(reply->element[1]->str);
-            *data_p = git__malloc(*len_p);
-            if (*data_p == NULL) {
-                error = GIT_ENOMEM;
-            } else {
-                memcpy(*data_p, reply->element[2]->str, *len_p);
-                error = GIT_SUCCESS;
-            }
-        } else {
-            error = GIT_ENOTFOUND;
-        }
-    } else {
-        error = GIT_ERROR;
-    }
-
-    freeReplyObject(reply);
-    return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to read backend");
-}
-
-int hiredis_backend__read_prefix(git_oid *out_oid, void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *_backend,
-					const git_oid *short_oid, unsigned int len) {
-	if (len >= GIT_OID_HEXSZ) {
-		/* Just match the full identifier */
-		int error = hiredis_backend__read(data_p, len_p, type_p, backend, short_oid);
-		if (error == GIT_SUCCESS)
-			git_oid_cpy(out_oid, short_oid);
-
-		return error;
-	} else if (len < GIT_OID_HEXSZ) {
-		/* TODO */
-		return git__throw(GIT_ENOTIMPLEMENTED, "Hiredis backend cannot search objects from short oid");
-	}
-}
-
-int hiredis_backend__exists(git_odb_backend *_backend, const git_oid *oid) {
-    hiredis_backend *backend;
-    int found;
-    redisReply *reply;
-
-    assert(_backend && oid);
-
-    backend = (hiredis_backend *) _backend;
-    found = 0;
-
-    reply = redisCommand(backend->db, "exists %b", oid->id, GIT_OID_RAWSZ);
-    if (reply && reply->type != REDIS_REPLY_NIL && reply->type != REDIS_REPLY_ERROR)
-        found = 1;
-
-
-    freeReplyObject(reply);
-    return found;
-}
-
-int hiredis_backend__write(git_oid *id, git_odb_backend *_backend, const void *data, size_t len, git_otype type) {
-    hiredis_backend *backend;
-    int error;
-    redisReply *reply;
-
-    assert(id && _backend && data);
-
-    backend = (hiredis_backend *) _backend;
-    error = GIT_ERROR;
-
-    if ((error = git_odb_hash(id, data, len, type)) < 0)
-        return git__rethrow(error, "Failed to write backend");
-
-    reply = redisCommand(backend->db, "HMSET %b "
-            "type %d "
-            "size %d "
-            "data %b ", id->id, GIT_OID_RAWSZ,
-            (int) type, len, data, len);
-
-    error = (reply == NULL || reply->type == REDIS_REPLY_ERROR) ? GIT_ERROR : GIT_SUCCESS;
-
-    freeReplyObject(reply);
-    return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to write backend");
-}
-
-void hiredis_backend__free(git_odb_backend *_backend) {
-    hiredis_backend *backend;
-    assert(_backend);
-    backend = (hiredis_backend *) _backend;
-
-    redisFree(backend->db);
-
-    free(backend);
-}
-
-int git_odb_backend_hiredis(git_odb_backend **backend_out, const char *host, int port) {
-    hiredis_backend *backend;
-
-    backend = git__calloc(1, sizeof (hiredis_backend));
-    if (backend == NULL)
-        return GIT_ENOMEM;
-
-
-    backend->db = redisConnect(host, port);
-    if (backend->db->err)
-        goto cleanup;
-
-    backend->parent.read = &hiredis_backend__read;
-    backend->parent.read_prefix = &hiredis_backend__read_prefix;
-    backend->parent.read_header = &hiredis_backend__read_header;
-    backend->parent.write = &hiredis_backend__write;
-    backend->parent.exists = &hiredis_backend__exists;
-    backend->parent.free = &hiredis_backend__free;
-
-    *backend_out = (git_odb_backend *) backend;
-
-    return GIT_SUCCESS;
-cleanup:
-    free(backend);
-    return git__throw(GIT_ERROR, "Failed to get ODB backend");
-}
-
-#else
-
-int git_odb_backend_hiredis(git_odb_backend ** GIT_UNUSED(backend_out),
-        const char *GIT_UNUSED(host), int GIT_UNUSED(port)) {
-    GIT_UNUSED_ARG(backend_out);
-    GIT_UNUSED_ARG(host);
-    GIT_UNUSED_ARG(port);
-    return git__throw(GIT_ENOTIMPLEMENTED, "Failed to get ODB backend. Feature not yet implemented");
-}
-
-
-#endif /* HAVE_HIREDIS */
diff --git a/src/backends/sqlite.c b/src/backends/sqlite.c
deleted file mode 100644
index 8626349..0000000
--- a/src/backends/sqlite.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file.  (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "common.h"
-#include "git2/object.h"
-#include "hash.h"
-#include "odb.h"
-
-#include "git2/odb_backend.h"
-
-#ifdef GIT2_SQLITE_BACKEND
-
-#include <sqlite3.h>
-
-#define GIT2_TABLE_NAME "git2_odb"
-
-typedef struct {
-	git_odb_backend parent;
-	sqlite3 *db;
-	sqlite3_stmt *st_read;
-	sqlite3_stmt *st_write;
-	sqlite3_stmt *st_read_header;
-} sqlite_backend;
-
-int sqlite_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *_backend, const git_oid *oid)
-{
-	sqlite_backend *backend;
-	int error;
-
-	assert(len_p && type_p && _backend && oid);
-
-	backend = (sqlite_backend *)_backend;
-	error = GIT_ERROR;
-
-	if (sqlite3_bind_text(backend->st_read_header, 1, (char *)oid->id, 20, SQLITE_TRANSIENT) == SQLITE_OK) {
-		if (sqlite3_step(backend->st_read_header) == SQLITE_ROW) {
-			*type_p = (git_otype)sqlite3_column_int(backend->st_read_header, 0);
-			*len_p = (size_t)sqlite3_column_int(backend->st_read_header, 1);
-			assert(sqlite3_step(backend->st_read_header) == SQLITE_DONE);
-			error = GIT_SUCCESS;
-		} else {
-			error = GIT_ENOTFOUND;
-		}
-	}
-
-	sqlite3_reset(backend->st_read_header);
-	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "SQLite backend: Failed to read header");
-}
-
-
-int sqlite_backend__read(void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *_backend, const git_oid *oid)
-{
-	sqlite_backend *backend;
-	int error;
-
-	assert(data_p && len_p && type_p && _backend && oid);
-
-	backend = (sqlite_backend *)_backend;
-	error = GIT_ERROR;
-
-	if (sqlite3_bind_text(backend->st_read, 1, (char *)oid->id, 20, SQLITE_TRANSIENT) == SQLITE_OK) {
-		if (sqlite3_step(backend->st_read) == SQLITE_ROW) {
-			*type_p = (git_otype)sqlite3_column_int(backend->st_read, 0);
-			*len_p = (size_t)sqlite3_column_int(backend->st_read, 1);
-			*data_p = git__malloc(*len_p);
-
-			if (*data_p == NULL) {
-				error = GIT_ENOMEM;
-			} else {
-				memcpy(*data_p, sqlite3_column_blob(backend->st_read, 2), *len_p);
-				error = GIT_SUCCESS;
-			}
-
-			assert(sqlite3_step(backend->st_read) == SQLITE_DONE);
-		} else {
-			error = GIT_ENOTFOUND;
-		}
-	}
-
-	sqlite3_reset(backend->st_read);
-	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "SQLite backend: Failed to read");
-}
-
-int sqlite_backend__read_prefix(git_oid *out_oid, void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *_backend,
-					const git_oid *short_oid, unsigned int len) {
-	if (len >= GIT_OID_HEXSZ) {
-		/* Just match the full identifier */
-		int error = sqlite_backend__read(data_p, len_p, type_p, _backend, short_oid);
-		if (error == GIT_SUCCESS)
-			git_oid_cpy(out_oid, short_oid);
-
-		return error;
-	} else if (len < GIT_OID_HEXSZ) {
-		/* TODO */
-		return git__throw(GIT_ENOTIMPLEMENTED, "Sqlite backend cannot search objects from short oid");
-	}
-}
-
-int sqlite_backend__exists(git_odb_backend *_backend, const git_oid *oid)
-{
-	sqlite_backend *backend;
-	int found;
-
-	assert(_backend && oid);
-
-	backend = (sqlite_backend *)_backend;
-	found = 0;
-
-	if (sqlite3_bind_text(backend->st_read_header, 1, (char *)oid->id, 20, SQLITE_TRANSIENT) == SQLITE_OK) {
-		if (sqlite3_step(backend->st_read_header) == SQLITE_ROW) {
-			found = 1;
-			assert(sqlite3_step(backend->st_read_header) == SQLITE_DONE);
-		}
-	}
-
-	sqlite3_reset(backend->st_read_header);
-	return found;
-}
-
-
-int sqlite_backend__write(git_oid *id, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
-{
-	int error;
-	sqlite_backend *backend;
-
-	assert(id && _backend && data);
-
-	backend = (sqlite_backend *)_backend;
-
-	if ((error = git_odb_hash(id, data, len, type)) < 0)
-		return git__rethrow(error, "SQLite backend: Failed to write");
-
-	error = SQLITE_ERROR;
-
-	if (sqlite3_bind_text(backend->st_write, 1, (char *)id->id, 20, SQLITE_TRANSIENT) == SQLITE_OK &&
-		sqlite3_bind_int(backend->st_write, 2, (int)type) == SQLITE_OK &&
-		sqlite3_bind_int(backend->st_write, 3, len) == SQLITE_OK &&
-		sqlite3_bind_blob(backend->st_write, 4, data, len, SQLITE_TRANSIENT) == SQLITE_OK) {
-		error = sqlite3_step(backend->st_write);
-	}
-
-	sqlite3_reset(backend->st_write);
-	return (error == SQLITE_DONE) ? GIT_SUCCESS : git__throw(GIT_ERROR, "SQLite backend: Failed to write");
-}
-
-
-void sqlite_backend__free(git_odb_backend *_backend)
-{
-	sqlite_backend *backend;
-	assert(_backend);
-	backend = (sqlite_backend *)_backend;
-
-	sqlite3_finalize(backend->st_read);
-	sqlite3_finalize(backend->st_read_header);
-	sqlite3_finalize(backend->st_write);
-	sqlite3_close(backend->db);
-
-	free(backend);
-}
-
-static int create_table(sqlite3 *db)
-{
-	static const char *sql_creat =
-		"CREATE TABLE '" GIT2_TABLE_NAME "' ("
-		"'oid' CHARACTER(20) PRIMARY KEY NOT NULL,"
-		"'type' INTEGER NOT NULL,"
-		"'size' INTEGER NOT NULL,"
-		"'data' BLOB);";
-
-	if (sqlite3_exec(db, sql_creat, NULL, NULL, NULL) != SQLITE_OK)
-		return git__throw(GIT_ERROR, "SQLite backend: Failed to create table");
-
-	return GIT_SUCCESS;
-}
-
-static int init_db(sqlite3 *db)
-{
-	static const char *sql_check =
-		"SELECT name FROM sqlite_master WHERE type='table' AND name='" GIT2_TABLE_NAME "';";
-
-	sqlite3_stmt *st_check;
-	int error;
-
-	if (sqlite3_prepare_v2(db, sql_check, -1, &st_check, NULL) != SQLITE_OK)
-		return git__throw(GIT_ERROR, "SQLite backend: Failed to initialize database");
-
-	switch (sqlite3_step(st_check)) {
-	case SQLITE_DONE:
-		/* the table was not found */
-		error = create_table(db);
-		break;
-
-	case SQLITE_ROW:
-		/* the table was found */
-		error = GIT_SUCCESS;
-		break;
-
-	default:
-		error = GIT_ERROR;
-		break;
-	}
-
-	sqlite3_finalize(st_check);
-	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "SQLite backend: Failed to initialize database");
-}
-
-static int init_statements(sqlite_backend *backend)
-{
-	static const char *sql_read =
-		"SELECT type, size, data FROM '" GIT2_TABLE_NAME "' WHERE oid = ?;";
-
-	static const char *sql_read_header =
-		"SELECT type, size FROM '" GIT2_TABLE_NAME "' WHERE oid = ?;";
-
-	static const char *sql_write =
-		"INSERT OR IGNORE INTO '" GIT2_TABLE_NAME "' VALUES (?, ?, ?, ?);";
-
-	if (sqlite3_prepare_v2(backend->db, sql_read, -1, &backend->st_read, NULL) != SQLITE_OK)
-		return git__throw(GIT_ERROR, "SQLite backend: Failed to initialize statements");
-
-	if (sqlite3_prepare_v2(backend->db, sql_read_header, -1, &backend->st_read_header, NULL) != SQLITE_OK)
-		return git__throw(GIT_ERROR, "SQLite backend: Failed to initialize statements");
-
-	if (sqlite3_prepare_v2(backend->db, sql_write, -1, &backend->st_write, NULL) != SQLITE_OK)
-		return git__throw(GIT_ERROR, "SQLite backend: Failed to initialize statements");
-
-	return GIT_SUCCESS;
-}
-
-int git_odb_backend_sqlite(git_odb_backend **backend_out, const char *sqlite_db)
-{
-	sqlite_backend *backend;
-	int error;
-
-	backend = git__calloc(1, sizeof(sqlite_backend));
-	if (backend == NULL)
-		return GIT_ENOMEM;
-
-	if (sqlite3_open(sqlite_db, &backend->db) != SQLITE_OK)
-		goto cleanup;
-
-	error = init_db(backend->db);
-	if (error < 0)
-		goto cleanup;
-
-	error = init_statements(backend);
-	if (error < 0)
-		goto cleanup;
-
-	backend->parent.read = &sqlite_backend__read;
-	backend->parent.read_prefix = &sqlite_backend__read_prefix;
-	backend->parent.read_header = &sqlite_backend__read_header;
-	backend->parent.write = &sqlite_backend__write;
-	backend->parent.exists = &sqlite_backend__exists;
-	backend->parent.free = &sqlite_backend__free;
-
-	*backend_out = (git_odb_backend *)backend;
-	return GIT_SUCCESS;
-
-cleanup:
-	sqlite_backend__free((git_odb_backend *)backend);
-	return git__throw(GIT_ERROR, "SQLite backend: Failed to get ODB backend");
-}
-
-#else
-
-int git_odb_backend_sqlite(git_odb_backend **GIT_UNUSED(backend_out), const char *GIT_UNUSED(sqlite_db))
-{
-	GIT_UNUSED_ARG(backend_out);
-	GIT_UNUSED_ARG(sqlite_db);
-	return git__throw(GIT_ENOTIMPLEMENTED, "SQLite backend: Failed to get ODB backend. Operation not yet implemented");
-}
-
-#endif /* HAVE_SQLITE3 */
diff --git a/tests/t11-sqlite.c b/tests/t11-sqlite.c
deleted file mode 100644
index e9e08ac..0000000
--- a/tests/t11-sqlite.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file.  (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "test_lib.h"
-#include "odb.h"
-
-#ifdef GIT2_SQLITE_BACKEND
-#include "t03-data.h"
-#include "fileops.h"
-#include "git2/odb_backend.h"
-
-
-static int cmp_objects(git_odb_object *odb_obj, git_rawobj *raw)
-{
-	if (raw->type != git_odb_object_type(odb_obj))
-		return -1;
-
-	if (raw->len != git_odb_object_size(odb_obj))
-		return -1;
-
-	if ((raw->len > 0) && (memcmp(raw->data, git_odb_object_data(odb_obj), raw->len) != 0))
-		return -1;
-
-	return 0;
-}
-
-static git_odb *open_sqlite_odb(void)
-{
-	git_odb *odb;
-	git_odb_backend *sqlite;
-
-	if (git_odb_new(&odb) < GIT_SUCCESS)
-		return NULL;
-
-	if (git_odb_backend_sqlite(&sqlite, ":memory:") < GIT_SUCCESS)
-		return NULL;
-
-	if (git_odb_add_backend(odb, sqlite, 0) < GIT_SUCCESS)
-		return NULL;
-
-	return odb;
-}
-
-#define TEST_WRITE(PTR) {\
-    git_odb *db; \
-	git_oid id1, id2; \
-    git_odb_object *obj; \
-	db = open_sqlite_odb(); \
-	must_be_true(db != NULL); \
-    must_pass(git_oid_mkstr(&id1, PTR.id)); \
-    must_pass(git_odb_write(&id2, db, PTR##_obj.data, PTR##_obj.len, PTR##_obj.type)); \
-    must_be_true(git_oid_cmp(&id1, &id2) == 0); \
-    must_pass(git_odb_read(&obj, db, &id1)); \
-    must_pass(cmp_objects(obj, &PTR##_obj)); \
-    git_odb_object_close(obj); \
-    git_odb_close(db); \
-}
-
-BEGIN_TEST(sqlite0, "write a commit, read it back (sqlite backend)")
-	TEST_WRITE(commit);
-END_TEST
-
-BEGIN_TEST(sqlite1, "write a tree, read it back (sqlite backend)")
-	TEST_WRITE(tree);
-END_TEST
-
-BEGIN_TEST(sqlite2, "write a tag, read it back (sqlite backend)")
-	TEST_WRITE(tag);
-END_TEST
-
-BEGIN_TEST(sqlite3, "write a zero-byte entry, read it back (sqlite backend)")
-	TEST_WRITE(zero);
-END_TEST
-
-BEGIN_TEST(sqlite4, "write a one-byte entry, read it back (sqlite backend)")
-	TEST_WRITE(one);
-END_TEST
-
-BEGIN_TEST(sqlite5, "write a two-byte entry, read it back (sqlite backend)")
-	TEST_WRITE(two);
-END_TEST
-
-BEGIN_TEST(sqlite6, "write some bytes in an entry, read it back (sqlite backend)")
-	TEST_WRITE(some);
-END_TEST
-
-
-BEGIN_SUITE(sqlite)
-	ADD_TEST(sqlite0);
-	ADD_TEST(sqlite1);
-	ADD_TEST(sqlite2);
-	ADD_TEST(sqlite3);
-	ADD_TEST(sqlite4);
-	ADD_TEST(sqlite5);
-	ADD_TEST(sqlite6);
-END_SUITE
-
-#else /* no sqlite builtin */
-BEGIN_SUITE(sqlite)
-	/* empty */
-END_SUITE
-#endif
-
-
-
diff --git a/tests/t14-hiredis.c b/tests/t14-hiredis.c
deleted file mode 100644
index c743f7d..0000000
--- a/tests/t14-hiredis.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2,
- * as published by the Free Software Foundation.
- *
- * In addition to the permissions in the GNU General Public License,
- * the authors give you unlimited permission to link the compiled
- * version of this file into combinations with other programs,
- * and to distribute those combinations without any restriction
- * coming from the use of this file.  (The General Public License
- * restrictions do apply in other respects; for example, they cover
- * modification of the file, and distribution when not linked into
- * a combined executable.)
- *
- * This file is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; see the file COPYING.  If not, write to
- * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "test_lib.h"
-#include "odb.h"
-
-#ifdef GIT2_HIREDIS_BACKEND
-#include "t03-data.h"
-#include "fileops.h"
-#include "git2/odb_backend.h"
-
-
-static int cmp_objects(git_odb_object *odb_obj, git_rawobj *raw)
-{
-	if (raw->type != git_odb_object_type(odb_obj))
-		return -1;
-
-	if (raw->len != git_odb_object_size(odb_obj))
-		return -1;
-
-	if ((raw->len > 0) && (memcmp(raw->data, git_odb_object_data(odb_obj), raw->len) != 0))
-		return -1;
-
-	return 0;
-}
-
-static git_odb *open_hiredis_odb(void)
-{
-	git_odb *odb;
-	git_odb_backend *hiredis;
-
-	if (git_odb_new(&odb) < GIT_SUCCESS)
-		return NULL;
-
-	if (git_odb_backend_hiredis(&hiredis, "127.0.0.1", 6379) < GIT_SUCCESS)
-		return NULL;
-
-	if (git_odb_add_backend(odb, hiredis, 0) < GIT_SUCCESS)
-		return NULL;
-
-	return odb;
-}
-
-#define TEST_WRITE(PTR) {\
-    git_odb *db; \
-	git_oid id1, id2; \
-    git_odb_object *obj; \
-	db = open_hiredis_odb(); \
-	must_be_true(db != NULL); \
-    must_pass(git_oid_mkstr(&id1, PTR.id)); \
-    must_pass(git_odb_write(&id2, db, PTR##_obj.data, PTR##_obj.len, PTR##_obj.type)); \
-    must_be_true(git_oid_cmp(&id1, &id2) == 0); \
-    must_pass(git_odb_read(&obj, db, &id1)); \
-    must_pass(cmp_objects(obj, &PTR##_obj)); \
-    git_odb_object_close(obj); \
-    git_odb_close(db); \
-}
-
-BEGIN_TEST(hiredis0, "write a commit, read it back (hiredis backend)")
-	TEST_WRITE(commit);
-END_TEST
-
-BEGIN_TEST(hiredis1, "write a tree, read it back (hiredis backend)")
-	TEST_WRITE(tree);
-END_TEST
-
-BEGIN_TEST(hiredis2, "write a tag, read it back (hiredis backend)")
-	TEST_WRITE(tag);
-END_TEST
-
-BEGIN_TEST(hiredis3, "write a zero-byte entry, read it back (hiredis backend)")
-	TEST_WRITE(zero);
-END_TEST
-
-BEGIN_TEST(hiredis4, "write a one-byte entry, read it back (hiredis backend)")
-	TEST_WRITE(one);
-END_TEST
-
-BEGIN_TEST(hiredis5, "write a two-byte entry, read it back (hiredis backend)")
-	TEST_WRITE(two);
-END_TEST
-
-BEGIN_TEST(hiredis6, "write some bytes in an entry, read it back (hiredis backend)")
-	TEST_WRITE(some);
-END_TEST
-
-
-BEGIN_SUITE(hiredis)
-	ADD_TEST(hiredis0);
-	ADD_TEST(hiredis1);
-	ADD_TEST(hiredis2);
-	ADD_TEST(hiredis3);
-	ADD_TEST(hiredis4);
-	ADD_TEST(hiredis5);
-	ADD_TEST(hiredis6);
-END_SUITE
-
-#else /* no hiredis builtin */
-BEGIN_SUITE(hiredis)
-	/* empty */
-END_SUITE
-#endif
diff --git a/tests/test_main.c b/tests/test_main.c
index 0f5f16a..3fd117d 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -40,8 +40,6 @@ DECLARE_SUITE(hashtable);
 DECLARE_SUITE(tag);
 DECLARE_SUITE(tree);
 DECLARE_SUITE(refs);
-DECLARE_SUITE(sqlite);
-DECLARE_SUITE(hiredis);
 DECLARE_SUITE(repository);
 DECLARE_SUITE(threads);
 DECLARE_SUITE(config);
@@ -58,10 +56,8 @@ static libgit2_suite suite_methods[]= {
 	SUITE_NAME(tag),
 	SUITE_NAME(tree),
 	SUITE_NAME(refs),
-	SUITE_NAME(sqlite),
 	SUITE_NAME(repository),
 	SUITE_NAME(threads),
-	SUITE_NAME(hiredis),
 	SUITE_NAME(config),
 };
 
diff --git a/wscript b/wscript
index fd877e4..92f00da 100644
--- a/wscript
+++ b/wscript
@@ -17,7 +17,7 @@ CFLAGS_WIN32_L = ['/RELEASE']  # used for /both/ debug and release builds.
                                # sets the module's checksum in the header.
 CFLAGS_WIN32_L_DBG = ['/DEBUG']
 
-ALL_LIBS = ['crypto', 'pthread', 'sqlite3', 'hiredis']
+ALL_LIBS = ['crypto', 'pthread']
 
 def options(opt):
     opt.load('compiler_c')
@@ -30,10 +30,6 @@ PPC optimized version (ppc) or the SHA1 functions from OpenSSL (openssl)")
         help='Force a specific MSVC++ version (7.1, 8.0, 9.0, 10.0), if more than one is installed')
     opt.add_option('--arch', action='store', default='x86',
         help='Select target architecture (ia64, x64, x86, x86_amd64, x86_ia64)')
-    opt.add_option('--with-sqlite', action='store_true', default=False,
-        dest='use_sqlite', help='Enable sqlite support')
-    opt.add_option('--with-hiredis', action='store_true', default=False,
-        dest='use_hiredis', help='Enable redis support using hiredis')
     opt.add_option('--threadsafe', action='store_true', default=False,
         help='Make libgit2 thread-safe (requires pthreads)')
 
@@ -73,17 +69,6 @@ def configure(conf):
             conf.check_cc(lib='pthread', uselib_store='pthread')
         conf.env.DEFINES += ['GIT_THREADS']
 
-    # check for sqlite3
-    if conf.options.use_sqlite and conf.check_cc(
-        lib='sqlite3', uselib_store='sqlite3', install_path=None, mandatory=False):
-        conf.env.DEFINES += ['GIT2_SQLITE_BACKEND']
-
-    # check for hiredis
-    if conf.options.use_hiredis and conf.check_cc(
-        lib='hiredis', uselib_store='hiredis', install_path=None, mandatory=False):
-        conf.env.DEFINES += ['GIT2_HIREDIS_BACKEND']
-
-
     if conf.options.sha1 not in ['openssl', 'ppc', 'builtin']:
         conf.fatal('Invalid SHA1 option')
 
@@ -149,7 +134,6 @@ def build_library(bld, build_type):
     # E.g.  src/unix/*.c
     #       src/win32/*.c
     sources = sources + directory.ant_glob('src/%s/*.c' % bld.env.PLATFORM)
-    sources = sources + directory.ant_glob('src/backends/*.c')
     sources = sources + directory.ant_glob('deps/zlib/*.c')
 
     # SHA1 methods source