git: Revert "Ignore whitespace in git blame invocation" (#44648)
Reverts zed-industries/zed#35960 cc @cole-miller --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
co-authored by
Cole Miller
parent
18d344e118
commit
47c30b6da7
@@ -8,7 +8,7 @@ use gpui::SharedString;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::process::Stdio;
|
||||
use std::{ops::Range, path::Path};
|
||||
use text::Rope;
|
||||
use text::{LineEnding, Rope};
|
||||
use time::OffsetDateTime;
|
||||
use time::UtcOffset;
|
||||
use time::macros::format_description;
|
||||
@@ -35,8 +35,10 @@ impl Blame {
|
||||
working_directory: &Path,
|
||||
path: &RepoPath,
|
||||
content: &Rope,
|
||||
line_ending: LineEnding,
|
||||
) -> Result<Self> {
|
||||
let output = run_git_blame(git_binary, working_directory, path, content).await?;
|
||||
let output =
|
||||
run_git_blame(git_binary, working_directory, path, content, line_ending).await?;
|
||||
let mut entries = parse_git_blame(&output)?;
|
||||
entries.sort_unstable_by(|a, b| a.range.start.cmp(&b.range.start));
|
||||
|
||||
@@ -63,12 +65,12 @@ async fn run_git_blame(
|
||||
working_directory: &Path,
|
||||
path: &RepoPath,
|
||||
contents: &Rope,
|
||||
line_ending: LineEnding,
|
||||
) -> Result<String> {
|
||||
let mut child = util::command::new_smol_command(git_binary)
|
||||
.current_dir(working_directory)
|
||||
.arg("blame")
|
||||
.arg("--incremental")
|
||||
.arg("-w")
|
||||
.arg("--contents")
|
||||
.arg("-")
|
||||
.arg(path.as_unix_str())
|
||||
@@ -83,7 +85,7 @@ async fn run_git_blame(
|
||||
.as_mut()
|
||||
.context("failed to get pipe to stdin of git blame command")?;
|
||||
|
||||
for chunk in contents.chunks() {
|
||||
for chunk in text::chunks_with_line_ending(contents, line_ending) {
|
||||
stdin.write_all(chunk.as_bytes()).await?;
|
||||
}
|
||||
stdin.flush().await?;
|
||||
|
||||
@@ -14,6 +14,7 @@ use rope::Rope;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use smol::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
|
||||
use text::LineEnding;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
@@ -487,7 +488,12 @@ pub trait GitRepository: Send + Sync {
|
||||
fn show(&self, commit: String) -> BoxFuture<'_, Result<CommitDetails>>;
|
||||
|
||||
fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result<CommitDiff>>;
|
||||
fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result<crate::blame::Blame>>;
|
||||
fn blame(
|
||||
&self,
|
||||
path: RepoPath,
|
||||
content: Rope,
|
||||
line_ending: LineEnding,
|
||||
) -> BoxFuture<'_, Result<crate::blame::Blame>>;
|
||||
fn file_history(&self, path: RepoPath) -> BoxFuture<'_, Result<FileHistory>>;
|
||||
fn file_history_paginated(
|
||||
&self,
|
||||
@@ -1512,7 +1518,12 @@ impl GitRepository for RealGitRepository {
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result<crate::blame::Blame>> {
|
||||
fn blame(
|
||||
&self,
|
||||
path: RepoPath,
|
||||
content: Rope,
|
||||
line_ending: LineEnding,
|
||||
) -> BoxFuture<'_, Result<crate::blame::Blame>> {
|
||||
let working_directory = self.working_directory();
|
||||
let git_binary_path = self.any_git_binary_path.clone();
|
||||
let executor = self.executor.clone();
|
||||
@@ -1524,6 +1535,7 @@ impl GitRepository for RealGitRepository {
|
||||
&working_directory?,
|
||||
&path,
|
||||
&content,
|
||||
line_ending,
|
||||
)
|
||||
.await
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user