From 3a861dc9069ed2f02fbee1e6416890d76d6b7c6d Mon Sep 17 00:00:00 2001 From: Esgariot Date: Tue, 3 Dec 2024 01:10:41 +0100 Subject: [PATCH 1/2] fix: Reverse commit range before yanking Produce `^..` when yanking consecutive range. Now, given consecutive marked selection, gitui's selection matches `git log`'s output in commit range. --- src/components/commitlist.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 8249429542..3eff2df5a0 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -134,7 +134,9 @@ impl CommitList { /// pub fn copy_commit_hash(&self) -> Result<()> { - let marked = self.marked.as_slice(); + let marked = self.marked.iter().rev().cloned().collect_vec(); + let marked = marked.as_slice(); + let yank: Option = match marked { [] => self .items @@ -147,7 +149,7 @@ impl CommitList { [(_idx, commit)] => Some(commit.to_string()), [first, .., last] => { let marked_consecutive = - marked.windows(2).all(|w| w[0].0 + 1 == w[1].0); + marked.windows(2).all(|w| w[0].0 - 1 == w[1].0); let yank = if marked_consecutive { format!("{}^..{}", first.1, last.1) From b5c057d829d36efa04cd87ba57c77ab54770192f Mon Sep 17 00:00:00 2001 From: Esgariot Date: Tue, 3 Dec 2024 01:40:21 +0100 Subject: [PATCH 2/2] misc: Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda15f11f7..f992c9960a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes * use default shell instead of bash on Unix-like OS [[@yerke](https://github.com/yerke)] ([#2343](https://github.com/extrawurst/gitui/pull/2343)) +* reverse commit range before yanking marked commits, producing `^..` for consecutive commit ranges. [[@Esgariot](https://github.com/Esgariot)] ([#2441](https://github.com/extrawurst/gitui/pull/2441)) ### Fixes * respect env vars like `GIT_CONFIG_GLOBAL` ([#2298](https://github.com/extrawurst/gitui/issues/2298))