@@ -813,40 +813,12 @@ pub fn get_current_repo_status(
813813 let sender = sender. clone ( ) ;
814814 let path = path. clone ( ) ;
815815 move || {
816- let repo = Repository :: open ( path. clone ( ) ) . expect ( "can't open repo" ) ;
817- let state = repo. state ( ) ;
818- let mut cleanup = Vec :: new ( ) ;
819- let conflicted = conflict:: get_diff ( & repo, & mut Some ( & mut cleanup) )
820- . ok ( )
821- . flatten ( )
822- . map ( |git_diff| make_diff ( & git_diff, DiffKind :: Conflicted ) ) ;
823- if !cleanup. is_empty ( ) {
824- // DANGER: modify index while get conflicted!
825- let mut index = repo. index ( ) . expect ( "cant get index" ) ;
826- for pth in cleanup {
827- index. remove_path ( & pth) . expect ( "cant remove from index" ) ;
828- }
829- get_untracked ( path, sender. clone ( ) ) ;
830- }
831- debug ! ( "GET REGULAR CONFLICTED {:?}" , conflicted. is_some( ) ) ;
832- sender. send_blocking ( crate :: Event :: Conflicted (
833- conflicted,
834- Some ( State :: new ( state, "" . to_string ( ) ) ) ,
835- ) )
816+ merge:: try_finalize_conflict ( path, sender, true ) . unwrap ( ) ;
836817 }
837818 } ) ;
838819
839- // get_unstaged
840820 get_unstaged ( & repo, sender. clone ( ) ) ;
841- // let git_diff = repo.diff_index_to_workdir(None, Some(&mut make_diff_options()))?;
842- // let diff = make_diff(&git_diff, DiffKind::Unstaged);
843- // sender
844- // .send_blocking(crate::Event::Unstaged(if diff.is_empty() {
845- // None
846- // } else {
847- // Some(diff)
848- // }))
849- // .expect("Could not send through channel");
821+
850822 Ok ( ( ) )
851823}
852824
@@ -1225,9 +1197,6 @@ pub fn track_changes(
12251197 break ;
12261198 }
12271199 }
1228- // if has_conflicted {
1229- // assert!(is_tracked);
1230- // }
12311200 // conflicts could be resolved right in this file change manually
12321201 // but it need to update conflicted anyways if we had them!
12331202 // see else below!
@@ -1237,97 +1206,18 @@ pub fn track_changes(
12371206 if let Some ( our) = conflict. our {
12381207 let conflict_path = String :: from_utf8 ( our. path . clone ( ) ) . unwrap ( ) ;
12391208 if file_path == conflict_path {
1240- merge:: try_finalize_conflict ( path. clone ( ) , sender. clone ( ) ) . unwrap ( ) ;
1241- // // if conflicts are resolved manually
1242- // // here will be empty diff! aganzha
1243- // let git_diff = conflict::get_diff(&repo, &mut None).unwrap().unwrap();
1244- // let event = crate::Event::TrackedFile(
1245- // file_path.into(),
1246- // make_diff(&git_diff, DiffKind::Conflicted),
1247- // );
1248- // sender
1249- // .send_blocking(event)
1250- // .expect("Could not send through channel");
1251- // return;
1209+ merge:: try_finalize_conflict ( path. clone ( ) , sender. clone ( ) , false ) . unwrap ( ) ;
12521210 }
12531211 }
12541212 }
12551213 }
12561214 if is_tracked {
12571215 get_unstaged ( & repo, sender. clone ( ) ) ;
1258- // if has_conflicted {
1259- // // this means file was in conflicted but now it is fixed manually!
1260- // // PERHAPS it is no longer in index conflicts.
1261- // // it must be in staged or unstaged then
1262- // // get_current_repo_status(Some(path), sender).expect("cant get status");
1263- // merge::try_finalize_conflict(path, sender).unwrap();
1264- // return;
1265- // }
1266- // let mut opts = make_diff_options();
1267- // opts.pathspec(&file_path);
1268- // let git_diff = repo
1269- // .diff_index_to_workdir(Some(&index), Some(&mut opts))
1270- // .expect("cant' get diff index to workdir");
1271- // let diff = make_diff(&git_diff, DiffKind::Unstaged);
1272-
1273- // if diff.is_empty() {
1274- // let git_diff = repo
1275- // .diff_index_to_workdir(None, Some(&mut make_diff_options()))
1276- // .expect("cant' get diff index to workdir");
1277- // let diff = make_diff(&git_diff, DiffKind::Unstaged);
1278- // sender
1279- // .send_blocking(crate::Event::Unstaged(if diff.is_empty() {
1280- // None
1281- // } else {
1282- // Some(diff)
1283- // }))
1284- // .expect("Could not send through channel");
1285- // } else {
1286- // sender
1287- // .send_blocking(crate::Event::TrackedFile(file_path.into(), diff))
1288- // .expect("Could not send through channel");
1289- // }
12901216 } else {
12911217 get_untracked ( path, sender) ;
12921218 }
12931219}
12941220
1295- // pub fn checkout_oid(
1296- // path: PathBuf,
1297- // sender: Sender<crate::Event>,
1298- // oid: Oid,
1299- // ref_log_msg: Option<String>,
1300- // ) {
1301- // // DANGEROUS! see in status_view!
1302- // let _updater = DeferRefresh::new(path.clone(), sender.clone(), true, true);
1303- // let repo = Repository::open(path.clone()).expect("can't open repo");
1304- // let commit = repo.find_commit(oid).expect("can't find commit");
1305- // let head_ref = repo.head().expect("can't get head");
1306- // assert!(head_ref.is_branch());
1307- // let branch = Branch::wrap(head_ref);
1308- // let log_message = match ref_log_msg {
1309- // None => {
1310- // format!("HEAD -> {}, {}", branch.name().unwrap().unwrap(), oid)
1311- // }
1312- // Some(msg) => msg,
1313- // };
1314- // let mut builder = CheckoutBuilder::new();
1315- // let builder = builder.safe().allow_conflicts(true);
1316-
1317- // sender
1318- // .send_blocking(crate::Event::LockMonitors(true))
1319- // .expect("can send through channel");
1320- // let result = repo.checkout_tree(commit.as_object(), Some(builder));
1321-
1322- // if result.is_err() {
1323- // panic!("{:?}", result);
1324- // }
1325- // let mut head_ref = repo.head().expect("can't get head");
1326- // head_ref
1327- // .set_target(oid, &log_message)
1328- // .expect("cant set target");
1329- // }
1330-
13311221pub fn abort_rebase ( path : PathBuf , sender : Sender < crate :: Event > ) -> Result < ( ) , Error > {
13321222 let _updater = DeferRefresh :: new ( path. clone ( ) , sender, true , true ) ;
13331223
0 commit comments