summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--branch_list_builder.go13
-rwxr-xr-xtest/case_insensitive_checkouts.sh30
-rwxr-xr-xtest/lots_of_commits.sh2
-rwxr-xr-xtest/unicode_characters.sh2
4 files changed, 44 insertions, 3 deletions
diff --git a/branch_list_builder.go b/branch_list_builder.go
index 113a5a44a..1d4dc338d 100644
--- a/branch_list_builder.go
+++ b/branch_list_builder.go
@@ -66,11 +66,19 @@ func (b *branchListBuilder) appendNewBranches(finalBranches, newBranches, existi
if included == branchIncluded(newBranch.Name, existingBranches) {
finalBranches = append(finalBranches, newBranch)
}
-
}
return finalBranches
}
+func sanitisedReflogName(reflogBranch Branch, safeBranches []Branch) string {
+ for _, safeBranch := range safeBranches {
+ if strings.ToLower(safeBranch.Name) == strings.ToLower(reflogBranch.Name) {
+ return safeBranch.Name
+ }
+ }
+ return reflogBranch.Name
+}
+
func (b *branchListBuilder) build() []Branch {
branches := make([]Branch, 0)
head := b.obtainCurrentBranch()
@@ -80,6 +88,9 @@ func (b *branchListBuilder) build() []Branch {
}
reflogBranches := b.obtainReflogBranches()
reflogBranches = uniqueByName(append([]Branch{head}, reflogBranches...))
+ for i, reflogBranch := range reflogBranches {
+ reflogBranches[i].Name = sanitisedReflogName(reflogBranch, safeBranches)
+ }
branches = b.appendNewBranches(branches, reflogBranches, safeBranches, true)
branches = b.appendNewBranches(branches, safeBranches, branches, false)
diff --git a/test/case_insensitive_checkouts.sh b/test/case_insensitive_checkouts.sh
new file mode 100755
index 000000000..d797a4181
--- /dev/null
+++ b/test/case_insensitive_checkouts.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# this script makes a repo with lots of commits
+
+# call this command from the test directory:
+# ./lots_of_commits.sh; cd testrepo; gg; cd ..
+
+# -e means exit if something fails
+# -x means print out simple commands before running them
+set -ex
+
+reponame="case_insensitive_checkouts"
+
+rm -rf ${reponame}
+mkdir ${reponame}
+cd ${reponame}
+
+git init
+
+touch foo
+git add foo
+git commit -m "init"
+git branch -a
+git branch test
+git branch TEST
+git checkout TEST
+git checkout TeST
+git checkout TesT
+git checkout TEsT
+git branch -a \ No newline at end of file
diff --git a/test/lots_of_commits.sh b/test/lots_of_commits.sh
index 6a92d32e2..b56c9a6be 100755
--- a/test/lots_of_commits.sh
+++ b/test/lots_of_commits.sh
@@ -9,7 +9,7 @@
# -x means print out simple commands before running them
set -ex
-reponame="testrepo"
+reponame="lots_of_commits"
rm -rf ${reponame}
mkdir ${reponame}
diff --git a/test/unicode_characters.sh b/test/unicode_characters.sh
index 92640d52f..2db0b3cfa 100755
--- a/test/unicode_characters.sh
+++ b/test/unicode_characters.sh
@@ -10,7 +10,7 @@
# -x means print out simple commands before running them
set -ex
-reponame="testrepo"
+reponame="unicode_characters"
rm -rf ${reponame}
mkdir ${reponame}