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

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

[nongnu] elpa/git-commit 47075e2 3/3: Add support for "git bundle"


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 47075e2 3/3: Add support for "git bundle"
Date: Fri, 20 Aug 2021 16:57:22 -0400 (EDT)

branch: elpa/git-commit
commit 47075e21ba9a5592c5a06601d2e357a360bf8d37
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Add support for "git bundle"
    
    Closes #4392.
---
 Documentation/RelNotes/3.3.0.org |   3 +
 Documentation/magit.org          |  14 +++-
 Documentation/magit.texi         |  30 ++++++++-
 default.mk                       |   1 +
 lisp/Makefile                    |   1 +
 lisp/magit-bundle.el             | 135 +++++++++++++++++++++++++++++++++++++++
 lisp/magit-clone.el              |   5 +-
 7 files changed, 184 insertions(+), 5 deletions(-)

diff --git a/Documentation/RelNotes/3.3.0.org b/Documentation/RelNotes/3.3.0.org
index 6fe14dd..5c49131 100644
--- a/Documentation/RelNotes/3.3.0.org
+++ b/Documentation/RelNotes/3.3.0.org
@@ -29,6 +29,9 @@
 - Added new command ~magit-dired-am-apply-patches~ for use in Dired.
   #4094.
 
+- Added new tranient prefix command ~magit-bundle~, which provides
+  support for ~git bundle~.  #4392
+
 ** Fixes since v3.2.0
 
 - Make ~magit-branch-remote-head~ and ~magit-branch-current~ fall back
diff --git a/Documentation/magit.org b/Documentation/magit.org
index 621c695..9cd5ce0 100644
--- a/Documentation/magit.org
+++ b/Documentation/magit.org
@@ -8,7 +8,7 @@
 #+TEXINFO_DIR_CATEGORY: Emacs
 #+TEXINFO_DIR_TITLE: Magit: (magit).
 #+TEXINFO_DIR_DESC: Using Git from Emacs with Magit.
-#+SUBTITLE: for version 3.2.1 (v3.2.1-40-g678df30c3+1)
+#+SUBTITLE: for version 3.2.1 (v3.2.1-43-g534ef5a64+1)
 
 #+TEXINFO_DEFFN: t
 #+OPTIONS: H:4 num:3 toc:2
@@ -25,7 +25,7 @@ directly from within Emacs.  While many fine Git clients 
exist, only
 Magit and Git itself deserve to be called porcelains.
 
 #+TEXINFO: @noindent
-This manual is for Magit version 3.2.1 (v3.2.1-40-g678df30c3+1).
+This manual is for Magit version 3.2.1 (v3.2.1-43-g534ef5a64+1).
 
 #+BEGIN_QUOTE
 Copyright (C) 2015-2021 Jonas Bernoulli <jonas@bernoul.li>
@@ -6934,6 +6934,16 @@ Also see [[man:git-worktree]]
   If the worktree at point is the one whose status is already being
   displayed in the current buffer, then show it in Dired instead.
 
+** Bundle
+
+Also see [[man:git-bundle]]
+
+- Command: magit-bundle
+
+  This transient prefix command binds several suffix commands for
+  running ~git bundle~ subcommands and displays them in a temporary
+  buffer until a suffix is invoked.
+
 ** Common Commands
 
 - Command: magit-switch-to-repository-buffer
diff --git a/Documentation/magit.texi b/Documentation/magit.texi
index db5c185..caf202e 100644
--- a/Documentation/magit.texi
+++ b/Documentation/magit.texi
@@ -31,7 +31,7 @@ General Public License for more details.
 @finalout
 @titlepage
 @title Magit User Manual
-@subtitle for version 3.2.1 (v3.2.1-40-g678df30c3+1)
+@subtitle for version 3.2.1 (v3.2.1-43-g534ef5a64+1)
 @author Jonas Bernoulli
 @page
 @vskip 0pt plus 1filll
@@ -53,7 +53,7 @@ directly from within Emacs.  While many fine Git clients 
exist, only
 Magit and Git itself deserve to be called porcelains.
 
 @noindent
-This manual is for Magit version 3.2.1 (v3.2.1-40-g678df30c3+1).
+This manual is for Magit version 3.2.1 (v3.2.1-43-g534ef5a64+1).
 
 @quotation
 Copyright (C) 2015-2021 Jonas Bernoulli <jonas@@bernoul.li>
@@ -261,6 +261,7 @@ Miscellaneous
 * Submodules::
 * Subtree::
 * Worktree::
+* Bundle::
 * Common Commands::
 * Wip Modes::
 * Commands for Buffers Visiting Files::
@@ -9022,6 +9023,7 @@ discards all changes made since the sequence started.
 * Submodules::
 * Subtree::
 * Worktree::
+* Bundle::
 * Common Commands::
 * Wip Modes::
 * Commands for Buffers Visiting Files::
@@ -9490,6 +9492,30 @@ If the worktree at point is the one whose status is 
already being
 displayed in the current buffer, then show it in Dired instead.
 @end table
 
+@node Bundle
+@section Bundle
+
+Also see 
+@ifinfo
+@ref{git-bundle,,,gitman,}.
+@end ifinfo
+@ifhtml
+@html
+the <a href="http://git-scm.com/docs/git-bundle";>git-bundle(1)</a> manpage.
+@end html
+@end ifhtml
+@iftex
+the git-bundle(1) manpage.
+@end iftex
+
+@cindex magit-bundle
+@deffn Command magit-bundle
+
+This transient prefix command binds several suffix commands for
+running @code{git bundle} subcommands and displays them in a temporary
+buffer until a suffix is invoked.
+@end deffn
+
 @node Common Commands
 @section Common Commands
 
diff --git a/default.mk b/default.mk
index 4f94aaa..bfde98d 100644
--- a/default.mk
+++ b/default.mk
@@ -92,6 +92,7 @@ ELS += magit-submodule.el
 ELS += magit-subtree.el
 ELS += magit-ediff.el
 ELS += magit-gitignore.el
+ELS += magit-bundle.el
 ELS += magit-extras.el
 ELS += git-rebase.el
 ELS += magit-imenu.el
diff --git a/lisp/Makefile b/lisp/Makefile
index 0f70446..2a87e30 100644
--- a/lisp/Makefile
+++ b/lisp/Makefile
@@ -61,6 +61,7 @@ magit-patch.elc:        magit.elc
 magit-subtree.elc:      magit.elc
 magit-ediff.elc:        magit.elc
 magit-gitignore.elc:    magit.elc
+magit-bunlde.elc:       magit.elc
 magit-extras.elc:       magit.elc magit-merge.elc
 git-rebase.elc:         magit.elc
 magit-imenu.elc:        magit.elc git-rebase.elc
diff --git a/lisp/magit-bundle.el b/lisp/magit-bundle.el
new file mode 100644
index 0000000..8728c66
--- /dev/null
+++ b/lisp/magit-bundle.el
@@ -0,0 +1,135 @@
+;;; magit-bundle.el --- bundle support for Magit   -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2021  The Magit Project Contributors
+;;
+;; You should have received a copy of the AUTHORS.md file which
+;; lists all contributors.  If not, see http://magit.vc/authors.
+
+;; Author: Jonas Bernoulli <jonas@bernoul.li>
+;; Maintainer: Jonas Bernoulli <jonas@bernoul.li>
+
+;; 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, 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 http://www.gnu.org/licenses.
+
+;;; Code:
+
+(require 'magit)
+
+;;; Commands
+
+;;;###autoload (autoload 'magit-bundle "magit-bundle" nil t)
+(transient-define-prefix magit-bundle ()
+  "Create or verify Git bundles."
+  :man-page "git-bundle"
+  ["Actions"
+   ("c" "create"     magit-bundle-create)
+   ("v" "verify"     magit-bundle-verify)
+   ("l" "list-heads" magit-bundle-list-heads)])
+
+;;;###autoload (autoload 'magit-bundle-import "magit-bundle" nil t)
+(transient-define-prefix magit-bundle-create (&optional file refs args)
+  "Create a bundle."
+  :man-page "git-bundle"
+  ["Arguments"
+   ("-a" "Include all refs" "--all")
+   ("-b" "Include branches" "--branches=" :allow-empty t)
+   ("-t" "Include tags"     "--tags="     :allow-empty t)
+   ("-r" "Include remotes"  "--remotes="  :allow-empty t)
+   ("-g" "Include refs"     "--glob=")
+   ("-e" "Exclude refs"     "--exclude=")
+   (magit-log:-n)
+   (magit-log:--since)
+   (magit-log:--until)]
+  ["Actions"
+   ("c" "create regular bundle" magit-bundle-create)
+   ("t" "create tracked bundle" magit-bundle-create-tracked)
+   ("u" "update tracked bundle" magit-bundle-update-tracked)]
+  (interactive
+   (and (eq transient-current-command 'magit-bundle-create)
+        (list (read-file-name "Create bundle: " nil nil nil
+                              (concat (file-name-nondirectory
+                                       (directory-file-name (magit-toplevel)))
+                                      ".bundle"))
+              (magit-completing-read-multiple* "Refnames (zero or more): "
+                                               (magit-list-refnames))
+              (transient-args 'magit-bundle-create))))
+  (if file
+      (magit-git-bundle "create" file refs args)
+    (transient-setup 'magit-bundle-create)))
+
+;;;###autoload
+(defun magit-bundle-create-tracked (file tag branch refs args)
+  "Create and track a new bundle."
+  (interactive
+   (let ((tag    (magit-read-tag "Track bundle using tag"))
+         (branch (magit-read-branch "Bundle branch"))
+         (refs   (magit-completing-read-multiple*
+                  "Additional refnames (zero or more): "
+                  (magit-list-refnames))))
+     (list (read-file-name "File: " nil nil nil (concat tag ".bundle"))
+           tag branch
+           (if (equal branch (magit-get-current-branch))
+               (cons "HEAD" refs)
+             refs)
+           (transient-args 'magit-bundle-create))))
+  (magit-git-bundle "create" file (cons branch refs) args)
+  (magit-git "tag" "--force" tag branch
+             "-m" (concat ";; git-bundle tracking\n"
+                          (pp-to-string `((file   . ,file)
+                                          (branch . ,branch)
+                                          (refs   . ,refs)
+                                          (args   . ,args))))))
+
+;;;###autoload
+(defun magit-bundle-update-tracked (tag)
+  "Update a bundle that is being tracked using TAG."
+  (interactive (list (magit-read-tag "Update bundle tracked by tag" t)))
+  (let (msg)
+    (let-alist (magit--with-temp-process-buffer
+                 (save-excursion
+                   (magit-git-insert "for-each-ref" "--format=%(contents)"
+                                     (concat "refs/tags/" tag)))
+                 (setq msg (buffer-string))
+                 (ignore-errors (read (current-buffer))))
+      (unless (and .file .branch)
+        (error "Tag %s does not appear to track a bundle" tag))
+      (magit-git-bundle "create" .file
+                        (cons (concat tag ".." .branch) .refs)
+                        .args)
+      (magit-git "tag" "--force" tag .branch "-m" msg))))
+
+;;;###autoload
+(defun magit-bundle-verify (file)
+  "Check whether FILE is valid and applies to the current repository."
+  (interactive (list (magit-bundle--read-file-name "Verify bundle: ")))
+  (magit-process-buffer)
+  (magit-git-bundle "verify" file))
+
+;;;###autoload
+(defun magit-bundle-list-heads (file)
+  "List the refs in FILE."
+  (interactive (list (magit-bundle--read-file-name "List heads of bundle: ")))
+  (magit-process-buffer)
+  (magit-git-bundle "list-heads" file))
+
+(defun magit-bundle--read-file-name (prompt)
+  (read-file-name prompt nil nil t (magit-file-at-point) #'file-regular-p))
+
+(defun magit-git-bundle (command file &optional refs args)
+  (magit-git "bundle" command (magit-convert-filename-for-git file) refs args))
+
+;;; _
+(provide 'magit-bundle)
+;;; magit-bundle.el ends here
diff --git a/lisp/magit-clone.el b/lisp/magit-clone.el
index 649d861..224ca7b 100644
--- a/lisp/magit-clone.el
+++ b/lisp/magit-clone.el
@@ -262,7 +262,10 @@ Then show the status buffer for the new repository."
     (?l "[l]ocal url"
         (concat "file://"
                 (magit-convert-filename-for-git
-                 (read-directory-name "Clone repository: file://"))))))
+                 (read-directory-name "Clone repository: file://"))))
+    (?b "or [b]undle"
+        (magit-convert-filename-for-git
+         (read-file-name "Clone from bundle: ")))))
 
 (defun magit-clone--url-to-name (url)
   (and (string-match "\\([^/:]+?\\)\\(/?\\.git\\)?$" url)



reply via email to

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