From af4930911628533bc669ef1ac181e4ff1ab96ece Mon Sep 17 00:00:00 2001
From: Ken Odegard <kodegard@anaconda.com>
Date: Tue, 11 Jan 2022 10:21:56 -0600
Subject: [PATCH 1/2] Properly disambiguate between branch or file checkout

---
 entrypoint.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 0d87608..a89bea4 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -60,7 +60,7 @@ _switch_to_branch() {
     else
         # Switch to branch from current Workflow run
         # shellcheck disable=SC2086
-        git checkout $INPUT_BRANCH;
+        git checkout $INPUT_BRANCH --;
     fi
 }
 

From e3cb9ba079224bed2a8cd6aab37bffc62e4b0c7b Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <hello@stefanzweifel.io>
Date: Wed, 12 Jan 2022 21:05:06 +0100
Subject: [PATCH 2/2] Add Test Case

---
 tests/git-auto-commit.bats | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats
index bdadd35..2250496 100644
--- a/tests/git-auto-commit.bats
+++ b/tests/git-auto-commit.bats
@@ -507,3 +507,29 @@ git_auto_commit() {
     run git status
     assert_output --partial 'nothing to commit, working tree clean'
 }
+
+@test "It does not throw an error if branch is checked out with same name as a file or folder in the repo" {
+
+    # Add File called dev and commit/push
+    echo "Create dev file";
+    cd "${FAKE_LOCAL_REPOSITORY}";
+    echo this is a file named dev > dev
+    git add dev
+    git commit -m 'add file named dev'
+    git update-ref refs/remotes/origin/master master
+    git update-ref refs/remotes/origin/dev master
+
+    # ---
+
+    INPUT_BRANCH=dev
+
+    touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{4,5,6}.txt
+
+    run git_auto_commit
+
+    assert_success
+
+    assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
+    assert_line "::set-output name=changes_detected::true"
+    assert_line "::debug::Push commit to remote branch dev"
+}