forked from RsyncProject/rsync
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkgitver
More file actions
executable file
·32 lines (29 loc) · 1.43 KB
/
Copy pathmkgitver
File metadata and controls
executable file
·32 lines (29 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
srcdir=`dirname $0`
if [ ! -f git-version.h ]; then
touch git-version.h
fi
if test -d "$srcdir/.git" || test -f "$srcdir/.git"; then
# Identify a git build by the development version from version.h plus the
# exact commit (e.g. "3.5.0dev-g1234abcd"), rather than the nearest release
# tag that `git describe` would pick: that tag can sit far behind a rebased
# development branch and then misnames the line you are actually on (showing,
# say, 3.4.3 for a 3.5.0dev tree). This also works in a shallow/tag-less
# clone. A release tarball has no .git, so git-version.h stays empty and
# rsync prints the plain RSYNC_VERSION.
# cd into the subshell rather than "git -C" (avoids needing a newer git).
gitsha=`(cd "$srcdir" && git rev-parse --short=8 HEAD) 2>/dev/null`
# Tolerate any preprocessor spacing and a trailing comment; capture only the
# quoted value. Empty (define missing/unmatched) -> leave RSYNC_GITVER unset.
rsyncver=`sed -n 's/^[[:space:]]*#[[:space:]]*define[[:space:]][[:space:]]*RSYNC_VERSION[[:space:]][[:space:]]*"\([^"]*\)".*/\1/p' "$srcdir/version.h"`
if [ -n "$gitsha" ] && [ -n "$rsyncver" ]; then
gitver="$rsyncver-g$gitsha"
echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h.new
if ! diff git-version.h.new git-version.h >/dev/null; then
echo "Updating git-version.h"
mv git-version.h.new git-version.h
else
rm git-version.h.new
fi
fi
fi