Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai c5bccf020e fix(vcs): don't commit a file that was added to the index and then deleted
A file added with git add and then deleted from disk (AD) is no change
against HEAD, so the Commit view lists it nowhere. The commit plan skipped
it, but it stayed in the index copy the commit is made from, so committing
other files also committed the deleted file. Such staged entries are now
excluded like unchecked staged files.
2026-11-12 19:15:10 +08:00
2 змінених файлів з 19 додано та 1 видалено

No files matched your search

+13
Переглянути файл
@@ -283,6 +283,19 @@ describe("commit inclusion", () => {
]);
});
it("leaves out a file added to the index and then deleted, which no group lists", () => {
const files = [fs("src/A.java", null, "modified"), fs("src/Gone.java", "added", "deleted")];
expect(
buildChangeTree(files, "/r", false)
.flatMap((g) => g.children ?? [])
.map((n) => n.label),
).toEqual(["A.java"]);
const plan = planCommit(files, new Map());
expect(plan.stage).toEqual(["/r/src/A.java"]);
expect(plan.exclude).toEqual(["/r/src/Gone.java"]);
expect(plan.included.map((f) => f.relPath)).toEqual(["src/A.java"]);
});
it("aggregates checkbox state for groups", () => {
const checks = new Map<string, CheckState>();
expect(aggregateCheck([status[0]!, status[3]!], checks)).toMatchObject({ checked: true, indeterminate: false });
+6 -1
Переглянути файл
@@ -390,7 +390,12 @@ export function renamedFromPath(fs: FileStatus): string | null {
export function planCommit(status: readonly FileStatus[], checks: ReadonlyMap<string, CheckState>): CommitPlan {
const plan: CommitPlan = { stage: [], exclude: [], included: [], partial: [] };
for (const fs of status) {
if (!groupOf(fs)) continue;
if (!groupOf(fs)) {
// Listed nowhere, yet staged: added to the index, then deleted from disk. It is no
// change against HEAD, so the commit must not pick up the staged addition.
if (fs.staged && fs.staged !== "conflicted" && fs.unstaged !== "ignored") plan.exclude.push(stripSlash(fs.path));
continue;
}
const c = checkOf(fs, checks);
const path = stripSlash(fs.path);
if (c === "none") {