diff --git a/src/main/git-elegant-configure b/src/main/git-elegant-configure index 16fa4d6..51c6b82 100755 --- a/src/main/git-elegant-configure +++ b/src/main/git-elegant-configure @@ -6,11 +6,11 @@ _core_comment_char_default="|" _core_comment_char_message="commit message won't start with" _user_name_key="user.name" -_user_name_default=$(git config "$_user_name_key") +_user_name_default=$(git config "$_user_name_key" || echo '') _user_name_message="your user name" _user_email_key="user.email" -_user_email_default=$(git config "$_user_email_key") +_user_email_default=$(git config "$_user_email_key" || echo '') _user_email_message="your user email" _apply_whitespace_key="apply.whitespace" diff --git a/src/test/git-elegant-configure.bats b/src/test/git-elegant-configure.bats index c8ec083..db95fdc 100644 --- a/src/test/git-elegant-configure.bats +++ b/src/test/git-elegant-configure.bats @@ -67,3 +67,11 @@ teardown() { [ "${lines[12]}" = "whitespace issues on patching [fix]: " ] [ ${#lines[@]} -eq 16 ] } + +@test "'configure': command works if both 'user.name' and 'user.email' are absent" { + # move to the directory without the ".git/" + cd /tmp + # force "11" exit code - means all internal vars are initialised (including 'user.name' and 'user.email') + check git-elegant configure + [ "$status" -eq 11 ] +}