Skip to content

Commit 3d84df4

Browse files
andyparkinsJunio C Hamano
authored andcommitted
Sample update hook: typofix and modernization to use "git log"
Instead of using antiquated "git-rev-parse | git-rev-list" pipeline, it is easier to use "git-rev-list" or "git-log" these days, as Linus points out. While we are at it, fix the typo on variable name $newref that should be $newrev. Signed-off-by: Andy Parkins <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8ab3e18 commit 3d84df4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

templates/hooks--update

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ case "$refname_type" in
148148
# This shows all log entries that are not already covered by
149149
# another ref - i.e. commits that are now accessible from this
150150
# ref that were previously not accessible
151-
git-rev-parse --not --all | git-rev-list --stdin --pretty $newref
151+
git log $newrev --not --all
152152
echo $LOGEND
153153
else
154154
# oldrev is valid
@@ -165,7 +165,7 @@ case "$refname_type" in
165165
baserev=$(git-merge-base $oldrev $newrev)
166166

167167
# Commit with a parent
168-
for rev in $(git-rev-parse --not --all | git-rev-list --stdin $newrev ^$baserev)
168+
for rev in $(git-rev-list $newrev --not $baserev --all)
169169
do
170170
revtype=$(git-cat-file -t "$rev")
171171
echo " via $rev ($revtype)"
@@ -190,12 +190,11 @@ case "$refname_type" in
190190
fi
191191
echo ""
192192
echo $LOGBEGIN
193-
git-rev-parse --not --all |
194-
git-rev-list --stdin --pretty $newrev ^$baserev
193+
git log $newrev --not $baserev --all
195194
echo $LOGEND
196195
echo ""
197196
echo "Diffstat:"
198-
git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev
197+
git-diff-tree --no-color --stat -M -C --find-copies-harder $baserev..$newrev
199198
fi
200199
;;
201200
"annotated tag")

0 commit comments

Comments
 (0)