emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit eb56b14bcb 6/7: magit-clone: Add --filter to su


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit eb56b14bcb 6/7: magit-clone: Add --filter to support partial clones
Date: Sun, 23 Jan 2022 16:58:09 -0500 (EST)

branch: elpa/git-commit
commit eb56b14bcb61b8131a45e6113da770b2ef92c160
Author: Kyle Meyer <kyle@kyleam.com>
Commit: Kyle Meyer <kyle@kyleam.com>

    magit-clone: Add --filter to support partial clones
    
    Git gained partial clone support via its --filter argument in v2.17
    (undocumented until v2.27.0).  Add the option to the clone transient,
    along with a custom reader that offers the two mostly likely values of
    interest (blobless and treeless clones).  See git-rev-list's manpage
    for a complete description of the filter specification.
    
    Note that users should probably expect to hit into rough edges when
    working with a partial clone.  For example, without a connection,
    checking out a commit for which blobs need to be downloaded will
    "fail" in the sense that it the checkout command will emit errors and
    `git status' from the command line will show deleted files for files
    that couldn't be downloaded.  While that's not surprising, the
    checkout command has an exit status of 0 [*], so Magit users won't see
    an indication of the failure.  And worse, the deleted files won't show
    up in the status buffer because the underlying git-diff commands fail
    (for the same reason as the checkout: the required objects can't be
    downloaded).
    
    [*] I haven't yet reported this upstream, but it seems like a bug to
        me.
---
 docs/RelNotes/3.4.0.org |  4 ++++
 lisp/magit-clone.el     | 15 +++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/docs/RelNotes/3.4.0.org b/docs/RelNotes/3.4.0.org
index 86fa3c34de..a46e266fc4 100644
--- a/docs/RelNotes/3.4.0.org
+++ b/docs/RelNotes/3.4.0.org
@@ -20,6 +20,10 @@
   repository and then immediately enable a sparse checkout, avoiding a
   checkout of the full working tree.  #4102
 
+- The ~magit-clone~ transient now includes ~--filter~ (hidden by
+  default) to support partial cloning, a feature that is available as
+  of Git v2.17.  #4102
+
 ** Fixes since v3.3.0
 
 - Automatic saving of file-visiting buffers was broken inside remote
diff --git a/lisp/magit-clone.el b/lisp/magit-clone.el
index 91e06ce8d6..8f5e910b3c 100644
--- a/lisp/magit-clone.el
+++ b/lisp/magit-clone.el
@@ -117,6 +117,9 @@ the name of the owner.  Also see `magit-clone-name-alist'."
   ["Setup arguments"
    ("-o" "Set name of remote"     ("-o" "--origin="))
    ("-b" "Set HEAD branch"        ("-b" "--branch="))
+   (magit-clone:--filter
+    :if (lambda () (magit-git-version>= "2.17.0"))
+    :level 7)
    ("-g" "Separate git directory" "--separate-git-dir="
     transient-read-directory :level 7)
    ("-t" "Use template directory" "--template="
@@ -139,6 +142,18 @@ the name of the owner.  Also see `magit-clone-name-alist'."
       (transient-setup #'magit-clone)
     (call-interactively #'magit-clone-regular)))
 
+(transient-define-argument magit-clone:--filter ()
+  :description "Filter some objects"
+  :class 'transient-option
+  :key "-f"
+  :argument "--filter="
+  :reader 'magit-clone-read-filter)
+
+(defun magit-clone-read-filter (prompt initial-input history)
+  (magit-completing-read prompt
+                         (list "blob:none" "tree:0")
+                         nil nil initial-input history))
+
 ;;;###autoload
 (defun magit-clone-regular (repository directory args)
   "Create a clone of REPOSITORY in DIRECTORY.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]