+53
-39
lines changedFilter options
+53
-39
lines changed Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1
1
pub(crate) mod function {
2
+
use crate::repository::HexId;
2
3
use crate::OutputFormat;
3
4
use anyhow::{bail, Context};
4
5
use gix::odb::store::RefreshMode;
5
6
use gix::revision::plumbing::Spec;
6
7
use gix::{prelude::ObjectIdExt, revision::walk::Sorting};
7
-
use std::fmt::Formatter;
8
8
use std::{borrow::Cow, ffi::OsString};
9
9
10
10
pub fn list(
@@ -70,23 +70,4 @@ pub(crate) mod function {
70
70
.context("Need committish as starting point")?
71
71
.id())
72
72
}
73
-
74
-
struct HexId<'a>(gix::Id<'a>, bool);
75
-
76
-
impl<'a> HexId<'a> {
77
-
pub fn new(id: gix::Id<'a>, long_hex: bool) -> Self {
78
-
HexId(id, long_hex)
79
-
}
80
-
}
81
-
82
-
impl std::fmt::Display for HexId<'_> {
83
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
84
-
let HexId(id, long_hex) = self;
85
-
if *long_hex {
86
-
id.fmt(f)
87
-
} else {
88
-
id.shorten_or_id().fmt(f)
89
-
}
90
-
}
91
-
}
92
73
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
1
+
use std::fmt::Formatter;
1
2
use std::path::PathBuf;
2
3
3
4
use anyhow::{Context as AnyhowContext, Result};
4
5
use gix::bstr::BString;
5
6
6
-
pub fn init(directory: Option<PathBuf>) -> Result<gix::discover::repository::Path> {
7
-
gix::create::into(
8
-
directory.unwrap_or_default(),
9
-
gix::create::Kind::WithWorktree,
10
-
gix::create::Options::default(),
11
-
)
12
-
.with_context(|| "Repository initialization failed")
13
-
}
14
-
15
-
pub enum PathsOrPatterns {
16
-
Paths(Box<dyn std::iter::Iterator<Item = BString>>),
17
-
Patterns(Vec<BString>),
18
-
}
19
-
20
7
#[cfg(feature = "archive")]
21
8
pub mod archive;
22
9
pub mod cat;
@@ -60,3 +47,36 @@ pub mod submodule;
60
47
pub mod tree;
61
48
pub mod verify;
62
49
pub mod worktree;
50
+
51
+
pub fn init(directory: Option<PathBuf>) -> Result<gix::discover::repository::Path> {
52
+
gix::create::into(
53
+
directory.unwrap_or_default(),
54
+
gix::create::Kind::WithWorktree,
55
+
gix::create::Options::default(),
56
+
)
57
+
.with_context(|| "Repository initialization failed")
58
+
}
59
+
60
+
pub enum PathsOrPatterns {
61
+
Paths(Box<dyn std::iter::Iterator<Item = BString>>),
62
+
Patterns(Vec<BString>),
63
+
}
64
+
65
+
struct HexId<'a>(gix::Id<'a>, bool);
66
+
67
+
impl<'a> HexId<'a> {
68
+
pub fn new(id: gix::Id<'a>, long_hex: bool) -> Self {
69
+
HexId(id, long_hex)
70
+
}
71
+
}
72
+
73
+
impl std::fmt::Display for HexId<'_> {
74
+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
75
+
let HexId(id, long_hex) = self;
76
+
if *long_hex {
77
+
id.fmt(f)
78
+
} else {
79
+
id.shorten_or_id().fmt(f)
80
+
}
81
+
}
82
+
}
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ pub struct Context {
7
7
pub spec: OsString,
8
8
pub format: OutputFormat,
9
9
pub text: Format,
10
+
pub long_hashes: bool,
10
11
}
11
12
12
13
pub enum Format {
@@ -16,16 +17,17 @@ pub enum Format {
16
17
pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 0..=2;
17
18
18
19
pub(crate) mod function {
20
+
use crate::repository::HexId;
21
+
use crate::{repository::revision::list::Format, OutputFormat};
19
22
use anyhow::{bail, Context};
23
+
use gix::odb::store::RefreshMode;
20
24
use gix::{hashtable::HashMap, revision::walk::Sorting, Progress};
21
25
use layout::{
22
26
backends::svg::SVGWriter,
23
27
core::{base::Orientation, geometry::Point, style::StyleAttr},
24
28
std_shapes::shapes::{Arrow, Element, ShapeKind},
25
29
};
26
30
27
-
use crate::{repository::revision::list::Format, OutputFormat};
28
-
29
31
pub fn list(
30
32
mut repo: gix::Repository,
31
33
mut progress: impl Progress,
@@ -35,12 +37,14 @@ pub(crate) mod function {
35
37
format,
36
38
text,
37
39
limit,
40
+
long_hashes,
38
41
}: super::Context,
39
42
) -> anyhow::Result<()> {
40
43
if format != OutputFormat::Human {
41
44
bail!("Only human output is currently supported");
42
45
}
43
46
repo.object_cache_size_if_unset(4 * 1024 * 1024);
47
+
repo.objects.refresh = RefreshMode::Never;
44
48
45
49
let spec = gix::path::os_str_into_bstr(&spec)?;
46
50
let id = repo
@@ -101,7 +105,7 @@ pub(crate) mod function {
101
105
writeln!(
102
106
out,
103
107
"{} {} {}",
104
-
commit.id().shorten_or_id(),
108
+
HexId::new(commit.id(), long_hashes),
105
109
commit.commit_time.expect("traversal with date"),
106
110
commit.parent_ids.len()
107
111
)?;
Original file line number Diff line number Diff line change
@@ -1148,7 +1148,12 @@ pub fn main() -> Result<()> {
1148
1148
},
1149
1149
),
1150
1150
Subcommands::Revision(cmd) => match cmd {
1151
-
revision::Subcommands::List { spec, svg, limit } => prepare_and_run(
1151
+
revision::Subcommands::List {
1152
+
spec,
1153
+
svg,
1154
+
limit,
1155
+
long_hashes,
1156
+
} => prepare_and_run(
1152
1157
"revision-list",
1153
1158
trace,
1154
1159
auto_verbose,
@@ -1164,6 +1169,7 @@ pub fn main() -> Result<()> {
1164
1169
limit,
1165
1170
spec,
1166
1171
format,
1172
+
long_hashes,
1167
1173
text: svg.map_or(core::repository::revision::list::Format::Text, |path| {
1168
1174
core::repository::revision::list::Format::Svg { path }
1169
1175
}),
Original file line number Diff line number Diff line change
@@ -996,8 +996,11 @@ pub mod revision {
996
996
/// List all commits reachable from the given rev-spec.
997
997
#[clap(visible_alias = "l")]
998
998
List {
999
-
/// How many commits to list at most.
999
+
/// Display long hashes, instead of expensively shortened versions for best performance.
1000
1000
#[clap(long, short = 'l')]
1001
+
long_hashes: bool,
1002
+
/// How many commits to list at most.
1003
+
#[clap(long)]
1001
1004
limit: Option<usize>,
1002
1005
/// Write the graph as SVG file to the given path.
1003
1006
#[clap(long, short = 's')]
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4