Bug 90936

Summary: git-version-gen marks tarballs as dirty if build inside a dirty git clone
Product: PulseAudio Reporter: Ross Burton <ross>
Component: build-systemAssignee: pulseaudio-bugs
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Prototype patch

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)

	pulseaudio-6.0/

$ cd pulseaudio-6.0/
$ ./git-version-gen .tarball-version
6.0-dirty
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!

http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=c25b06577c2cc251c541732f245117c913206916

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.