newvers.sh: fix git false positive -dirty tag
Assuming that any output from `git diff-index --name-only` implies changes in the working tree results in false positives: files with metadata, but not content, changes are also listed. Check that content differences exist before adding the -dirty tag to the git hash. PR: 229230 Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D15968
This commit is contained in:
parent
97a7bf3070
commit
50b53a8dc3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340083
@ -76,6 +76,35 @@ findvcs()
|
||||
return 1
|
||||
}
|
||||
|
||||
git_tree_modified()
|
||||
{
|
||||
# git diff-index lists both files that are known to have changes as
|
||||
# well as those with metadata that does not match what is recorded in
|
||||
# git's internal state. The latter case is indicated by an all-zero
|
||||
# destination file hash.
|
||||
|
||||
local fifo vcstop_abs
|
||||
|
||||
fifo=$(mktemp -u)
|
||||
mkfifo -m 600 $fifo
|
||||
vcstop_abs=$(realpath $VCSTOP)
|
||||
$git_cmd --work-tree=${VCSTOP} diff-index HEAD > $fifo &
|
||||
while read smode dmode ssha dsha status file; do
|
||||
if ! expr $dsha : '^00*$' >/dev/null; then
|
||||
rm $fifo
|
||||
return 0
|
||||
fi
|
||||
if ! $git_cmd diff --quiet -- "${vcstop_abs}/${file}"; then
|
||||
rm $fifo
|
||||
return 0
|
||||
fi
|
||||
done < $fifo
|
||||
# No files with content differences.
|
||||
rm $fifo
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
if [ -z "${SYSDIR}" ]; then
|
||||
SYSDIR=$(dirname $0)/..
|
||||
fi
|
||||
@ -240,8 +269,7 @@ if [ -n "$git_cmd" ] ; then
|
||||
if [ -n "$git_b" ] ; then
|
||||
git="${git}(${git_b})"
|
||||
fi
|
||||
if $git_cmd --work-tree=${VCSTOP} diff-index \
|
||||
--name-only HEAD | read dummy; then
|
||||
if git_tree_modified; then
|
||||
git="${git}-dirty"
|
||||
modified=true
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user