Skip to content

Commit 8b93f91

Browse files
committed
Make path optional
1 parent 35c709d commit 8b93f91

File tree

2 files changed

+25
-2
lines changed
  • gitoxide-core/src/repository
  • src/plumbing/options

2 files changed

+25
-2
lines changed

gitoxide-core/src/repository/log.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,32 @@ use gix::bstr::{BStr, BString, ByteSlice};
22
use gix::prelude::FindExt;
33
use gix::ObjectId;
44

5-
pub fn log(mut repo: gix::Repository, out: &mut dyn std::io::Write, path: BString) -> anyhow::Result<()> {
5+
pub fn log(mut repo: gix::Repository, out: &mut dyn std::io::Write, path: Option<BString>) -> anyhow::Result<()> {
66
repo.object_cache_size_if_unset(repo.compute_object_cache_size_for_tree_diffs(&**repo.index_or_empty()?));
77

8+
if let Some(path) = path {
9+
log_file(repo, out, path)
10+
} else {
11+
log_all(repo, out)
12+
}
13+
}
14+
15+
fn log_all(repo: gix::Repository, out: &mut dyn std::io::Write) -> Result<(), anyhow::Error> {
16+
let head = repo.head()?.peel_to_commit_in_place()?;
17+
let mut topo =
18+
gix::traverse::commit::topo::Builder::from_iters(&repo.objects, [head.id], None::<Vec<gix::ObjectId>>)
19+
.build()?;
20+
21+
while let Some(info) = topo.next() {
22+
let info = info?;
23+
24+
write_info(&repo, &mut *out, &info)?;
25+
}
26+
27+
Ok(())
28+
}
29+
30+
fn log_file(repo: gix::Repository, out: &mut dyn std::io::Write, path: BString) -> anyhow::Result<()> {
831
let head = repo.head()?.peel_to_commit_in_place()?;
932
let mut topo =
1033
gix::traverse::commit::topo::Builder::from_iters(&repo.objects, [head.id], None::<Vec<gix::ObjectId>>)

src/plumbing/options/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ pub mod log {
418418
pub struct Platform {
419419
/// The git path specification to show a log for.
420420
#[clap(value_parser = crate::shared::AsBString)]
421-
pub pathspec: BString,
421+
pub pathspec: Option<BString>,
422422
}
423423
}
424424

0 commit comments

Comments
 (0)