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