Skip to content

Commit c47e6a4

Browse files
andyparkinsJunio C Hamano
authored andcommitted
update-hook: fix incorrect use of git-describe and sed for finding previous tag
Previously git-describe would output lines of the form v1.1.1-gf509d56 The update hook found the dash and stripped it off using sed 's/-g.*//' The remainder was then used as the previous tag name. However, git-describe has changed format. The output is now of the form v1.1.1-23-gf509d56 The above sed fragment doesn't strip the middle "-23", and so the previous tag name used would be "v1.1.1-23". This is incorrect. Since the hook script was written, git-describe now gained support for "--abbrev=0", which it uses as a special flag to tell it not to output anything other than the nearest tag name. This patch fixes the problem, and prevents any future recurrence by using this new flag rather than sed to find the previous tag. Signed-off-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent c49b260 commit c47e6a4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/hooks--update

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ case "$refname_type" in
210210
fi
211211

212212
# If this tag succeeds another, then show which tag it replaces
213-
prevtag=$(git describe $newrev^ 2>/dev/null | sed 's/-g.*//')
213+
prevtag=$(git describe --abbrev=0 $newrev^ 2>/dev/null)
214214
if [ -n "$prevtag" ]; then
215215
echo " replaces $prevtag"
216216
fi

0 commit comments

Comments
 (0)