From f4f505c25e1615f857b2da40a908bf7c5683ab70 Mon Sep 17 00:00:00 2001 From: Johannes Gilger Date: Mon, 23 Feb 2009 14:51:01 +0100 Subject: [PATCH] PBGitCommitController: Fix unstaging of last hunk When unstaging the last cached hunk of a file, the file remained in the "Staged Changes" column, with the notice "This file has no more changes" and the "Unstage"-button remaining in the diff-view. This fixes this behaviour by correctly distinguishing files in the files-array not only by filename but also by unstaged/cached status, s.t. for a file with unstaged and cached changes, there are two entries in the files-array. Signed-off-by: Johannes Gilger --- PBGitCommitController.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index bc67878..03b6a76 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -193,17 +193,17 @@ // but rather update it to incorporate our changes for (PBChangedFile *file in files) { if ([file.path isEqualToString:line]) { - file.shouldBeDeleted = NO; - if (cached) { - file.commitBlobSHA = sha; + if (cached && file.hasCachedChanges) { // if we're listing cached files + file.shouldBeDeleted = NO; // and the matching file in files had cached changes + file.commitBlobSHA = sha; // we don't delete it file.commitBlobMode = mode; - file.hasCachedChanges = YES; + isNew = NO; + break; + } else if ((!cached) && file.hasUnstagedChanges) { // if we're listing unstaged files and the + file.shouldBeDeleted = NO; // matching file in files had unstaged changes + isNew = NO; // we don't delete it + break; } - else - file.hasUnstagedChanges = YES; - - isNew = NO; - break; } }