 		}
 	}
 }
+
+private extension Array {
+	func aggregateResult<Value, Error>() -> Result<[Value], Error> where Element == Result<Value, Error> {
+		var values: [Value] = []
+		for result in self {
+			switch result {
+			case .success(let value):
+				values.append(value)
+			case .failure(let error):
+				return .failure(error)
+			}
+		}
+		return .success(values)
+	}
+}

		git_strarray_free(pointer)
		pointer.deallocate()

		let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error }
		if let error = error {
			return Result.failure(error)
		}
		return Result.success(remotes.map { $0.value! })
	}

	private func remoteLookup<A>(named name: String, _ callback: (Result<OpaquePointer, NSError>) -> A) -> A {

		git_strarray_free(pointer)
		pointer.deallocate()

		return references.aggregateResult()
	}

	/// Load the reference with the given long name (e.g. "refs/heads/master")
