Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Git blame: make ignoring whitespace configurable#58134

Merged
camdencheek merged 3 commits into
mainfrom
cc/blame-ignore-whitespace
Nov 7, 2023
Merged

Git blame: make ignoring whitespace configurable#58134
camdencheek merged 3 commits into
mainfrom
cc/blame-ignore-whitespace

Conversation

@camdencheek

Copy link
Copy Markdown
Member

Currently, our git blame API endpoint adds the -w flag to git blame, which causes whitespace-only changes to be ignored when blaming a line. This is different than GitHub's behavior, and a confusing default.

This makes the ignoring whitespace configurable in the GraphQL enpdoint, and disables it by default.

Test plan

Git blame for this file now matches what GitHub shows.

@cla-bot cla-bot Bot added the cla-signed label Nov 6, 2023
Comment on lines -24 to +36
var hunksResolver []*hunkResolver
hunkResolvers := make([]*hunkResolver, 0, len(hunks))
for _, hunk := range hunks {
hunksResolver = append(hunksResolver, &hunkResolver{
hunkResolvers = append(hunkResolvers, &hunkResolver{
db: r.db,
repo: r.commit.repoResolver,
hunk: hunk,
})
}

return hunksResolver, nil
return hunkResolvers, nil

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated, just cleaning up some weird naming and extra allocations

@sourcegraph-bot

sourcegraph-bot commented Nov 6, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff a465ffc...6ca82f6.

Notify File(s)
@eseliger internal/gitserver/commands.go

@camdencheek camdencheek requested review from a team and fkling November 6, 2023 22:28
@sourcegraph-bot

sourcegraph-bot commented Nov 6, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

Comment thread cmd/frontend/graphqlbackend/git_blob.go Outdated
EndLine int32
StartLine int32
EndLine int32
IgnoreWhitespace *bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline structs 🚬

Comment thread cmd/frontend/graphqlbackend/schema.graphql Outdated
@fkling

fkling commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

In case it's relevant: Currently the blame view uses a separate endpoint to get streamed blame information. I guess it uses this function under the hood too. Just mentioning it since you've been changing the GraphQL API.

@camdencheek

Copy link
Copy Markdown
Member Author

I guess it uses this function under the hood too.

I made the change in two places! The streaming API doesn't have any arguments, so it effectively changes the default without making it configurable.

@camdencheek camdencheek merged commit 0400936 into main Nov 7, 2023
@camdencheek camdencheek deleted the cc/blame-ignore-whitespace branch November 7, 2023 19:13
vovakulikov pushed a commit that referenced this pull request Dec 12, 2023
Currently, our git blame API endpoint adds the -w flag to git blame, which causes whitespace-only changes to be ignored when blaming a line. This is different than GitHub's behavior, and a confusing default.

This makes the ignoring whitespace configurable in the GraphQL enpdoint, and disables it by default.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants