Skip to content

Commit

Permalink
Fix magit-unstage-item when no commit is present
Browse files Browse the repository at this point in the history
When no commit is present, magit shoudl run "git rm --cached" as
opposed to the normal "git reset HEAD".

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
  • Loading branch information
artagnon authored and vanicat committed Feb 24, 2011
1 parent 9686628 commit 81fe116
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion magit.el
Original file line number Diff line number Diff line change
Expand Up @@ -2899,7 +2899,10 @@ at point."
((staged diff)
(if (eq (car info) 'unmerged)
(error "Can't unstage a unmerged file. Resolve it first"))
(magit-run-git "reset" "-q" "HEAD" "--" (magit-diff-item-file item)))
(if (magit-git-string
"log" "--max-count=1" "--abbrev-commit" "--pretty=oneline")
(magit-run-git "reset" "-q" "HEAD" "--" (magit-diff-item-file item))
(magit-run-git "rm" "--cached" "--" (magit-diff-item-file item))))
((unstaged *)
(error "Already unstaged"))
((hunk)
Expand Down

0 comments on commit 81fe116

Please sign in to comment.