Skip to content

Commit ca35266

Browse files
cole-millermikayla-maki
authored andcommitted
Revert "Fix track file renames in git panel (#42352)" (#43030)
This reverts commit b0a7def. It looks like this doesn't interact correctly with the project diff or with staging, let's revert and reland with bugs fixed. Release Notes: - N/A
1 parent 4a4785a commit ca35266

File tree

9 files changed

+44
-150
lines changed

9 files changed

+44
-150
lines changed

crates/collab/src/db/queries/projects.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ impl Database {
10051005
is_last_update: true,
10061006
merge_message: db_repository_entry.merge_message,
10071007
stash_entries: Vec::new(),
1008-
renamed_paths: Default::default(),
10091008
});
10101009
}
10111010
}

crates/collab/src/db/queries/rooms.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ impl Database {
796796
is_last_update: true,
797797
merge_message: db_repository.merge_message,
798798
stash_entries: Vec::new(),
799-
renamed_paths: Default::default(),
800799
});
801800
}
802801
}

crates/fs/src/fake_git_repo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ impl GitRepository for FakeGitRepository {
359359
entries.sort_by(|a, b| a.0.cmp(&b.0));
360360
anyhow::Ok(GitStatus {
361361
entries: entries.into(),
362-
renamed_paths: HashMap::default(),
363362
})
364363
});
365364
Task::ready(match result {

crates/git/src/repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ fn git_status_args(path_prefixes: &[RepoPath]) -> Vec<OsString> {
20452045
OsString::from("status"),
20462046
OsString::from("--porcelain=v1"),
20472047
OsString::from("--untracked-files=all"),
2048-
OsString::from("--find-renames"),
2048+
OsString::from("--no-renames"),
20492049
OsString::from("-z"),
20502050
];
20512051
args.extend(

crates/git/src/status.rs

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,6 @@ impl FileStatus {
203203
matches!(self, FileStatus::Untracked)
204204
}
205205

206-
pub fn is_renamed(self) -> bool {
207-
let FileStatus::Tracked(tracked) = self else {
208-
return false;
209-
};
210-
tracked.index_status == StatusCode::Renamed
211-
|| tracked.worktree_status == StatusCode::Renamed
212-
}
213-
214206
pub fn summary(self) -> GitSummary {
215207
match self {
216208
FileStatus::Ignored => GitSummary::UNCHANGED,
@@ -438,79 +430,34 @@ impl std::ops::Sub for GitSummary {
438430
#[derive(Clone, Debug)]
439431
pub struct GitStatus {
440432
pub entries: Arc<[(RepoPath, FileStatus)]>,
441-
pub renamed_paths: HashMap<RepoPath, RepoPath>,
442433
}
443434

444435
impl FromStr for GitStatus {
445436
type Err = anyhow::Error;
446437

447438
fn from_str(s: &str) -> Result<Self> {
448-
let mut parts = s.split('\0').peekable();
449-
let mut entries = Vec::new();
450-
let mut renamed_paths = HashMap::default();
451-
452-
while let Some(entry) = parts.next() {
453-
if entry.is_empty() {
454-
continue;
455-
}
456-
457-
if !matches!(entry.get(2..3), Some(" ")) {
458-
continue;
459-
}
460-
461-
let path_or_old_path = &entry[3..];
462-
463-
if path_or_old_path.ends_with('/') {
464-
continue;
465-
}
466-
467-
let status = match entry.as_bytes()[0..2].try_into() {
468-
Ok(bytes) => match FileStatus::from_bytes(bytes).log_err() {
469-
Some(s) => s,
470-
None => continue,
471-
},
472-
Err(_) => continue,
473-
};
474-
475-
let is_rename = matches!(
476-
status,
477-
FileStatus::Tracked(TrackedStatus {
478-
index_status: StatusCode::Renamed | StatusCode::Copied,
479-
..
480-
}) | FileStatus::Tracked(TrackedStatus {
481-
worktree_status: StatusCode::Renamed | StatusCode::Copied,
482-
..
483-
})
484-
);
485-
486-
let (old_path_str, new_path_str) = if is_rename {
487-
let new_path = match parts.next() {
488-
Some(new_path) if !new_path.is_empty() => new_path,
489-
_ => continue,
439+
let mut entries = s
440+
.split('\0')
441+
.filter_map(|entry| {
442+
let sep = entry.get(2..3)?;
443+
if sep != " " {
444+
return None;
490445
};
491-
(path_or_old_path, new_path)
492-
} else {
493-
(path_or_old_path, path_or_old_path)
494-
};
495-
496-
if new_path_str.ends_with('/') {
497-
continue;
498-
}
499-
500-
let new_path = match RelPath::unix(new_path_str).log_err() {
501-
Some(p) => RepoPath::from_rel_path(p),
502-
None => continue,
503-
};
504-
505-
if is_rename {
506-
if let Some(old_path_rel) = RelPath::unix(old_path_str).log_err() {
507-
let old_path_repo = RepoPath::from_rel_path(old_path_rel);
508-
renamed_paths.insert(new_path.clone(), old_path_repo);
446+
let path = &entry[3..];
447+
// The git status output includes untracked directories as well as untracked files.
448+
// We do our own processing to compute the "summary" status of each directory,
449+
// so just skip any directories in the output, since they'll otherwise interfere
450+
// with our handling of nested repositories.
451+
if path.ends_with('/') {
452+
return None;
509453
}
510-
}
511-
512-
entries.push((new_path, status));
513-
}
454+
let status = entry.as_bytes()[0..2].try_into().unwrap();
455+
let status = FileStatus::from_bytes(status).log_err()?;
456+
// git-status outputs `/`-delimited repo paths, even on Windows.
457+
let path = RepoPath::from_rel_path(RelPath::unix(path).log_err()?);
458+
Some((path, status))
459+
})
460+
.collect::<Vec<_>>();
514461
entries.sort_unstable_by(|(a, _), (b, _)| a.cmp(b));
515462
// When a file exists in HEAD, is deleted in the index, and exists again in the working copy,
516463
// git produces two lines for it, one reading `D ` (deleted in index, unmodified in working copy)
@@ -534,7 +481,6 @@ impl FromStr for GitStatus {
534481
});
535482
Ok(Self {
536483
entries: entries.into(),
537-
renamed_paths,
538484
})
539485
}
540486
}
@@ -543,7 +489,6 @@ impl Default for GitStatus {
543489
fn default() -> Self {
544490
Self {
545491
entries: Arc::new([]),
546-
renamed_paths: HashMap::default(),
547492
}
548493
}
549494
}

crates/git_ui/src/git_panel.rs

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,20 +3957,6 @@ impl GitPanel {
39573957
let path_style = self.project.read(cx).path_style(cx);
39583958
let display_name = entry.display_name(path_style);
39593959

3960-
let active_repo = self
3961-
.project
3962-
.read(cx)
3963-
.active_repository(cx)
3964-
.expect("active repository must be set");
3965-
let repo = active_repo.read(cx);
3966-
let repo_snapshot = repo.snapshot();
3967-
3968-
let old_path = if entry.status.is_renamed() {
3969-
repo_snapshot.renamed_paths.get(&entry.repo_path)
3970-
} else {
3971-
None
3972-
};
3973-
39743960
let selected = self.selected_entry == Some(ix);
39753961
let marked = self.marked_entries.contains(&ix);
39763962
let status_style = GitPanelSettings::get_global(cx).status_style;
@@ -3979,16 +3965,15 @@ impl GitPanel {
39793965
let has_conflict = status.is_conflicted();
39803966
let is_modified = status.is_modified();
39813967
let is_deleted = status.is_deleted();
3982-
let is_renamed = status.is_renamed();
39833968

39843969
let label_color = if status_style == StatusStyle::LabelColor {
39853970
if has_conflict {
39863971
Color::VersionControlConflict
3972+
} else if is_modified {
3973+
Color::VersionControlModified
39873974
} else if is_deleted {
39883975
// We don't want a bunch of red labels in the list
39893976
Color::Disabled
3990-
} else if is_renamed || is_modified {
3991-
Color::VersionControlModified
39923977
} else {
39933978
Color::VersionControlAdded
39943979
}
@@ -4008,6 +3993,12 @@ impl GitPanel {
40083993
let checkbox_id: ElementId =
40093994
ElementId::Name(format!("entry_{}_{}_checkbox", display_name, ix).into());
40103995

3996+
let active_repo = self
3997+
.project
3998+
.read(cx)
3999+
.active_repository(cx)
4000+
.expect("active repository must be set");
4001+
let repo = active_repo.read(cx);
40114002
// Checking for current staged/unstaged file status is a chained operation:
40124003
// 1. first, we check for any pending operation recorded in repository
40134004
// 2. if there are no pending ops either running or finished, we then ask the repository
@@ -4162,32 +4153,23 @@ impl GitPanel {
41624153
.items_center()
41634154
.flex_1()
41644155
// .overflow_hidden()
4165-
.when_some(old_path.as_ref(), |this, old_path| {
4166-
let new_display = old_path.display(path_style).to_string();
4167-
let old_display = entry.repo_path.display(path_style).to_string();
4168-
this.child(self.entry_label(old_display, Color::Muted).strikethrough())
4169-
.child(self.entry_label(" → ", Color::Muted))
4170-
.child(self.entry_label(new_display, label_color))
4171-
})
4172-
.when(old_path.is_none(), |this| {
4173-
this.when_some(entry.parent_dir(path_style), |this, parent| {
4174-
if !parent.is_empty() {
4175-
this.child(
4176-
self.entry_label(
4177-
format!("{parent}{}", path_style.separator()),
4178-
path_color,
4179-
)
4180-
.when(status.is_deleted(), |this| this.strikethrough()),
4156+
.when_some(entry.parent_dir(path_style), |this, parent| {
4157+
if !parent.is_empty() {
4158+
this.child(
4159+
self.entry_label(
4160+
format!("{parent}{}", path_style.separator()),
4161+
path_color,
41814162
)
4182-
} else {
4183-
this
4184-
}
4185-
})
4186-
.child(
4187-
self.entry_label(display_name, label_color)
41884163
.when(status.is_deleted(), |this| this.strikethrough()),
4189-
)
4190-
}),
4164+
)
4165+
} else {
4166+
this
4167+
}
4168+
})
4169+
.child(
4170+
self.entry_label(display_name, label_color)
4171+
.when(status.is_deleted(), |this| this.strikethrough()),
4172+
),
41914173
)
41924174
.into_any_element()
41934175
}

crates/git_ui/src/git_ui.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,6 @@ impl RenderOnce for GitStatusIcon {
708708
IconName::SquareMinus,
709709
cx.theme().colors().version_control_deleted,
710710
)
711-
} else if status.is_renamed() {
712-
(
713-
IconName::ArrowRight,
714-
cx.theme().colors().version_control_modified,
715-
)
716711
} else if status.is_modified() {
717712
(
718713
IconName::SquareDot,

crates/project/src/git_store.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ pub struct RepositorySnapshot {
256256
pub id: RepositoryId,
257257
pub statuses_by_path: SumTree<StatusEntry>,
258258
pub pending_ops_by_path: SumTree<PendingOps>,
259-
pub renamed_paths: HashMap<RepoPath, RepoPath>,
260259
pub work_directory_abs_path: Arc<Path>,
261260
pub path_style: PathStyle,
262261
pub branch: Option<Branch>,
@@ -3064,7 +3063,6 @@ impl RepositorySnapshot {
30643063
id,
30653064
statuses_by_path: Default::default(),
30663065
pending_ops_by_path: Default::default(),
3067-
renamed_paths: HashMap::default(),
30683066
work_directory_abs_path,
30693067
branch: None,
30703068
head_commit: None,
@@ -3106,11 +3104,6 @@ impl RepositorySnapshot {
31063104
.iter()
31073105
.map(stash_to_proto)
31083106
.collect(),
3109-
renamed_paths: self
3110-
.renamed_paths
3111-
.iter()
3112-
.map(|(new_path, old_path)| (new_path.to_proto(), old_path.to_proto()))
3113-
.collect(),
31143107
}
31153108
}
31163109

@@ -3180,11 +3173,6 @@ impl RepositorySnapshot {
31803173
.iter()
31813174
.map(stash_to_proto)
31823175
.collect(),
3183-
renamed_paths: self
3184-
.renamed_paths
3185-
.iter()
3186-
.map(|(new_path, old_path)| (new_path.to_proto(), old_path.to_proto()))
3187-
.collect(),
31883176
}
31893177
}
31903178

@@ -4980,17 +4968,6 @@ impl Repository {
49804968
}
49814969
self.snapshot.stash_entries = new_stash_entries;
49824970

4983-
self.snapshot.renamed_paths = update
4984-
.renamed_paths
4985-
.into_iter()
4986-
.filter_map(|(new_path_str, old_path_str)| {
4987-
Some((
4988-
RepoPath::from_proto(&new_path_str).log_err()?,
4989-
RepoPath::from_proto(&old_path_str).log_err()?,
4990-
))
4991-
})
4992-
.collect();
4993-
49944971
let edits = update
49954972
.removed_statuses
49964973
.into_iter()
@@ -5766,7 +5743,6 @@ async fn compute_snapshot(
57665743
id,
57675744
statuses_by_path,
57685745
pending_ops_by_path,
5769-
renamed_paths: statuses.renamed_paths,
57705746
work_directory_abs_path,
57715747
path_style: prev_snapshot.path_style,
57725748
scan_id: prev_snapshot.scan_id + 1,

crates/proto/proto/git.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ message UpdateRepository {
124124
optional GitCommitDetails head_commit_details = 11;
125125
optional string merge_message = 12;
126126
repeated StashEntry stash_entries = 13;
127-
map<string, string> renamed_paths = 14;
128127
}
129128

130129
message RemoveRepository {

0 commit comments

Comments
 (0)