diff options
author | Alexandre Julliard <julliard@winehq.org> | 2008-08-02 20:35:20 +0200 |
---|---|---|
committer | Alexandre Julliard <julliard@winehq.org> | 2008-11-21 20:39:03 +0100 |
commit | db18a182a28f254fa514179dcd49ceb3d95cd9d8 (patch) | |
tree | aaaac0cc7152b9903460960ca2e9cc6258866f9d /contrib | |
parent | ef5133df7c9d0304ce2fc437abc74c220f49dabd (diff) | |
download | git-db18a182a28f254fa514179dcd49ceb3d95cd9d8.tar.gz git-db18a182a28f254fa514179dcd49ceb3d95cd9d8.tar.xz |
git.el: Fix git-amend-commit to support amending an initial commit.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/emacs/git.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index 207ff0ba2..2dd97eeb5 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -389,11 +389,12 @@ the process output as a string, or nil if the git command failed." (defun git-update-ref (ref newval &optional oldval reason) "Update a reference by calling git-update-ref." (let ((args (and oldval (list oldval)))) - (push newval args) + (when newval (push newval args)) (push ref args) (when reason (push reason args) (push "-m" args)) + (unless newval (push "-d" args)) (apply 'git-call-process-display-error "update-ref" args))) (defun git-read-tree (tree &optional index-file) @@ -1329,7 +1330,7 @@ Return the list of files that haven't been handled." "Retrieve the list of files modified by COMMIT." (let (files) (with-temp-buffer - (git-call-process t "diff-tree" "-m" "-r" "-z" "--name-only" "--no-commit-id" commit) + (git-call-process t "diff-tree" "-m" "-r" "-z" "--name-only" "--no-commit-id" "--root" commit) (goto-char (point-min)) (while (re-search-forward "\\([^\0]*\\)\0" nil t 1) (push (match-string 1) files))) @@ -1343,7 +1344,10 @@ amended version of it." (when (git-empty-db-p) (error "No commit to amend.")) (let* ((commit (git-rev-parse "HEAD")) (files (git-get-commit-files commit))) - (when (git-call-process-display-error "reset" "--soft" "HEAD^") + (when (if (git-rev-parse "HEAD^") + (git-call-process-display-error "reset" "--soft" "HEAD^") + (and (git-update-ref "ORIG_HEAD" commit) + (git-update-ref "HEAD" nil commit))) (git-update-status-files (copy-sequence files) 'uptodate) (git-mark-files git-status files) (git-refresh-files) |