File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,14 +103,18 @@ else
103103fi
104104
105105if [ -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
114118else
115119 log_range=" "
116120 ref=" "
You can’t perform that action at this time.
0 commit comments