Skip to content

Commit a9fa3fd

Browse files
handle non-initial commits without parents
Signed-off-by: Michael Standley <michael.standley@tempus.com>
1 parent a004e01 commit a9fa3fd

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

assets/check

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,18 @@ else
103103
fi
104104

105105
if [ -n "$ref" ] && git cat-file -e "$ref"; then
106-
init_commit=$(git rev-list --max-parents=0 HEAD | tail -n 1)
107-
if [ "${ref}" = "${init_commit}" ]; then
108-
reverse=true
109-
log_range="HEAD"
110-
else
111-
reverse=true
112-
log_range="${ref}~1..HEAD"
113-
fi
106+
reverse=true
107+
log_range="${ref}~1..HEAD"
108+
109+
# if ${ref} does not have parents, ${ref}~1 raises the error: "unknown revision or path not in the working tree"
110+
# the initial commit in a branch will never have parents, but rarely, subsequent commits can also be parentless
111+
orphan_commits=$(git rev-list --max-parents=0 HEAD)
112+
for orphan_commit in ${orphan_commits}; do
113+
if [ "${ref}" = "${orphan_commit}" ]; then
114+
log_range="HEAD"
115+
break
116+
fi
117+
done
114118
else
115119
log_range=""
116120
ref=""

0 commit comments

Comments
 (0)