Received: from eggs.gnu.org ([2001:4830:134:3::10]:46926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b81wG-0003Je-57 for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b81wC-0007mc-0d for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:55:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b81wB-0007mP-OW for qemu-devel@nongnu.org; Wed, 01 Jun 2016 04:55:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38A636330D for ; Wed, 1 Jun 2016 08:55:39 +0000 (UTC) References: <1464707044-10447-1-git-send-email-lersek@redhat.com> <20160531151418.GZ21628@redhat.com> <20160531154346.GB21628@redhat.com> <8d55914d-e57c-43e3-5319-28db331de5f8@redhat.com> <574DCDB5.5000208@redhat.com> From: Laszlo Ersek Message-ID: Date: Wed, 1 Jun 2016 10:55:36 +0200 MIME-Version: 1.0 In-Reply-To: <574DCDB5.5000208@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] configure: save git working tree information in "pkgversion" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Fam Zheng 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 > > 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 > BTW, my patch has a functionality bug. Consider the case when you change some of the tracked files, then stage all those changes with "git add", then *undo* the changes in the working tree only. In this case, my patch will report "dirty" ("+"), because there will be both staged changes (relative to the HEAD commit) and working tree changes (relative to the index). But that's incorrect -- the working tree actually matches the HEAD commit, so the build qualifies as "clean". On the other hand, git-diff-index will do the right thing, namely: git-diff-index compares the and the files on the filesystem. which is exactly right. The index (= the staged changes) are irrelevant for a build; only the working tree matters. (Anyway, this is moot now; I'll happily leave it to Fam! :)) Thanks Laszlo