On 05/31/16 19:45, Eric Blake wrote: > On 05/31/2016 11:01 AM, Laszlo Ersek wrote: > >>>> Grepping git's Documentation/RelNotes/ directory, I find: >>>> - in "1.6.6.txt": the introduction of --dirty >>>> - in "1.7.6.4.txt": an apparently important bugfix for --dirty
(*) >>>> >>>> Version 1.7.6.4 of git was tagged on Sep 23 2011. >>>> >>>> Does this information help in deciding if we can use --dirty? >>> >>> 5 years old sounds new enough for my liking :-) >>> >>> I guess we could use --dirty and catch the non-zero exit code and just >>> re-try without --dirty. >> >> But, if we can't use --dirty, I should probably use the plus-sign >> fallback (we need *something* to mark a dirty state). >> >> In which case however, shouldn't we just go with the current patch, >> which doesn't care about --dirty at all? Otherwise, some build hosts >> will append "-dirty", and others will append "+". >> >> IMO we should either require --dirty, or go with the current patch. > > Gnulib's build-aux/git-version-gen script doesn't yet use --dirty, but > may be an inspiration for how to generate the same suffix: > > # Test whether to append the "-dirty" suffix only if the version > # string we're using came from git. I.e., skip the test if it's "UNKNOWN" > # or if it came from .tarball-version. > if test "x$v_from_git" != x; then > # Don't declare a version "dirty" merely because a time stamp has changed. > git update-index --refresh > /dev/null 2>&1 ( This is exactly the fix (*) that went into git v1.7.6.4 (and v1.7.7): $ git log --oneline --reverse v1.7.6.3..v1.7.6.4 0f64bfa9567f ls-files: fix pathspec display on error e9d4f7405b6a branch.c: use the parsed branch name 13d6ec913330 read_gitfile_gently(): rename misnamed function to read_gitfile() 9b0ebc722cfc clone: allow to clone from .git file dbc92b072dd7 clone: allow more than one --reference e6baf4a1ae1b clone: clone from a repository with relative alternates 2f633f41d695 check-ref-format --print: Normalize refnames that start with slashes f3738c1ce919 Forbid DEL characters in reference names 385ceec1cb46 t3005: do not assume a particular order of stdout and stderr of git-ls-files dff4b0ef30cd am: format is in $patch_format, not parse_patch e622f41dcd97 git-mergetool: check return value from read 40ffc4987661 Merge branch 'gb/maint-am-patch-format-error-message' into maint 503359f13abc Merge branch 'mg/branch-set-upstream-previous' into maint be5acb3b63af Merge branch 'mh/check-ref-format-print-normalize' into maint 406c1c4dd4a8 Merge branch 'nd/maint-clone-gitdir' into maint 84b051462fca Merge branch 'jc/maint-clone-alternates' into maint 85b3c75f4fd3 describe: Refresh the index when run with --dirty a0b1cb60ab29 Merge branch 'cb/maint-ls-files-error-report' into maint 632052641517 Git 1.7.6.4 --> https://github.com/git/git/commit/85b3c75f4fd3 "describe: Refresh the index when run with --dirty" ) > > dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty= > case "$dirty" in > '') ;; > *) # Append the suffix only if there isn't one already. > case $v in > *-dirty) ;; > *) v="$v-dirty" ;; > esac ;; > esac > fi This seems to do the right thing, yes. I'll submit a new version later. Thanks! Laszlo