Quoting Johannes Sixt <j6t@xxxxxxxx>:
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -200,7 +200,19 @@ require_work_tree () {
}
require_clean_work_tree () {
- git rev-parse --verify HEAD >/dev/null || exit 1
+ if git rev-parse --verify HEAD >/dev/null 2>/dev/null
+ then
+ compare_to=HEAD
+ else
+ if [ -z "$ORPHAN_OK" ]
+ then
+ echo >&2 "Cannot $1: Your current branch does not have any commits yet."
+ exit 1
+ else
+ # SHA1 of an empty tree
+ compare_to=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+ fi
+ fi
It is worrysome that this now throws away any error message of
rev-parse. A more conservative approach would be to test for -z
"$ORPHAN_OK" first and entail new behavior only for the "$ORPHAN_OK"
case.
Those error messages didn't seem to be helpful and in some cases they
were even misleading, e.g.:
$ git checkout --orphan orphan
$ git rm -rf .
$ git script valid-branch
fatal: Needed a single revision
$ # Huh? Didn't I just gave you one?!
Gábor
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html