Skip to content

Commit df3574b

Browse files
authored
Merge pull request #50 from mlange-42/bugfis/missing-tags
Fix for missing tags due to tag id inconsistency, increment version to 0.4.3 Tag ids/hashes are inconsistent in git2-rs / libgit2. Sometimes, the tag's id are separate ids of tags (find_tag), sometimes thay are the ids of the target commit. To fix the problem, first look for the id with find_tag, then with find_commit if not found with find_tags.
2 parents d370e8f + 6c6339e commit df3574b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "git-graph"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
authors = ["Martin Lange <[email protected]>"]
55
description = "Command line tool to show clear git graphs arranged for your branching model"
66
repository = "https://github.com/mlange-42/git-graph.git"

src/graph.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,13 @@ fn extract_branches(
639639
for (oid, name) in tags {
640640
let name = std::str::from_utf8(&name[5..]).map_err(|err| err.to_string())?;
641641

642-
if let Ok(tag) = repository.find_tag(oid) {
643-
if let Some(target_index) = indices.get(&tag.target_id()) {
642+
let target = repository
643+
.find_tag(oid)
644+
.map(|tag| tag.target_id())
645+
.or_else(|_| repository.find_commit(oid).map(|_| oid));
646+
647+
if let Ok(target_oid) = target {
648+
if let Some(target_index) = indices.get(&target_oid) {
644649
counter += 1;
645650
let term_col = to_terminal_color(
646651
&branch_color(
@@ -658,7 +663,7 @@ fn extract_branches(
658663
counter,
659664
);
660665
let tag_info = BranchInfo::new(
661-
tag.target_id(),
666+
target_oid,
662667
None,
663668
name.to_string(),
664669
settings.branches.persistence.len() as u8 + 1,

0 commit comments

Comments
 (0)