Skip to content

Commit 9ba6da9

Browse files
committed
smartlog: replace --reverse flag with config opt
1 parent ce1aa49 commit 9ba6da9

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

git-branchless-lib/src/core/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ pub fn get_smartlog_default_revset(repo: &Repo) -> eyre::Result<String> {
108108
})
109109
}
110110

111+
/// Whether to reverse the smartlog direction by default
112+
#[instrument]
113+
pub fn get_smartlog_reverse(repo: &Repo) -> eyre::Result<bool> {
114+
repo.get_readonly_config()?
115+
.get_or("branchless.smartlog.reverse", false)
116+
}
117+
111118
/// Get the default comment character.
112119
#[instrument]
113120
pub fn get_comment_char(repo: &Repo) -> eyre::Result<char> {

git-branchless-opts/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,6 @@ pub struct SmartlogArgs {
340340
#[clap(value_parser)]
341341
pub revset: Option<Revset>,
342342

343-
/// Print the smartlog in the opposite of the usual order, with the latest
344-
/// commits first.
345-
#[clap(long)]
346-
pub reverse: bool,
347-
348343
/// Don't automatically add HEAD and the main branch to the list of commits
349344
/// to present. They will still be added if included in the revset.
350345
#[clap(long)]

git-branchless-smartlog/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use std::time::SystemTime;
1919
use git_branchless_invoke::CommandContext;
2020
use git_branchless_opts::{Revset, SmartlogArgs};
2121
use lib::core::config::{
22-
get_hint_enabled, get_hint_string, get_smartlog_default_revset, print_hint_suppression_notice,
23-
Hint,
22+
get_hint_enabled, get_hint_string, get_smartlog_default_revset, get_smartlog_reverse,
23+
print_hint_suppression_notice, Hint,
2424
};
2525
use lib::core::repo_ext::RepoExt;
2626
use lib::core::rewrite::find_rewrite_target;
@@ -747,10 +747,6 @@ mod render {
747747
/// The options to use when resolving the revset.
748748
pub resolve_revset_options: ResolveRevsetOptions,
749749

750-
/// Reverse the ordering of items in the smartlog output, list the most
751-
/// recent commits first.
752-
pub reverse: bool,
753-
754750
/// Normally HEAD and the main branch are included. Set this to exclude them.
755751
pub exact: bool,
756752
}
@@ -767,7 +763,6 @@ pub fn smartlog(
767763
event_id,
768764
revset,
769765
resolve_revset_options,
770-
reverse,
771766
exact,
772767
} = options;
773768

@@ -825,6 +820,7 @@ pub fn smartlog(
825820
exact,
826821
)?;
827822

823+
let reverse = get_smartlog_reverse(&repo)?;
828824
let mut lines = render_graph(
829825
&effects.reverse_order(reverse),
830826
&repo,
@@ -914,7 +910,6 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
914910
event_id,
915911
revset,
916912
resolve_revset_options,
917-
reverse,
918913
exact,
919914
} = args;
920915

@@ -925,7 +920,6 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
925920
event_id,
926921
revset,
927922
resolve_revset_options,
928-
reverse,
929923
exact,
930924
},
931925
)

git-branchless/tests/test_init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ fn test_main_branch_not_found_error_message() -> eyre::Result<()> {
316316
317317
0: branchless::core::eventlog::from_event_log_db with effects=<Output fancy=false> repo=<Git repository at: "<repo-path>/.git/"> event_log_db=<EventLogDb path=Some("<repo-path>/.git/branchless/db.sqlite3")>
318318
at some/file/path.rs:123
319-
1: git_branchless_smartlog::smartlog with effects=<Output fancy=false> git_run_info=<GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> options=SmartlogOptions { event_id: None, revset: None, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false }, reverse: false, exact: false }
319+
1: git_branchless_smartlog::smartlog with effects=<Output fancy=false> git_run_info=<GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> options=SmartlogOptions { event_id: None, revset: None, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false }, exact: false }
320320
at some/file/path.rs:123
321-
2: git_branchless_smartlog::command_main with ctx=CommandContext { effects: <Output fancy=false>, git_run_info: <GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> } args=SmartlogArgs { event_id: None, revset: None, reverse: false, exact: false, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false } }
321+
2: git_branchless_smartlog::command_main with ctx=CommandContext { effects: <Output fancy=false>, git_run_info: <GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> } args=SmartlogArgs { event_id: None, revset: None, exact: false, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false } }
322322
at some/file/path.rs:123
323323
324324
Suggestion:

0 commit comments

Comments
 (0)