From 21de77821ab2f12f391d9fe183c5185c2f69e78c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 8 Jul 2023 01:49:28 +0900 Subject: [PATCH] templater: include pseudo @git targets in branches keyword #1666 --- CHANGELOG.md | 6 +++--- src/commit_templater.rs | 5 +++-- tests/test_branch_command.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 559f1fa5bc..e3a8e45102 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,9 +107,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 setting the `revsets.short-prefixes` config to a different revset. * The last seen state of branches in the underlying git repo is now presented by - `jj branch list` as a remote called `git` (e.g. `main@git`). They can also be - referenced in revsets. Such branches exist in colocated repos or if you use - `jj git export`. + `jj branch list`/`jj log` as a remote called `git` (e.g. `main@git`). They can + also be referenced in revsets. Such branches exist in colocated repos or if + you use `jj git export`. * The new `jj chmod` command allows setting or removing the executable bit on paths. Unlike the POSIX `chmod`, it works on Windows, on conflicted files, and diff --git a/src/commit_templater.rs b/src/commit_templater.rs index 250ac16545..f08971c84f 100644 --- a/src/commit_templater.rs +++ b/src/commit_templater.rs @@ -24,7 +24,7 @@ use jujutsu_lib::hex_util::to_reverse_hex; use jujutsu_lib::id_prefix::IdPrefixContext; use jujutsu_lib::op_store::{RefTarget, WorkspaceId}; use jujutsu_lib::repo::Repo; -use jujutsu_lib::rewrite; +use jujutsu_lib::{git, rewrite}; use once_cell::unsync::OnceCell; use crate::formatter::Formatter; @@ -352,7 +352,8 @@ impl RefNamesIndex { fn build_branches_index(repo: &dyn Repo) -> RefNamesIndex { let mut index = RefNamesIndex::default(); - for (branch_name, branch_target) in repo.view().branches() { + let (all_branches, _) = git::build_unified_branches_map(repo.view()); + for (branch_name, branch_target) in &all_branches { let local_target = branch_target.local_target.as_ref(); let mut unsynced_remote_targets = branch_target .remote_targets diff --git a/tests/test_branch_command.rs b/tests/test_branch_command.rs index 7ff9cca671..d384089007 100644 --- a/tests/test_branch_command.rs +++ b/tests/test_branch_command.rs @@ -250,7 +250,7 @@ fn test_branch_forget_export() { "###); let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r=foo@git", "--no-graph"]); insta::assert_snapshot!(stdout, @r###" - rlvkpnrzqnoo test.user@example.com 2001-02-03 04:05:08.000 +07:00 65b6b74e0897 + rlvkpnrzqnoo test.user@example.com 2001-02-03 04:05:08.000 +07:00 foo@git 65b6b74e0897 (empty) (no description set) "###);