From 67a573dae86ae43d30395864351b81ec03c8bef8 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 28 Aug 2022 17:52:47 +0200 Subject: [PATCH] create-git-repo.sh: fix amend error if there's no branch checked out In this case, `git commit --amend` fails. The state of a .git repo existing without a branch being checked out can be reached through the following sequence of events (which I just seem to have triggered): 1. The script calls `git init` 2. The user interrupts the script before `git commit` is finished --- test/lib/create-git-repo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/create-git-repo.sh b/test/lib/create-git-repo.sh index 110dfdf..3549904 100644 --- a/test/lib/create-git-repo.sh +++ b/test/lib/create-git-repo.sh @@ -4,7 +4,7 @@ cd "$scriptDir/.." amend=--amend - if [[ ! -e .git ]]; then + if [[ ! -e .git ]] || ! git rev-parse HEAD 2>/dev/null; then git init amend= fi