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

Handle files starting with colons in WalkGitLog #22935

Merged
merged 4 commits into from
Mar 16, 2023
Merged
Changes from 2 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
4 changes: 4 additions & 0 deletions modules/git/log_name_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
} else if treepath != "" {
files = append(files, treepath)
}
// Use the :(literal) pathspec magic to handle edge cases with files named like ":file.txt" or "*.jpg"
for i, file := range files {
files[i] = ":(literal)" + file
}
cmd.AddDashesAndList(files...)
Comment on lines +59 to 63
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, wouldn't it be better to add it to AddDashesAndList directly?
That way, it will already be applied to every possible instance, I don't know of any usage that expects wildcards to work, and it is in the other cases not intended to be used as a wildcard.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, wouldn't it be better to add it to AddDashesAndList directly?

This approach has been discussed before, it might break something.

Maybe next time we can introduce AddDashesAndLiterals, but not change the behavior of AddDashesAndList.


go func() {
Expand Down