cli: include tags as upstream commits to exclude in default log revset

Sometimes a tagged commit is not in any branch on the remote, but we
should still consider them upstream and not include them in the
default log template.

This was reported by @colemickens but now that I think about it, I
remember seeing such commits in the Git core repo (v1.4.4.5 and a few
commits before it were never merged into main).

We don't have a good way of testing this because we don't have a
command for creating tags.

Closes #681
This commit is contained in:
Martin von Zweigbergk 2022-10-27 16:40:08 -07:00 committed by Martin von Zweigbergk
parent 95638d453c
commit 8e2dd4b406
2 changed files with 5 additions and 2 deletions

View file

@ -82,7 +82,9 @@ impl UserSettings {
pub fn default_revset(&self) -> String {
self.config
.get_string("ui.default-revset")
.unwrap_or_else(|_| "@ | remote_branches().. | (remote_branches()..)-".to_string())
.unwrap_or_else(|_| {
"@ | (remote_branches() | tags()).. | ((remote_branches() | tags())..)-".to_string()
})
}
pub fn signature(&self) -> Signature {

View file

@ -259,7 +259,8 @@ struct StatusArgs {}
#[derive(clap::Args, Clone, Debug)]
struct LogArgs {
/// Which revisions to show. Defaults to the `ui.default-revset` setting,
/// or "@ | remote_branches().. | (remote_branches()..)-" if it is not set.
/// or `@ | (remote_branches() | tags()).. | ((remote_branches() |
/// tags())..)-` if it is not set.
#[arg(long, short)]
revisions: Option<String>,
/// Show commits modifying the given paths