@@ -389,11 +389,12 @@ the process output as a string, or nil if the git command failed."
389389(defun git-update-ref (ref newval &optional oldval reason )
390390 " Update a reference by calling git-update-ref."
391391 (let ((args (and oldval (list oldval))))
392- (push newval args)
392+ (when newval ( push newval args) )
393393 (push ref args)
394394 (when reason
395395 (push reason args)
396396 (push " -m" args))
397+ (unless newval (push " -d" args))
397398 (apply 'git-call-process-display-error " update-ref" args)))
398399
399400(defun git-read-tree (tree &optional index-file )
@@ -1329,7 +1330,7 @@ Return the list of files that haven't been handled."
13291330 " Retrieve the list of files modified by COMMIT."
13301331 (let (files )
13311332 (with-temp-buffer
1332- (git-call-process t " diff-tree" " -m" " -r" " -z" " --name-only" " --no-commit-id" commit)
1333+ (git-call-process t " diff-tree" " -m" " -r" " -z" " --name-only" " --no-commit-id" " --root " commit)
13331334 (goto-char (point-min ))
13341335 (while (re-search-forward " \\ ([^\0 ]*\\ )\0 " nil t 1 )
13351336 (push (match-string 1 ) files )))
@@ -1343,7 +1344,10 @@ amended version of it."
13431344 (when (git-empty-db-p) (error " No commit to amend. " ))
13441345 (let* ((commit (git-rev-parse " HEAD" ))
13451346 (files (git-get-commit-files commit)))
1346- (when (git-call-process-display-error " reset" " --soft" " HEAD^" )
1347+ (when (if (git-rev-parse " HEAD^" )
1348+ (git-call-process-display-error " reset" " --soft" " HEAD^" )
1349+ (and (git-update-ref " ORIG_HEAD" commit)
1350+ (git-update-ref " HEAD" nil commit)))
13471351 (git-update-status-files (copy-sequence files ) 'uptodate )
13481352 (git-mark-files git-status files )
13491353 (git-refresh-files)
0 commit comments