-
-
Notifications
You must be signed in to change notification settings - Fork 800
/
magit-libgit.el
88 lines (68 loc) · 2.74 KB
/
magit-libgit.el
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
;;; magit-libgit.el --- (POC) Teach Magit to use Libgit2 -*- lexical-binding:t -*-
;; Copyright (C) 2008-2023 The Magit Project Contributors
;; Author: Jonas Bernoulli <jonas@bernoul.li>
;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
;; Homepage: https://github.com/magit/magit
;; Keywords: git tools vc
;; Package-Version: 3.3.0.50-git
;; Package-Requires: (
;; (emacs "26.1")
;; (compat "29.1.3.4")
;; (libgit "0")
;; (seq "2.24")
;; (magit "3.3.0"))
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Magit is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation, either version 3 of the License,
;; or (at your option) any later version.
;;
;; Magit 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 Magit. If not, see <https://www.gnu.org/licenses/>.
;; You should have received a copy of the AUTHORS.md file, which
;; lists all contributors. If not, see https://magit.vc/authors.
;;; Commentary:
;; This package teaches Magit to use functions provided by the
;; `libegit2' module to perform certain tasks. That module used the
;; Libgit2 implementation of the Git core methods and is implemented
;; in the `libgit' package.
;; The hope is that using a C module instead of calling out to `git'
;; all the time increases performance; especially on Windows where
;; starting a process is unreasonably slow.
;; This package is still experimental and not many functions have been
;; reimplemented to use `libgit' yet.
;;; Code:
(require 'cl-lib)
(require 'compat)
(require 'dash)
(require 'eieio)
(require 'seq)
(require 'subr-x)
(require 'magit-git)
(require 'libgit)
;;; Utilities
(defun magit-libgit-repo (&optional directory)
"Return an object for the repository in DIRECTORY.
If optional DIRECTORY is nil, then use `default-directory'."
(and-let* ((default-directory
(let ((magit-inhibit-libgit t))
(magit-gitdir directory))))
(magit--with-refresh-cache
(cons default-directory 'magit-libgit-repo)
(libgit-repository-open default-directory))))
;;; Methods
(cl-defmethod magit-bare-repo-p
(&context ((magit-gitimpl) (eql libgit)) &optional noerror)
(and (magit--assert-default-directory noerror)
(if-let ((repo (magit-libgit-repo)))
(libgit-repository-bare-p repo)
(unless noerror
(signal 'magit-outside-git-repo default-directory)))))
;;; _
(provide 'magit-libgit)
;;; magit-libgit.el ends here