]> granicus.if.org Git - git/commitdiff
hook: name the positional variables
authorKaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Tue, 11 Jul 2017 14:11:09 +0000 (19:41 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Jul 2017 20:20:42 +0000 (13:20 -0700)
It's always nice to have named variables instead of
positional variables as they communicate their purpose
well.

Appropriately name the positional variables of the hook
to make it easier to see what's going on.

Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
templates/hooks--prepare-commit-msg.sample

index 279ddc1a723c7eb0915025358748f73fe0184a14..eb59121637d8ffed2430fbaec23c3cd244d03a2b 100755 (executable)
 # The second example adds a Signed-off-by line to the message, that can
 # still be edited.  This is rarely a good idea.
 
+COMMIT_MSG_FILE=$1
+COMMIT_SOURCE=$2
+SHA1=$3
 
-# case "$2,$3" in
+# case "$COMMIT_SOURCE,$SHA1" in
 #  ,|template,)
 #    @PERL_PATH@ -i.bak -pe '
 #       print "\n" . `git diff --cached --name-status -r`
-#       if /^#/ && $first++ == 0' "$1" ;;
+#       if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
 #  *) ;;
 # esac
 
 # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
-# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
+# grep -qs "^$SOB" "$COMMIT_MSG_FILE" || echo "$SOB" >> "$COMMIT_MSG_FILE"