Skip to content
Merged
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
2 changes: 1 addition & 1 deletion internal/api/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (h *SessionsHandler) HandleDiff(w http.ResponseWriter, r *http.Request) {
if baseCommit == "" {
baseCommit = inferBaseCommit(h.db, worktreePath, sourceBranch, repoID)
if baseCommit == "" {
WriteJSON(w, http.StatusOK, git.DiffResult{})
WriteJSON(w, http.StatusOK, git.DiffResult{Files: []git.DiffFile{}})
return
}
// Backfill so we don't recompute next time
Expand Down
6 changes: 3 additions & 3 deletions internal/git/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func Diff(worktreePath, baseCommit string) (*DiffResult, error) {

// parseDiff parses unified diff output into structured types.
func parseDiff(raw string) (*DiffResult, error) {
result := &DiffResult{}
result := &DiffResult{Files: []DiffFile{}}

if strings.TrimSpace(raw) == "" {
return result, nil
Expand All @@ -111,7 +111,7 @@ func parseDiff(raw string) (*DiffResult, error) {
if currentFile != nil {
result.Files = append(result.Files, *currentFile)
}
currentFile = &DiffFile{Status: "modified"}
currentFile = &DiffFile{Status: "modified", Hunks: []DiffHunk{}}
currentHunk = nil
continue
}
Expand Down Expand Up @@ -270,7 +270,7 @@ func parseHunkHeader(line string) (*DiffHunk, error) {
return nil, fmt.Errorf("malformed hunk range")
}

hunk := &DiffHunk{Header: line}
hunk := &DiffHunk{Header: line, Lines: []DiffLine{}}

// Parse old range (-start,count)
oldRange := strings.TrimPrefix(parts[0], "-")
Expand Down