diff --git a/bin/git-authors b/bin/git-authors index a9ef29292..549235ae1 100755 --- a/bin/git-authors +++ b/bin/git-authors @@ -22,9 +22,9 @@ done if ! $LIST; then FILE=$1 - if test "$FILE" = ""; then - FILE=$(ls | grep -E 'authors|contributors' -i|head -n1) - if test "$FILE" = ""; then + if [ -z "$FILE" ]; then + FILE=$(find . -mindepth 1 -maxdepth 1 -iregex '.*\(authors\|contributors\).*' | head -n1) + if [ -z "$FILE" ]; then FILE='AUTHORS' fi fi diff --git a/bin/git-changelog b/bin/git-changelog index 0d1753fe6..82b480200 100755 --- a/bin/git-changelog +++ b/bin/git-changelog @@ -280,7 +280,8 @@ commitList() { for (( i=0; i<"${_tags_list_keys_length}"; i++ )); do local __curr_tag="${tags_list_keys[$i]}" local __prev_tag="${tags_list_keys[$i+1]:-null}" - local __curr_date="$(_valueForKeyFakeAssocArray "${__curr_tag}" "${tags_list[*]}")" + local __curr_date + __curr_date="$(_valueForKeyFakeAssocArray "${__curr_tag}" "${tags_list[*]}")" __curr_date="${__curr_date##*=>}" # output latest commits, up until the most-recent tag, these are all @@ -528,9 +529,10 @@ main() { # # generate changelog # - local tmpfile="$(git_extra_mktemp)" - local changelog="$(_valueForKeyFakeAssocArray "output_file" "${option[*]}")" - local title_tag="$(_valueForKeyFakeAssocArray "title_tag" "${option[*]}")" + local tmpfile changelog title_tag + tmpfile="$(git_extra_mktemp)" + changelog="$(_valueForKeyFakeAssocArray "output_file" "${option[*]}")" + title_tag="$(_valueForKeyFakeAssocArray "title_tag" "${option[*]}")" if [[ "$(_valueForKeyFakeAssocArray "list_style" "${option[*]}")" == true ]]; then if [[ "$(_valueForKeyFakeAssocArray "list_all" "${option[*]}")" == true ]]; then @@ -549,7 +551,7 @@ main() { fi if [[ -z "$changelog" ]]; then - changelog="$(ls | grep -E 'change|history' -i | head -n1)" + changelog="$(find . -mindepth 1 -maxdepth 1 -iregex '.*\(change\|history\).*' | head -n1)" if [[ -z "$changelog" ]]; then changelog="History.md"; fi diff --git a/bin/git-guilt b/bin/git-guilt index e63f71a07..3fe644ac9 100755 --- a/bin/git-guilt +++ b/bin/git-guilt @@ -87,7 +87,7 @@ do do printf "+" done - printf "(%s)" $num + printf "(%s)" "$num" else for (( i = 0; i < num; i++ )) do diff --git a/bin/git-rebase-patch b/bin/git-rebase-patch index f5cf510fe..395304e9d 100755 --- a/bin/git-rebase-patch +++ b/bin/git-rebase-patch @@ -20,7 +20,7 @@ cleanup() { rm "$index" exit 2 } -trap cleanup 2 +trap cleanup INT # Go back in history while parent commits are available. echo "Trying to find a commit the patch applies to..." diff --git a/bin/git-scp b/bin/git-scp index 7aa2131d4..52d4d1463 100755 --- a/bin/git-scp +++ b/bin/git-scp @@ -80,7 +80,8 @@ function scp_and_stage set_remote "$1" shift - local refhead="$(git rev-parse --quiet --verify "$1")" + local refhead + refhead="$(git rev-parse --quiet --verify "$1")" if [ -n "$refhead" ] then shift diff --git a/bin/git-summary b/bin/git-summary index ddb72cd2d..7a05517e2 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -45,11 +45,10 @@ if [ -n "$MERGES_ARG" ] && [ -n "$SUMMARY_BY_LINE" ]; then exit 1 fi - +commit="HEAD" if [ -n "$SUMMARY_BY_LINE" ]; then paths=( "$@" ) else - commit="HEAD" [ $# -ne 0 ] && commit=$* fi project=${PWD##*/} @@ -57,18 +56,17 @@ project=${PWD##*/} # # get date for the given # -date() { +commit_date() { # the $1 can be empty # shellcheck disable=SC2086 - git log $MERGES_ARG --pretty='format: %ai' $1 | cut -d ' ' -f 2 + git log $MERGES_ARG --pretty='format: %ai' "$1" | cut -d ' ' -f 2 } # # get active days for the given # active_days() { - # shellcheck disable=SC2086 - date $1 | sort -r | uniq | awk ' + commit_date "$1" | sort -r | uniq | awk ' { sum += 1 } END { print sum } ' @@ -79,7 +77,7 @@ active_days() { # commit_count() { # shellcheck disable=SC2086 - git log $MERGES_ARG --oneline $commit | wc -l | tr -d ' ' + git log $MERGES_ARG --oneline "$commit" | wc -l | tr -d ' ' } # @@ -216,19 +214,17 @@ print_summary_by_line() { print_summary() { if [ "$OUTPUT_STYLE" == "tabular" ]; then tabular_headers="# Repo $SP Age $SP Last active $SP Active on $SP Commits $SP Uncommitted $SP Branch" - echo -e "$tabular_headers\n$project $SP $(repository_age) $SP $(last_active) $SP $(active_days $commit) days $SP $(commit_count $commit) $SP $(uncommitted_changes_count) $SP $(current_branch_name)" | column -t -s "$COLUMN_CMD_DELIMTER" + echo -e "$tabular_headers\n$project $SP $(repository_age) $SP $(last_active) $SP $(active_days "$commit") days $SP $(commit_count "$commit") $SP $(uncommitted_changes_count) $SP $(current_branch_name)" | column -t -s "$COLUMN_CMD_DELIMTER" elif [ "$OUTPUT_STYLE" == "oneline" ]; then - echo "$project / age: $(repository_age) / last active: $(last_active) / active on $(active_days $commit) days / commits: $(commit_count $commit) / uncommitted: $(uncommitted_changes_count) / branch: $(current_branch_name)" + echo "$project / age: $(repository_age) / last active: $(last_active) / active on $(active_days "$commit") days / commits: $(commit_count "$commit") / uncommitted: $(uncommitted_changes_count) / branch: $(current_branch_name)" else echo echo " project : $project" echo " repo age : $(repository_age)" echo " branch: : $(current_branch_name)" echo " last active : $(last_active)" - # shellcheck disable=SC2086 - echo " active on : $(active_days $commit) days" - # shellcheck disable=SC2086 - echo " commits : $(commit_count $commit)" + echo " active on : $(active_days "$commit") days" + echo " commits : $(commit_count "$commit")" # The file count doesn't support passing a git ref so ignore it if a ref is given if [ "$commit" == "HEAD" ]; then @@ -239,10 +235,10 @@ print_summary() { if [ -n "$DEDUP_BY_EMAIL" ]; then # the $commit can be empty # shellcheck disable=SC2086 - git shortlog $MERGES_ARG -n -s -e $commit | dedup_by_email | format_authors + git shortlog $MERGES_ARG -n -s -e "$commit" | dedup_by_email | format_authors else # shellcheck disable=SC2086 - git shortlog $MERGES_ARG -n -s $commit | format_authors + git shortlog $MERGES_ARG -n -s "$commit" | format_authors fi fi }