Skip to content

Commit 6135b32

Browse files
committed
Restore --reverse flag with deprecation warning
1 parent a565e2b commit 6135b32

File tree

2 files changed

+30
-3
lines changed
  • git-branchless-opts/src
  • git-branchless-smartlog/src

2 files changed

+30
-3
lines changed

git-branchless-opts/src/lib.rs

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

343+
/// (Deprecated)
344+
/// Print the smartlog in the opposite of the usual order, with the latest
345+
/// commits first. Can be configured via `branchless.smartlog.reverse`.
346+
#[clap(long)]
347+
pub reverse: bool,
348+
343349
/// Don't automatically add HEAD and the main branch to the list of commits
344350
/// to present. They will still be added if included in the revset.
345351
#[clap(long)]

git-branchless-smartlog/src/lib.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ mod render {
747747
/// The options to use when resolving the revset.
748748
pub resolve_revset_options: ResolveRevsetOptions,
749749

750+
/// Deprecated
751+
/// Reverse the ordering of items in the smartlog output, list the most
752+
/// recent commits first.
753+
pub reverse: bool,
754+
750755
/// Normally HEAD and the main branch are included. Set this to exclude them.
751756
pub exact: bool,
752757
}
@@ -763,6 +768,7 @@ pub fn smartlog(
763768
event_id,
764769
revset,
765770
resolve_revset_options,
771+
reverse,
766772
exact,
767773
} = options;
768774

@@ -820,9 +826,22 @@ pub fn smartlog(
820826
exact,
821827
)?;
822828

823-
let reverse = get_smartlog_reverse(&repo)?;
829+
if reverse {
830+
print!(
831+
"\
832+
branchless: WARNING: The `--reverse` flag is deprecated.
833+
branchless: Please use the `branchless.smartlog.reverse` configuration option.
834+
"
835+
);
836+
}
837+
let reverse_cfg = get_smartlog_reverse(&repo)?;
838+
let reverse_value = match (reverse_cfg, reverse) {
839+
(.., true) => true,
840+
_ => reverse_cfg,
841+
};
842+
824843
let mut lines = render_graph(
825-
&effects.reverse_order(reverse),
844+
&effects.reverse_order(reverse_value),
826845
&repo,
827846
&dag,
828847
&graph,
@@ -845,7 +864,7 @@ pub fn smartlog(
845864
],
846865
)?
847866
.into_iter();
848-
while let Some(line) = if reverse {
867+
while let Some(line) = if reverse_value {
849868
lines.next_back()
850869
} else {
851870
lines.next()
@@ -910,6 +929,7 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
910929
event_id,
911930
revset,
912931
resolve_revset_options,
932+
reverse,
913933
exact,
914934
} = args;
915935

@@ -920,6 +940,7 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
920940
event_id,
921941
revset,
922942
resolve_revset_options,
943+
reverse,
923944
exact,
924945
},
925946
)

0 commit comments

Comments
 (0)