summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas O'Donnell <andytom@users.noreply.github.com>2020-04-11 22:10:39 +0200
committerGitHub <noreply@github.com>2020-04-11 16:10:39 -0400
commit391add767fbf5137e8fef3f01e107f751353538c (patch)
tree4723a17ae2fe39027948a880674d97d6cb9571ac
parent4551a20d0e71e5368657faa0ab21ea2d07404900 (diff)
revert: fix(git_branch,git_status): implement fallback branch_nā€¦ (#1092)
-rw-r--r--src/modules/git_branch.rs5
-rw-r--r--src/modules/git_status.rs5
2 files changed, 2 insertions, 8 deletions
diff --git a/src/modules/git_branch.rs b/src/modules/git_branch.rs
index 4b58c33de..56414b19a 100644
--- a/src/modules/git_branch.rs
+++ b/src/modules/git_branch.rs
@@ -30,10 +30,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
};
let repo = context.get_repo().ok()?;
- // bare repos don't have a branch name, so `repo.branch.as_ref` would return None,
- // but git treats "master" as the default branch name
- let default_branch = String::from("master");
- let branch_name = repo.branch.as_ref().unwrap_or(&default_branch);
+ let branch_name = repo.branch.as_ref()?;
let truncated_graphemes = get_graphemes(&branch_name, len);
// The truncation symbol should only be added if we truncated
let truncated_and_symbol = if len < graphemes_len(&branch_name) {
diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs
index b689b070e..0778bbce9 100644
--- a/src/modules/git_status.rs
+++ b/src/modules/git_status.rs
@@ -23,10 +23,7 @@ use std::collections::HashMap;
/// - `āœ˜` ā€” A file's deletion has been added to the staging area
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let repo = context.get_repo().ok()?;
- // bare repos don't have a branch name, so `repo.branch.as_ref` would return None,
- // but git treats "master" as the default branch name
- let default_branch = String::from("master");
- let branch_name = repo.branch.as_ref().unwrap_or(&default_branch);
+ let branch_name = repo.branch.as_ref()?;
let repo_root = repo.root.as_ref()?;
let mut repository = Repository::open(repo_root).ok()?;