From 3d989938836498e7c263751a9fc1cea4a71335dc Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 20 Nov 2013 00:58:51 +0200 Subject: [PATCH 01/26] commit-patch-buffer-in-directory: Use commit-patch script from the same directory The missing link for distributing the package via ELPA --- commit-patch-buffer.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index ac99e38..1c1ad33 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -30,6 +30,10 @@ (require 'vc) (require 'log-edit) +(defvar commit-patch-program + (let ((current (or load-file-name (buffer-file-name)))) + (expand-file-name "commit-patch" (file-name-directory current)))) + (defun commit-patch-buffer-in-directory (buffer directory) "Commit the patch found in BUFFER by applying it to the repository in DIRECTORY with commit-patch(1)." @@ -59,7 +63,7 @@ DIRECTORY with commit-patch(1)." (with-current-buffer output-buffer (erase-buffer) (let* ((default-directory ,directory) - (status (process-file "commit-patch" patch + (status (process-file commit-patch-program patch output-buffer 'display "-m" comment))) (if (not (eq status 0)) -- 2.51.2 From c068cfc199190cace21ee77d372a1ddd6e6966de Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Wed, 20 Nov 2013 16:01:26 -0800 Subject: [PATCH 02/26] [README] Mention Ubuntu. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 43ef43e..1a1b396 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ PREREQUISITES subversion - cvs - - On Debian: + On Debian/Ubuntu: apt-get install libipc-run-perl patch patchutils On Fedora: -- 2.51.2 From cc3efccf80c6ee93c819317a4ef20fca279231c7 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Wed, 15 May 2013 21:47:27 -0700 Subject: [PATCH 03/26] [test] Give darcs, bzr, and hg a username so they don't freak out or go interactive --- test/vcs/bzr.sh | 2 +- test/vcs/darcs.sh | 2 +- test/vcs/hg.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/vcs/bzr.sh b/test/vcs/bzr.sh index 34e0ba0..565e01c 100644 --- a/test/vcs/bzr.sh +++ b/test/vcs/bzr.sh @@ -1,7 +1,7 @@ bzr_init () { WD=$1 mkdir -p "$WD" - (cd "$WD" && bzr init) + (cd "$WD" && bzr init && bzr whoami --branch "Chester McTester ") export VC_DIFF="bzr diff" export VC_RM="true" diff --git a/test/vcs/darcs.sh b/test/vcs/darcs.sh index d4f8498..613590e 100644 --- a/test/vcs/darcs.sh +++ b/test/vcs/darcs.sh @@ -1,7 +1,7 @@ darcs_init () { WD=$1 mkdir -p "$WD" - (cd "$WD" && darcs init) + (cd "$WD" && darcs init && echo "Chester McTester" >_darcs/prefs/author) export VC_DIFF="darcs diff" export VC_RM="true" diff --git a/test/vcs/hg.sh b/test/vcs/hg.sh index 017087f..ad7764f 100644 --- a/test/vcs/hg.sh +++ b/test/vcs/hg.sh @@ -1,7 +1,7 @@ hg_init () { WD=$1 mkdir -p "$WD" - (cd "$WD" && hg init) + (cd "$WD" && hg init && (echo "[ui]"; echo "username=Chester McTester") > .hg/hgrc) export VC_DIFF="hg diff" export VC_RM="hg rm" -- 2.51.2 From f136396b3885bbf545a1fa48b6c48d17d135d659 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Fri, 20 Jun 2014 01:17:17 -0700 Subject: [PATCH 04/26] Emacs interface no longer displays backend output as it comes in The emacs interface creates and populates a *commit-patch* buffer. This is meant to stay in the background unless something goes wrong. Due to a bug in Emacs (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17815) this buffer was getting displayed if using commit-patch with TRAMP, even when no error has occured. This patch asks emacs to not update this buffer with the data as it comes in. This is fine here, and fixes the issue. --- commit-patch-buffer.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 1c1ad33..6267498 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -64,7 +64,7 @@ DIRECTORY with commit-patch(1)." (erase-buffer) (let* ((default-directory ,directory) (status (process-file commit-patch-program patch - output-buffer 'display + output-buffer nil "-m" comment))) (if (not (eq status 0)) (progn -- 2.51.2 From 8115e9ceb34e4ec504d4251fa6d7ab8fdecedf3d Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 16:54:21 -0700 Subject: [PATCH 05/26] Use App::FatPacker to remove IPC::Run dependency in the release. --- Makefile | 7 ++++++- README | 1 - cpanfile | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 cpanfile diff --git a/Makefile b/Makefile index d8c8cee..a7aa168 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION := $(shell perl -ne '/VERSION\s*=\s*'"'(.*)'"'/ and print "$$1"' commit-patch) -BIN = commit-patch commit-partial +BIN = commit-patch commit-partial commit-patch.fat MAN = commit-patch.1 commit-partial.1 ELISP = commit-patch-buffer.el DOC = commit-patch.html README COPYING Changes @@ -8,6 +8,10 @@ ALL = $(BIN) $(MAN) $(ELISP) $(DOC) all: $(ALL) +commit-patch.fat: commit-patch + carton exec fatpack pack $< > $@ + chmod +x $@ + commit-partial: ln -s commit-patch commit-partial @@ -25,6 +29,7 @@ release: commit-patch-$(VERSION).tar.gz commit-patch-$(VERSION).tar.gz: $(ALL) Makefile mkdir commit-patch-$(VERSION) rsync -a $^ commit-patch-$(VERSION) + mv -f commit-patch-$(VERSION)/commit-patch.fat commit-patch-$(VERSION)/commit-patch tar czf commit-patch-$(VERSION).tar.gz commit-patch-$(VERSION) rm -rf commit-patch-$(VERSION) diff --git a/README b/README index 1a1b396..c620df3 100644 --- a/README +++ b/README @@ -6,7 +6,6 @@ PREREQUISITES commit-patch relies on several programs to get the job done: perl - - IPC::Run - patch - interdiff - cp - Ideally installed on your system already. :-) diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..480f713 --- /dev/null +++ b/cpanfile @@ -0,0 +1,3 @@ +# -*- perl -*- +requires 'IPC::Run'; +requires 'App::FatPacker'; -- 2.51.2 From c619210272b708f2e8fa6adc9b6fc363a5927c86 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 17:21:47 -0700 Subject: [PATCH 06/26] Update copyright dates --- README | 2 +- commit-patch | 2 +- commit-patch-buffer.el | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index c620df3..11a38d5 100644 --- a/README +++ b/README @@ -56,7 +56,7 @@ AUTHORS o Jim Radford COPYRIGHT AND LICENSE - Copyright 2003-2013 by David Caldwell and Jim Radford. + Copyright 2003-2014 by David Caldwell and Jim Radford. commit-patch is distributed under the GNU General Public License. See the COPYING file in the distribution for more diff --git a/commit-patch b/commit-patch index f9dca19..752ddda 100755 --- a/commit-patch +++ b/commit-patch @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright (c) 2003-2013 David Caldwell +# Copyright (c) 2003-2014 David Caldwell # and Jim Radford , All Rights Reserved. # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 6267498..d3675f6 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -1,6 +1,6 @@ ;;; commit-patch-buffer.el --- commit patches to Darcs, Git, Mercurial, Bazaar, Monotone, Subversion, or CVS repositories -;; Copyright 2003-2013 Jim Radford +;; Copyright 2003-2014 Jim Radford ;; and David Caldwell , All Rights Reserved. ;; This code can be distributed under the terms of the GNU Public License (Version 2 or greater). ;; -- 2.51.2 From d2918fd360a63872ac837698112ab2382f89a470 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 17:23:48 -0700 Subject: [PATCH 07/26] Version 2.5.1 --- Changes | 7 +++++++ commit-patch | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index d6e58ba..545edd8 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,10 @@ +commit-patch (2.5.1) + + * Use App::Fatpacker to bundle IPC::Run, removing the dependency from + the release tarball. + + -- David Caldwell Sun, 21 Sep 2014 17:22:29 -0700 + commit-patch (2.5) * Added Monotone support. diff --git a/commit-patch b/commit-patch index 752ddda..72eee0c 100755 --- a/commit-patch +++ b/commit-patch @@ -3,7 +3,7 @@ # and Jim Radford , All Rights Reserved. # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). -my $VERSION = '2.5'; +my $VERSION = '2.5.1'; use strict; use Cwd qw(abs_path); -- 2.51.2 From 4cbace49f012e3f96383a86f3c47e5c4dd45b208 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 17:32:30 -0700 Subject: [PATCH 08/26] [Changes] Reword changelog. --- Changes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 545edd8..03235a0 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,7 @@ commit-patch (2.5.1) - * Use App::Fatpacker to bundle IPC::Run, removing the dependency from - the release tarball. + * We now use App::Fatpacker to bundle IPC::Run, removing the dependency + from the release tarball. -- David Caldwell Sun, 21 Sep 2014 17:22:29 -0700 -- 2.51.2 From ecdaa7f8472cde8b2b697532e1c7d7b42c91d869 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 17:32:40 -0700 Subject: [PATCH 09/26] [Changes] Mention Dima's patch. --- Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changes b/Changes index 03235a0..04d42af 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,9 @@ commit-patch (2.5.1) * We now use App::Fatpacker to bundle IPC::Run, removing the dependency from the release tarball. + * Work around emacs/tramp bug in commit-patch-buffer.el (thanks Dima + Kogan ). + -- David Caldwell Sun, 21 Sep 2014 17:22:29 -0700 commit-patch (2.5) -- 2.51.2 From cbcafffd1b6d2c27701ca04d4bcde256b0d8b3a1 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 17:50:04 -0700 Subject: [PATCH 10/26] [Makefile] Whine if we try to release something impure. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index a7aa168..9bcfd54 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ commit-patch.html: commit-patch release: commit-patch-$(VERSION).tar.gz commit-patch-$(VERSION).tar.gz: $(ALL) Makefile + if ! git diff --quiet -- $^; then tput setab 1; tput setaf 3; /bin/echo -n 'WARNING: Directory is not clean!'; tput sgr0; echo; fi mkdir commit-patch-$(VERSION) rsync -a $^ commit-patch-$(VERSION) mv -f commit-patch-$(VERSION)/commit-patch.fat commit-patch-$(VERSION)/commit-patch -- 2.51.2 From 26cb9315d2b1db9ca57e784a1d4c187c2e6c03ea Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 18:12:48 -0700 Subject: [PATCH 11/26] [Makefile] Fix commit-patch.fat needing to be made during "make install". --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9bcfd54..ab4c88c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION := $(shell perl -ne '/VERSION\s*=\s*'"'(.*)'"'/ and print "$$1"' commit-patch) -BIN = commit-patch commit-partial commit-patch.fat +BIN = commit-patch commit-partial MAN = commit-patch.1 commit-partial.1 ELISP = commit-patch-buffer.el DOC = commit-patch.html README COPYING Changes @@ -26,7 +26,7 @@ commit-patch.html: commit-patch release: commit-patch-$(VERSION).tar.gz -commit-patch-$(VERSION).tar.gz: $(ALL) Makefile +commit-patch-$(VERSION).tar.gz: $(ALL) Makefile commit-patch.fat if ! git diff --quiet -- $^; then tput setab 1; tput setaf 3; /bin/echo -n 'WARNING: Directory is not clean!'; tput sgr0; echo; fi mkdir commit-patch-$(VERSION) rsync -a $^ commit-patch-$(VERSION) -- 2.51.2 From 518698988fa2e492653d5894223a7f95688c7ff7 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 18:15:49 -0700 Subject: [PATCH 12/26] [commit-patch] Update another Copyright I missed earlier --- commit-patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-patch b/commit-patch index 72eee0c..c13ac7e 100755 --- a/commit-patch +++ b/commit-patch @@ -381,7 +381,7 @@ Jim Radford =head1 COPYRIGHT AND LICENSE -Copyright 2003-2013 by David Caldwell and Jim Radford. +Copyright 2003-2014 by David Caldwell and Jim Radford. B is distributed under the GNU General Public License. See the COPYING file in the distribution for more details. -- 2.51.2 From 1ce58933ee5054a120595e2ab1c1341ae8c00de1 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 21 Sep 2014 18:16:02 -0700 Subject: [PATCH 13/26] Version 2.5.2 --- Changes | 6 ++++++ commit-patch | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 04d42af..f50da72 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +commit-patch (2.5.2) + + * Fixed dumb bug that caused "make install" to fail. + + -- David Caldwell Sun, 21 Sep 2014 18:15:04 -0700 + commit-patch (2.5.1) * We now use App::Fatpacker to bundle IPC::Run, removing the dependency diff --git a/commit-patch b/commit-patch index c13ac7e..fd54d9b 100755 --- a/commit-patch +++ b/commit-patch @@ -3,7 +3,7 @@ # and Jim Radford , All Rights Reserved. # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). -my $VERSION = '2.5.1'; +my $VERSION = '2.5.2'; use strict; use Cwd qw(abs_path); -- 2.51.2 From 5bfe8120ea5de05c2fde80b2ae8fbf2cf04acd7a Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 1 Mar 2015 21:57:33 -0800 Subject: [PATCH 14/26] emacs interface can now amend commits --- commit-patch-buffer.el | 43 +++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index d3675f6..6c382ca 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -34,10 +34,12 @@ (let ((current (or load-file-name (buffer-file-name)))) (expand-file-name "commit-patch" (file-name-directory current)))) -(defun commit-patch-buffer-in-directory (buffer directory) - "Commit the patch found in BUFFER by applying it to the repository in -DIRECTORY with commit-patch(1)." - (interactive "bBuffer to commit: \nDDirectory: ") +(defun commit-patch-buffer-in-directory (buffer directory &optional amend) + "Commit the patch found in BUFFER by applying it to the +repository in DIRECTORY with commit-patch(1). If AMEND is +non-nil, we amend the previous commit instead of creating a new +one." + (interactive "bBuffer to commit: \nDDirectory: \nP") (let* ((patch-files (with-temp-buffer (let ((lsdiff (current-buffer))) (when (eq 0 (with-current-buffer buffer @@ -63,9 +65,13 @@ DIRECTORY with commit-patch(1)." (with-current-buffer output-buffer (erase-buffer) (let* ((default-directory ,directory) - (status (process-file commit-patch-program patch + (args `("-m" ,comment)) + (args (if ,amend + (append args '("--amend")) + args)) + (status (apply 'process-file commit-patch-program patch output-buffer nil - "-m" comment))) + args))) (if (not (eq status 0)) (progn (window-buffer (display-buffer output-buffer)) @@ -84,16 +90,30 @@ DIRECTORY with commit-patch(1)." `((log-edit-listfun . (lambda () ',patch-files))) "*commit*"))) -(defun commit-patch-buffer (&optional arg) +(defun commit-patch-buffer (&optional arg amend) "Commit the patch in the current buffer, applying it to the repository in the appropriate directory with commit-patch(1). If the current buffer is not in diff-mode or ARG is non-nil then it will ask interactively which buffer to commit and to which -directory to commit it." +directory to commit it. If AMEND is non-nil, we amend the +previous commit instead of creating a new one." (interactive "P") (if (and (not arg) (eq major-mode 'diff-mode)) - (commit-patch-buffer-in-directory (buffer-name) (autodetect-patch-directory-root)) - (call-interactively 'commit-patch-buffer-in-directory))) + (commit-patch-buffer-in-directory (buffer-name) (autodetect-patch-directory-root) amend) + + (let ((current-prefix-arg amend)) + (call-interactively 'commit-patch-buffer-in-directory)))) + +(defun commit-patch-buffer-amend (&optional arg) + "Commit the patch in the current buffer, applying it to the +repository in the appropriate directory with commit-patch(1). If +the current buffer is not in diff-mode or ARG is non-nil then it +will ask interactively which buffer to commit and to which +directory to commit it. This is identical to +`commit-patch-buffer' except it amends the last commit by default +instead of creating a new one." + (interactive "P") + (commit-patch-buffer arg t)) (defun autodetect-patch-directory-root () "Tries to autodect where a patch should be committed from using the @@ -121,7 +141,8 @@ following algorithm: (eval-after-load 'diff-mode '(progn (setq diff-default-read-only nil) (define-key diff-mode-map "\C-c\C-c" 'commit-patch-buffer) - (define-key diff-mode-map "\C-xvv" 'commit-patch-buffer))) + (define-key diff-mode-map "\C-xvv" 'commit-patch-buffer) + (define-key diff-mode-map (kbd "C-c C-S-c") 'commit-patch-buffer-amend))) (provide 'commit-patch-buffer) -- 2.51.2 From 00d997ec329cd3c469290c03d80a88ca0454680f Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 2 Mar 2015 12:24:46 -0800 Subject: [PATCH 15/26] [commit-patch-buffer.el] Make arg handling style a little more functional. --- commit-patch-buffer.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 6c382ca..693faf8 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -65,13 +65,10 @@ one." (with-current-buffer output-buffer (erase-buffer) (let* ((default-directory ,directory) - (args `("-m" ,comment)) - (args (if ,amend - (append args '("--amend")) - args)) (status (apply 'process-file commit-patch-program patch output-buffer nil - args))) + (append `("-m" ,comment) + (if ,amend '("--amend")))))) (if (not (eq status 0)) (progn (window-buffer (display-buffer output-buffer)) -- 2.51.2 From 4659f112eaf79e13fbfc305b6e47d1a5a0f7d0ba Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 2 Mar 2015 12:31:52 -0800 Subject: [PATCH 16/26] [commit-patch-buffer.el] Change final message when amending. --- commit-patch-buffer.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 693faf8..7000c75 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -80,7 +80,8 @@ one." ;; get updated, so we do it by hand. (run-hooks 'find-file-hooks))) ',visiting-buffers) - (message "Patched and commited %S file(s) and reverted %S." + (message "Patched and %s %S file(s) and reverted %S." + (if ,amend "amended" "committed") ,(length patch-files) ,(length visiting-buffers)))))) (delete-file patch)))) nil -- 2.51.2 From e6ba37818bdafeb4fac2dc2f84dfad706b40edee Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 2 Mar 2015 12:33:28 -0800 Subject: [PATCH 17/26] [commit-patch-buffer.el] Cleanup trailing whitespace. --- commit-patch-buffer.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 7000c75..52320fc 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -43,9 +43,9 @@ one." (let* ((patch-files (with-temp-buffer (let ((lsdiff (current-buffer))) (when (eq 0 (with-current-buffer buffer - (call-process-region (point-min) (point-max) + (call-process-region (point-min) (point-max) "lsdiff" nil lsdiff nil))) - (split-string (buffer-string)))))) + (split-string (buffer-string)))))) (f patch-files) visiting-buffers) (while (car f) (let ((buf (find-buffer-visiting (car f)))) @@ -64,7 +64,7 @@ one." (write-region (point-min) (point-max) patch)) (with-current-buffer output-buffer (erase-buffer) - (let* ((default-directory ,directory) + (let* ((default-directory ,directory) (status (apply 'process-file commit-patch-program patch output-buffer nil (append `("-m" ,comment) -- 2.51.2 From b4b29e08bb8ca87290df935fffd85800275b1910 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 2 Mar 2015 12:36:31 -0800 Subject: [PATCH 18/26] It's 2015 now. --- README | 2 +- commit-patch | 6 +++--- commit-patch-buffer.el | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README b/README index 11a38d5..fab2de6 100644 --- a/README +++ b/README @@ -56,7 +56,7 @@ AUTHORS o Jim Radford COPYRIGHT AND LICENSE - Copyright 2003-2014 by David Caldwell and Jim Radford. + Copyright © 2003-2015 by David Caldwell and Jim Radford. commit-patch is distributed under the GNU General Public License. See the COPYING file in the distribution for more diff --git a/commit-patch b/commit-patch index fd54d9b..d9e4890 100755 --- a/commit-patch +++ b/commit-patch @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (c) 2003-2014 David Caldwell -# and Jim Radford , All Rights Reserved. +# Copyright © 2003-2015 David Caldwell +# and Jim Radford , All Rights Reserved. # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). my $VERSION = '2.5.2'; @@ -381,7 +381,7 @@ Jim Radford =head1 COPYRIGHT AND LICENSE -Copyright 2003-2014 by David Caldwell and Jim Radford. +Copyright © 2003-2015 by David Caldwell and Jim Radford. B is distributed under the GNU General Public License. See the COPYING file in the distribution for more details. diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 52320fc..a6c0cda 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -1,6 +1,6 @@ ;;; commit-patch-buffer.el --- commit patches to Darcs, Git, Mercurial, Bazaar, Monotone, Subversion, or CVS repositories -;; Copyright 2003-2014 Jim Radford +;; Copyright 2003-2015 Jim Radford ;; and David Caldwell , All Rights Reserved. ;; This code can be distributed under the terms of the GNU Public License (Version 2 or greater). ;; -- 2.51.2 From 9942ab44fe77ec49c5c1bc75cc90226d3d46f46c Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 2 Mar 2015 12:39:34 -0800 Subject: [PATCH 19/26] "All Rights Reserved" is obsolete According to https://en.wikipedia.org/wiki/All_rights_reserved --- commit-patch | 2 +- commit-patch-buffer.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commit-patch b/commit-patch index d9e4890..f4c00bd 100755 --- a/commit-patch +++ b/commit-patch @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # Copyright © 2003-2015 David Caldwell -# and Jim Radford , All Rights Reserved. +# and Jim Radford # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). my $VERSION = '2.5.2'; diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index a6c0cda..17ca98c 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -1,7 +1,7 @@ ;;; commit-patch-buffer.el --- commit patches to Darcs, Git, Mercurial, Bazaar, Monotone, Subversion, or CVS repositories ;; Copyright 2003-2015 Jim Radford -;; and David Caldwell , All Rights Reserved. +;; and David Caldwell ;; This code can be distributed under the terms of the GNU Public License (Version 2 or greater). ;; ;; Version: 2.5 -- 2.51.2 From 3379d7f46710e158adf4aee6a95940bbd60d53c8 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sat, 7 Mar 2015 13:04:16 -0800 Subject: [PATCH 20/26] [commit-patch-buffer] Retrieve last comment when amending. This only works in Git, but then amending really only works in git. --- commit-patch-buffer.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 17ca98c..57ecb7a 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -34,6 +34,23 @@ (let ((current (or load-file-name (buffer-file-name)))) (expand-file-name "commit-patch" (file-name-directory current)))) +;; Based on vc-git-expanded-log-entry, but don't indent and only grab the full comment using --pretty +(defun commit-patch-git-log-comment (revision) + (with-temp-buffer + (apply 'vc-git-command t nil nil (list "log" "--pretty=format:%B" revision "-1")) + (goto-char (point-min)) + (unless (eobp) + (buffer-string)))) + +;; Currently commit-patch only supports --amend with Git and Darcs. +;; But Darcs amend is very interactive, so we don't support it here. +(defun commit-patch-last-log-comment (directory) + (let ((default-directory directory)) + (pcase (vc-responsible-backend directory) + (`Git + (commit-patch-git-log-comment "HEAD"))))) + + (defun commit-patch-buffer-in-directory (buffer directory &optional amend) "Commit the patch found in BUFFER by applying it to the repository in DIRECTORY with commit-patch(1). If AMEND is @@ -53,6 +70,11 @@ one." (with-current-buffer buf (vc-buffer-sync)) (add-to-list 'visiting-buffers buf))) (setq f (cdr f))) + (if amend + (with-current-buffer (get-buffer-create "*commit*") + (erase-buffer) + (insert (or (commit-patch-last-log-comment directory) "")) + (goto-char 0))) (log-edit `(lambda () (interactive) (let ((patch (make-temp-file "commit-buffer" nil)) -- 2.51.2 From 581181764b5fa37f14a359471660e0927c759fab Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Mon, 9 Mar 2015 10:49:18 -0700 Subject: [PATCH 21/26] log-edit buffer is now called "*amend*" when amending and "*commit*" otherwise --- commit-patch-buffer.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 57ecb7a..aaa1ff7 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -63,6 +63,7 @@ one." (call-process-region (point-min) (point-max) "lsdiff" nil lsdiff nil))) (split-string (buffer-string)))))) + (log-buffer-name (if amend "*amend*" "*commit*")) (f patch-files) visiting-buffers) (while (car f) (let ((buf (find-buffer-visiting (car f)))) @@ -71,7 +72,7 @@ one." (add-to-list 'visiting-buffers buf))) (setq f (cdr f))) (if amend - (with-current-buffer (get-buffer-create "*commit*") + (with-current-buffer (get-buffer-create log-buffer-name) (erase-buffer) (insert (or (commit-patch-last-log-comment directory) "")) (goto-char 0))) @@ -108,7 +109,7 @@ one." (delete-file patch)))) nil `((log-edit-listfun . (lambda () ',patch-files))) - "*commit*"))) + log-buffer-name))) (defun commit-patch-buffer (&optional arg amend) "Commit the patch in the current buffer, applying it to the -- 2.51.2 From 36f9475776d13c27e1aa7f5763e4a3be45c32820 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Wed, 26 Aug 2015 10:09:45 -0700 Subject: [PATCH 22/26] [commit-patch-buffer.el] Only use local commit-patch executable if it exists. Normally the exe goes in /usr/bin and the .el files go in /usr/share/site-lisp (or the /usr/local versions of those if you aren't installing a package). Fixes #11. --- commit-patch-buffer.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index aaa1ff7..a247300 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -30,9 +30,11 @@ (require 'vc) (require 'log-edit) +;; Prefer a locally installed commit patch over one installed in the PATH. (defvar commit-patch-program - (let ((current (or load-file-name (buffer-file-name)))) - (expand-file-name "commit-patch" (file-name-directory current)))) + (let* ((this-path (or load-file-name (buffer-file-name))) + (local-path (expand-file-name "commit-patch" (file-name-directory this-path)))) + (if (file-executable-p local-path) local-path "commit-patch"))) ;; Based on vc-git-expanded-log-entry, but don't indent and only grab the full comment using --pretty (defun commit-patch-git-log-comment (revision) -- 2.51.2 From b63b99d99cf597918fb82b9111143e03af6ba606 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Tue, 22 Nov 2016 15:23:28 -0800 Subject: [PATCH 23/26] (autodetect-patch-directory-root) doesn't get confused by symlinks Prior to this patch you could have a scenario where - The filename in the first hunk refers to a real file - The emacs buffer returned by (buffer-file-name) is a symlink to this file Since (autodetect-patch-directory-root) comparse paths, this would make the comparison fail in the wrong place, and (autodetect-patch-directory-root) would return a wrong result --- commit-patch-buffer.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index a247300..7a5ffab 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -152,7 +152,7 @@ following algorithm: (beginning-of-buffer) (diff-hunk-next) ;; Have to be in a hunk or diff-hunk-file-names won't work. (let ((diff-path (reverse (split-string (car (diff-hunk-file-names)) "/"))) - (file-path (reverse (split-string (buffer-file-name (car (diff-find-source-location))) "/")))) + (file-path (reverse (split-string (file-chase-links (buffer-file-name (car (diff-find-source-location)))) "/")))) (while (string-equal (car file-path) (car diff-path)) (setq file-path (cdr file-path)) (setq diff-path (cdr diff-path))) -- 2.51.2 From fe2c2cef50a592171f3215c48600ba2313e4d322 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sat, 2 Jul 2016 11:17:13 -0700 Subject: [PATCH 24/26] commit-patch-program can now be given as a function --- commit-patch-buffer.el | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/commit-patch-buffer.el b/commit-patch-buffer.el index 7a5ffab..487e02d 100644 --- a/commit-patch-buffer.el +++ b/commit-patch-buffer.el @@ -30,11 +30,34 @@ (require 'vc) (require 'log-edit) -;; Prefer a locally installed commit patch over one installed in the PATH. -(defvar commit-patch-program + +(defcustom commit-patch-program + ;; Prefer a locally installed commit patch over one installed in the PATH. (let* ((this-path (or load-file-name (buffer-file-name))) (local-path (expand-file-name "commit-patch" (file-name-directory this-path)))) - (if (file-executable-p local-path) local-path "commit-patch"))) + (if (file-executable-p local-path) local-path "commit-patch")) + "The pathname of the commit-patch executable to use. This could be a +string, or a function. If a function, then this is called every +time the program path is needed to retrieve the path. The +function takes no arguments, but can use variables such as +`default-directory'. This is useful to find commit-patch in different +places on different machines when using TRAMP." + :type '(choice + (string :tag "Program path") + (function :tag "Function that returns the program path")) + :group 'commit-patch) + +(defun commit-patch--get-program () + "Retrieves the path to the commit-patch program. This is the value of +the `commit-patch-program' variable, if it is a string, or the value +returned by the `commit-patch-program' function, if it is a function." + (let ((program + (cond + ((stringp commit-patch-program) commit-patch-program) + ((functionp commit-patch-program) (funcall commit-patch-program)) + (t (error "commit-patch-program must be a string or function: %s" + commit-patch-program))))) + (or program (error "commit-patch-program is nil!")))) ;; Based on vc-git-expanded-log-entry, but don't indent and only grab the full comment using --pretty (defun commit-patch-git-log-comment (revision) @@ -90,7 +113,7 @@ one." (with-current-buffer output-buffer (erase-buffer) (let* ((default-directory ,directory) - (status (apply 'process-file commit-patch-program patch + (status (apply 'process-file (commit-patch--get-program) patch output-buffer nil (append `("-m" ,comment) (if ,amend '("--amend")))))) -- 2.51.2 From fe7b4fe08756a8dbcb49a71fa21daecc4e60c9d7 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 3 Feb 2019 00:26:41 -0800 Subject: [PATCH 25/26] Version 2.6 --- Changes | 11 +++++++++++ commit-patch | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index f50da72..3dc6d0b 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,14 @@ +commit-patch (2.6) + + * Support --amend from the Emacs interface (Dima Kogan) + + * Fixed a bug with symlinked files in repos (Dima Kogan) + + * Allow Emacs config option `commit-patch-program` to be a function + (Dima Kogan) + + -- David Caldwell Sun, 03 Feb 2019 00:24:11 -0800 + commit-patch (2.5.2) * Fixed dumb bug that caused "make install" to fail. diff --git a/commit-patch b/commit-patch index f4c00bd..a2673e1 100755 --- a/commit-patch +++ b/commit-patch @@ -3,7 +3,7 @@ # and Jim Radford # This code can be distributed under the terms of the GNU Public License (Version 2 or greater). -my $VERSION = '2.5.2'; +my $VERSION = '2.6'; use strict; use Cwd qw(abs_path); -- 2.51.2 From d531ce52bfbeb2e05b600199083da2e7fe5da827 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 3 Feb 2019 01:04:18 -0800 Subject: [PATCH 26/26] commit-patch: fix pod2man whining about encoding --- commit-patch | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commit-patch b/commit-patch index a2673e1..b7bd18f 100755 --- a/commit-patch +++ b/commit-patch @@ -256,6 +256,8 @@ END { } +=encoding utf-8 + =head1 NAME commit-patch - commit patches to I, I, I, I, I, I, or I repositories -- 2.51.2