Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show file when staged to add but deleted in working tree #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions src/command/status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { git, gitVersion, IGitExecutionOptions } from '../core/git';
import { parsePorcelainStatus, mapStatus } from '../parser/status-parser';
import { DiffSelectionType, DiffSelection } from '../model/diff';
import { IStatusResult, IAheadBehind, WorkingDirectoryStatus, WorkingDirectoryFileChange, AppFileStatus, FileEntry, GitStatusEntry } from '../model/status';
import { IStatusResult, IAheadBehind, WorkingDirectoryStatus, WorkingDirectoryFileChange, AppFileStatus, FileEntry } from '../model/status';

function convertToAppStatus(status: FileEntry): AppFileStatus {
if (status.kind === 'ordinary') {
Expand Down Expand Up @@ -105,31 +105,6 @@ export async function getStatus(
if (entry.kind === 'entry') {
const status = mapStatus(entry.statusCode);

if (status.kind === 'ordinary') {
// when a file is added in the index but then removed in the working
// directory, the file won't be part of the commit, so we can skip
// displaying this entry in the changes list
if (
status.index === GitStatusEntry.Added &&
status.workingTree === GitStatusEntry.Deleted
) {
continue;
}
}

if (status.kind === 'untracked') {
// when a delete has been staged, but an untracked file exists with the
// same path, we should ensure that we only draw one entry in the
// changes list - see if an entry already exists for this path and
// remove it if found
if (existingFiles.has(entry.path)) {
const existingEntry = files.findIndex(p => p.path === entry.path);
if (existingEntry > -1) {
files.splice(existingEntry, 1);
}
}
}

// for now we just poke at the existing summary
const summary = convertToAppStatus(status);
const selection = DiffSelection.fromInitialSelection(
Expand Down