From 7c9c71cbdd80abdbb57b308238a1e7bb83b22439 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 09:41:10 +0200 Subject: [PATCH 1/8] show merge head ids in merge state --- Cargo.lock | 4 ---- asyncgit/Cargo.toml | 3 ++- asyncgit/src/sync/merge.rs | 17 ++++++++++++++++- asyncgit/src/sync/mod.rs | 2 +- src/tabs/status.rs | 15 +++++++++++++-- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ce98a443b..2cc416525c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,8 +313,6 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "git2" version = "0.13.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b483c6c2145421099df1b4efd50e0f6205479a072199460eff852fa15e5603c7" dependencies = [ "bitflags", "libc", @@ -468,8 +466,6 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libgit2-sys" version = "0.12.19+1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f322155d574c8b9ebe991a04f6908bb49e68a79463338d24a43d6274cb6443e6" dependencies = [ "cc", "libc", diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index a3240c212d..3913c547ca 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -13,7 +13,8 @@ keywords = ["git"] [dependencies] scopetime = { path = "../scopetime", version = "0.1" } -git2 = { version = "0.13", features = ["vendored-openssl"] } +git2 = { path = "../../github/git2-rs", features = ["vendored-openssl"]} +# git2 = { version = "0.13", features = ["vendored-openssl"] } rayon-core = "1.9" crossbeam-channel = "0.5" log = "0.4" diff --git a/asyncgit/src/sync/merge.rs b/asyncgit/src/sync/merge.rs index c61e7411fa..a683804786 100644 --- a/asyncgit/src/sync/merge.rs +++ b/asyncgit/src/sync/merge.rs @@ -1,10 +1,25 @@ use crate::{ error::{Error, Result}, - sync::{reset_stage, reset_workdir, utils}, + sync::{reset_stage, reset_workdir, utils, CommitId}, }; use git2::{BranchType, MergeOptions}; use scopetime::scope_time; +/// +pub fn merge_state_info(repo_path: &str) -> Result> { + scope_time!("merge_state_info"); + + let mut repo = utils::repo(repo_path)?; + + let mut ids: Vec = Vec::new(); + repo.mergehead_foreach(|id| { + ids.push(CommitId::from(*id)); + true + })?; + + Ok(ids) +} + /// does these steps: /// * reset all staged changes, /// * revert all changes in workdir diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 7bb41c95f2..94074d9650 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -50,7 +50,7 @@ pub use hooks::{ pub use hunks::{reset_hunk, stage_hunk, unstage_hunk}; pub use ignore::add_to_ignore; pub use logwalker::LogWalker; -pub use merge::{abort_merge, merge_branch}; +pub use merge::{abort_merge, merge_branch, merge_state_info}; pub use remotes::{ get_default_remote, get_remotes, push::AsyncProgress, tags::PushTagsProgress, diff --git a/src/tabs/status.rs b/src/tabs/status.rs index cccca38321..275dac4b07 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -21,6 +21,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; +use itertools::Itertools; use std::convert::Into; use std::convert::TryFrom; use tui::{ @@ -214,9 +215,19 @@ impl Status { f: &mut tui::Frame, r: tui::layout::Rect, ) -> Result<()> { - if let Ok(state) = asyncgit::sync::repo_state(CWD) { + if let Ok(state) = sync::repo_state(CWD) { if state != RepoState::Clean { - let txt = format!("{:?}", state); + let ids = + sync::merge_state_info(CWD).unwrap_or_default(); + let ids = format!( + "({})", + ids.iter() + .map(|id| sync::CommitId::get_short_string( + id + )) + .join(",") + ); + let txt = format!("{:?} {}", state, ids); let txt_len = u16::try_from(txt.len())?; let w = Paragraph::new(txt) .style(Style::default().fg(Color::Red)) From 404653565f05e5e2e5d57e2b6de6b54552439b3f Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 09:46:24 +0200 Subject: [PATCH 2/8] use PR for now --- Cargo.lock | 2 ++ asyncgit/Cargo.toml | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2cc416525c..102d82faff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,6 +313,7 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "git2" version = "0.13.18" +source = "git+https://github.com/extrawurst/git2-rs.git?rev=4619405#461940586fe586c3527314e1954708f645efd2c5" dependencies = [ "bitflags", "libc", @@ -466,6 +467,7 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libgit2-sys" version = "0.12.19+1.1.0" +source = "git+https://github.com/extrawurst/git2-rs.git?rev=4619405#461940586fe586c3527314e1954708f645efd2c5" dependencies = [ "cc", "libc", diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index 3913c547ca..6a808bf474 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -13,8 +13,9 @@ keywords = ["git"] [dependencies] scopetime = { path = "../scopetime", version = "0.1" } -git2 = { path = "../../github/git2-rs", features = ["vendored-openssl"]} # git2 = { version = "0.13", features = ["vendored-openssl"] } +# git2 = { path = "../../github/git2-rs", features = ["vendored-openssl"]} +git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="4619405", features = ["vendored-openssl"]} rayon-core = "1.9" crossbeam-channel = "0.5" log = "0.4" From cbb5003270d3b6187c5fa8d1f581eb2310d26956 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 09:48:35 +0200 Subject: [PATCH 3/8] fix rev --- asyncgit/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index 6a808bf474..8c6be27f1d 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -15,7 +15,7 @@ keywords = ["git"] scopetime = { path = "../scopetime", version = "0.1" } # git2 = { version = "0.13", features = ["vendored-openssl"] } # git2 = { path = "../../github/git2-rs", features = ["vendored-openssl"]} -git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="4619405", features = ["vendored-openssl"]} +git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="513a8c9", features = ["vendored-openssl"]} rayon-core = "1.9" crossbeam-channel = "0.5" log = "0.4" From 637b0b5c2b18c5eeec8a8ed048a2b0d0c1c5f0f5 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 09:50:39 +0200 Subject: [PATCH 4/8] fix rev and add offline clean --- .github/workflows/ci.yml | 2 +- Cargo.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24e953ea6b..1fa34643c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: MacOS Workaround if: matrix.os == 'macos-latest' - run: cargo clean --locked -p serde_derive -p thiserror + run: cargo clean --locked --offline -p serde_derive -p thiserror - name: Install Rust uses: actions-rs/toolchain@v1 diff --git a/Cargo.lock b/Cargo.lock index 102d82faff..519546901a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -313,7 +313,7 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "git2" version = "0.13.18" -source = "git+https://github.com/extrawurst/git2-rs.git?rev=4619405#461940586fe586c3527314e1954708f645efd2c5" +source = "git+https://github.com/extrawurst/git2-rs.git?rev=513a8c9#513a8c98ea26471741854934043a11fbc35feadd" dependencies = [ "bitflags", "libc", @@ -467,7 +467,7 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libgit2-sys" version = "0.12.19+1.1.0" -source = "git+https://github.com/extrawurst/git2-rs.git?rev=4619405#461940586fe586c3527314e1954708f645efd2c5" +source = "git+https://github.com/extrawurst/git2-rs.git?rev=513a8c9#513a8c98ea26471741854934043a11fbc35feadd" dependencies = [ "cc", "libc", From 41e50dab6b9c4b9d8a3d3ac943a8351c26410e19 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 09:58:51 +0200 Subject: [PATCH 5/8] add unittest --- asyncgit/src/sync/merge.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/asyncgit/src/sync/merge.rs b/asyncgit/src/sync/merge.rs index a683804786..323d451b5b 100644 --- a/asyncgit/src/sync/merge.rs +++ b/asyncgit/src/sync/merge.rs @@ -62,3 +62,32 @@ pub fn merge_branch(repo_path: &str, branch: &str) -> Result<()> { Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::sync::{ + create_branch, + tests::{repo_init, write_commit_file}, + }; + + #[test] + fn test_smoke() { + let (_td, repo) = repo_init().unwrap(); + let root = repo.path().parent().unwrap(); + let repo_path = root.as_os_str().to_str().unwrap(); + + let c1 = + write_commit_file(&repo, "test.txt", "test", "commit1"); + + create_branch(repo_path, "foo").unwrap(); + + write_commit_file(&repo, "test.txt", "test2", "commit2"); + + merge_branch(repo_path, "master").unwrap(); + + let mergeheads = merge_state_info(repo_path).unwrap(); + + assert_eq!(mergeheads[0], c1); + } +} From 8485db07e5a5c5ae7c9b2c8b16acd999045a61bf Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Mon, 10 May 2021 10:00:02 +0200 Subject: [PATCH 6/8] fix ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fa34643c0..1bedeb35d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: MacOS Workaround if: matrix.os == 'macos-latest' - run: cargo clean --locked --offline -p serde_derive -p thiserror + run: cargo clean -p serde_derive -p thiserror - name: Install Rust uses: actions-rs/toolchain@v1 From 715fbfb0df7ccd5067fd3028e3b90aa3013a565c Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 11 May 2021 09:58:21 +0200 Subject: [PATCH 7/8] merged master --- CHANGELOG.md | 3 ++- Cargo.lock | 20 ++++++++++---------- src/components/branchlist.rs | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c648c3f419..9a68e07c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - warning if commit subject line gets too long ([#478](https://github.com/extrawurst/gitui/issues/478)) ## Changed -- smarter log timestamps ([#682](https://github.com/extrawurst/gitui/issues/682)) +- smarter log timestamps ([#682](https://github.com/extrawurst/gitui/issues/682)) +- create-branch popup aligned with rename-branch [[@bruceCoelho](https://github.com/bruceCoelho)] ([#679](https://github.com/extrawurst/gitui/issues/679)) ## [0.15.0] - 2020-04-27 diff --git a/Cargo.lock b/Cargo.lock index 519546901a..2270a51810 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "addr2line" -version = "0.14.1" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "gimli", ] @@ -78,9 +78,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.58" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88fb5a785d6b44fd9d6700935608639af1b8356de1e55d5f7c2740f4faa15d82" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", "cc", @@ -306,9 +306,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "git2" @@ -652,9 +652,9 @@ dependencies = [ [[package]] name = "object" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" [[package]] name = "once_cell" @@ -1168,9 +1168,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "url" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", "idna", diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs index c79a22e407..881f84ed25 100644 --- a/src/components/branchlist.rs +++ b/src/components/branchlist.rs @@ -202,7 +202,6 @@ impl Component for BranchListComponent { self.queue .borrow_mut() .push_back(InternalEvent::CreateBranch); - self.hide(); } else if e == self.key_config.rename_branch && self.valid_selection() { From e04903984bcf7a173e2540c29078cf567fb702c6 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 11 May 2021 17:00:10 +0200 Subject: [PATCH 8/8] use new git2 release --- Cargo.lock | 14 ++++++++------ asyncgit/Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2270a51810..9b9f2f14ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,8 +312,9 @@ checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "git2" -version = "0.13.18" -source = "git+https://github.com/extrawurst/git2-rs.git?rev=513a8c9#513a8c98ea26471741854934043a11fbc35feadd" +version = "0.13.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17929de7239dea9f68aa14f94b2ab4974e7b24c1314275ffcc12a7758172fa18" dependencies = [ "bitflags", "libc", @@ -466,8 +467,9 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "libgit2-sys" -version = "0.12.19+1.1.0" -source = "git+https://github.com/extrawurst/git2-rs.git?rev=513a8c9#513a8c98ea26471741854934043a11fbc35feadd" +version = "0.12.20+1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e2f09917e00b9ad194ae72072bb5ada2cca16d8171a43e91ddba2afbb02664b" dependencies = [ "cc", "libc", @@ -664,9 +666,9 @@ checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "openssl-probe" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-src" diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index 8c6be27f1d..b1872a6511 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -13,9 +13,9 @@ keywords = ["git"] [dependencies] scopetime = { path = "../scopetime", version = "0.1" } -# git2 = { version = "0.13", features = ["vendored-openssl"] } +git2 = { version = "0.13", features = ["vendored-openssl"] } # git2 = { path = "../../github/git2-rs", features = ["vendored-openssl"]} -git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="513a8c9", features = ["vendored-openssl"]} +# git2 = { git="https://github.com/extrawurst/git2-rs.git", rev="513a8c9", features = ["vendored-openssl"]} rayon-core = "1.9" crossbeam-channel = "0.5" log = "0.4"