image-buildinfo: treat staged changes as modified branch, too

When staging changes in a layer using git add, image-buildinfo
doesn't detect this as a modification, because of the way it
uses git diff.

Surely, merely staging, but not committing changes to git
should not result in image-buildhistory assuming that the
git repository hasn't been modified compared to the branch
HEAD, this state should be treated similarly to modifications
being unstaged.

We have to use both, git diff and git diff --cached to get the
desired result.

(From OE-Core rev: b46906889665f6ab72bccee608276646cda50140)

Signed-off-by: André Draszik <adraszik@tycoint.com>
Reported-by: Lukasz Nowak <lnowak@tycoint.com>
Reviewed-by: Lukasz Nowak <lnowak@tycoint.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
André Draszik 2016-11-04 10:53:33 +00:00 committed by Richard Purdie
parent 4e6c5d8769
commit ba011f588b
1 changed files with 3 additions and 1 deletions

View File

@ -28,7 +28,9 @@ def image_buildinfo_outputvars(vars, listvars, d):
def get_layer_git_status(path):
import subprocess
try:
subprocess.check_output("cd %s; PSEUDO_UNLOAD=1 git diff --quiet --no-ext-diff" % path,
subprocess.check_output("""cd %s; export PSEUDO_UNLOAD=1; set -e;
git diff --quiet --no-ext-diff
git diff --quiet --no-ext-diff --cached""" % path,
shell=True,
stderr=subprocess.STDOUT)
return ""