Skip to content

Commit 31f6771

Browse files
authored
add trace-libgit feature (#905)
1 parent d6a2af8 commit 31f6771

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
## Added
11+
- add `trace-libgit` feature to make git tracing optional [[@dm9pZCAq](https://github.com/dm9pZCAq)] ([#902](https://github.com/extrawurst/gitui/issues/902))
12+
813
## [0.18] - 2021-10-11
914

1015
**rebase merge with conflicts**

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ keywords = [
2020

2121
[dependencies]
2222
scopetime = { path = "./scopetime", version = "0.1" }
23-
asyncgit = { path = "./asyncgit", version = "0.18" }
23+
asyncgit = { path = "./asyncgit", version = "0.18", default-features = false }
2424
filetreelist = { path = "./filetreelist", version = "0.4" }
2525
crossterm = { version = "0.20", features = [ "serde" ] }
2626
clap = { version = "2.33", default-features = false }
@@ -64,8 +64,9 @@ pretty_assertions = "1.0"
6464
maintenance = { status = "actively-developed" }
6565

6666
[features]
67-
default=[]
67+
default=["trace-libgit"]
6868
timing=["scopetime/enabled"]
69+
trace-libgit=["asyncgit/trace-libgit"]
6970

7071
[workspace]
7172
members=[
@@ -86,4 +87,4 @@ codegen-units = 1
8687
opt-level = 3
8788

8889
[profile.dev]
89-
split-debuginfo = "unpacked"
90+
split-debuginfo = "unpacked"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ Binaries available for:
167167
### Cargo Install
168168

169169
The simplest way to start playing around with `gitui` is to have `cargo` build and install it with `cargo install gitui`. If you are not familiar with rust and cargo: [Getting Started with Rust](https://doc.rust-lang.org/book/ch01-00-getting-started.html)
170+
### Cargo Features
171+
#### trace-libgit
172+
enable `libgit2` tracing
173+
174+
works if `libgit2` builded with `-DENABLE_TRACE=ON`
175+
176+
this feature enabled by default, to disable: `cargo install --no-default-features`
170177

171178
## 8. <a name="diagnostics"></a> Diagnostics <small><sup>[Top ▲](#table-of-contents)</sup></small>
172179

asyncgit/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ easy-cast = "0.4"
3030
tempfile = "3.2"
3131
invalidstring = { path = "../invalidstring", version = "0.1" }
3232
serial_test = "0.5.1"
33-
pretty_assertions = "1.0"
33+
pretty_assertions = "1.0"
34+
35+
[features]
36+
default = ["trace-libgit"]
37+
trace-libgit = []

asyncgit/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ pub fn hash<T: Hash + ?Sized>(v: &T) -> u64 {
101101
}
102102

103103
///
104+
#[cfg(feature = "trace-libgit")]
104105
pub fn register_tracing_logging() -> bool {
106+
fn git_trace(level: git2::TraceLevel, msg: &str) {
107+
log::info!("[{:?}]: {}", level, msg);
108+
}
105109
git2::trace_set(git2::TraceLevel::Trace, git_trace)
106110
}
107111

108-
fn git_trace(level: git2::TraceLevel, msg: &str) {
109-
log::info!("[{:?}]: {}", level, msg);
112+
///
113+
#[cfg(not(feature = "trace-libgit"))]
114+
pub fn register_tracing_logging() -> bool {
115+
true
110116
}

0 commit comments

Comments
 (0)