diff --git a/gp/gp b/gp/gp index 71ca32e..d3d32d2 100755 --- a/gp/gp +++ b/gp/gp @@ -131,10 +131,25 @@ check_git_repo() { # Function to check for uncommitted changes check_for_changes() { - if git diff --cached --quiet && git diff --quiet; then - if [ "$ADD_ALL" = false ]; then - print_warning "No staged changes found" - print_info "Use 'gp -a' to add all files, or stage changes first with 'git add'" + local has_staged=$(! git diff --cached --quiet && echo "true" || echo "false") + local has_modified=$(! git diff --quiet && echo "true" || echo "false") + local has_untracked=$([ -n "$(git ls-files --others --exclude-standard)" ] && echo "true" || echo "false") + + # If add-all is enabled, check if we have any changes at all + if [ "$ADD_ALL" = true ]; then + if [ "$has_staged" = false ] && [ "$has_modified" = false ] && [ "$has_untracked" = false ]; then + print_info "No changes to commit (working tree clean)" + exit 0 + fi + else + # If add-all is disabled, only check staged changes + if [ "$has_staged" = false ]; then + if [ "$has_modified" = true ] || [ "$has_untracked" = true ]; then + print_warning "No staged changes found" + print_info "Use 'gp -a' to add all files, or stage changes first with 'git add'" + else + print_info "No changes to commit (working tree clean)" + fi exit 0 fi fi