Bug 90936 - git-version-gen marks tarballs as dirty if build inside a dirty git clone
Summary: git-version-gen marks tarballs as dirty if build inside a dirty git clone
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: build-system (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
Depends on:
Reported: 2015-06-11 15:22 UTC by Ross Burton
Modified: 2015-10-22 12:27 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Prototype patch (356 bytes, patch)
2015-06-11 15:25 UTC, Ross Burton
Details | Splinter Review

Description Ross Burton 2015-06-11 15:22:46 UTC
Say I have a distro build system in git, which builds packages in a working directory in the git checkout:

~/mydistro/builds/pulseaudio-6.0/[tarball contents]

git-version-gen will read the version from .tarball-version and then try running git diff-index, at which point git will iterate up until it finds ~/mydistro/.git/ and report that the repo is dirty, resulting in a build of Pulseaudio that thinks its version 6.0-dirty.  Obviously, this isn't right.
Comment 1 Ross Burton 2015-06-11 15:25:25 UTC
Created attachment 116439 [details] [review]
Prototype patch

Prototype patch for review/comment.
Comment 2 David Henningsson 2015-10-16 14:48:12 UTC
Sorry, I don't follow.

If you have tarball contents, and you run "./git-version-gen ./.tarball-version" you'll get "6.0", not "6.0-dirty" regardless of you have a .git directory higher up in the path.

I tried to reproduce, like this:

   mkdir mydistro
   cd mydistro
   git init
   wget <URL>
   tar -xf <FILE>
   cd pulseaudio-7.0
   ./git-version-gen ./.tarball-version

and it reported back "7.0", not "7.0-dirty".

Could you clarify?
Comment 3 Ross Burton 2015-10-16 15:15:14 UTC
You need pending modifications in the containing git tree (so git thinks there are changes to commit, thus being dirty).  In your test case after git init something like this will replicate:

touch foo
git add foo ; git commit foo
echo foo >foo
Comment 4 Ross Burton 2015-10-16 15:16:07 UTC
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   foo

Untracked files:
  (use "git add <file>..." to include in what will be committed)


$ cd pulseaudio-6.0/
$ ./git-version-gen .tarball-version
Comment 5 David Henningsson 2015-10-19 11:45:08 UTC
Ok, now I can reproduce it, thanks.

Your patch looks good enough to me (except that it is a "git diff" rather than "git format-patch"), but you wrote it as being a "prototype". 
Is there anything that you'd like to change in it before I commit it? If so, feel free to upload a new one.
Comment 6 Ross Burton 2015-10-19 12:01:11 UTC
There wasn't anything I wanted to change, so feel free to commit it as-is.
Comment 7 David Henningsson 2015-10-22 12:27:35 UTC
Pushed now, thanks for the contribution!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.