Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 6 additions & 10 deletions apps/emdash-desktop/src/main/core/git/impl/git-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,19 +500,15 @@ export class GitService implements GitProvider, IDisposable {
}

async getFileAtIndex(filePath: string): Promise<string | null> {
const cf = this._getCatFile();
if (cf) {
try {
return await cf.read(`:0:${filePath}`);
} catch {
// Fall back
}
}
// Must NOT go through the persistent cat-file --batch channel: git caches
// the in-core index on the first `:0:<path>` read and never re-reads it,
// so a long-lived batch process keeps serving stale staged content after
// the index changes (git add / commit). A one-shot process is always fresh.
try {
const { stdout } = await this.ctx.exec('git', ['show', `:0:${filePath}`], {
const { stdout } = await this.ctx.exec('git', ['cat-file', 'blob', `:0:${filePath}`], {
maxBuffer: MAX_DIFF_CONTENT_BYTES,
});
return stripTrailingNewline(stdout);
return stdout;
} catch {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export function wireModelRegistryInvalidation(registry: MonacoModelRegistry): ()
// Local/remote ref changes → invalidate matching git:// models (exact ref when known).
const unsubRefs = events.on(gitRefChangedChannel, ({ projectId, kind, changedRefs }) => {
if (kind === 'config') return;
// A commit moves the local branch ref but never touches the worktree HEAD
// file, so no workspace-level 'head' event fires — refresh HEAD models on
// any local ref change to keep HEAD-based diffs in sync after commits.
if (kind === 'local-refs') {
for (const uri of registry.findGitUris({ projectId, ref: HEAD_REF })) {
void registry.invalidateModel(uri);
}
}
if (changedRefs) {
for (const ref of changedRefs) {
for (const uri of registry.findGitUris({ projectId, ref })) {
Expand Down
Loading