From 0a7fed94371730d4e959e7975cbb0dc69484dcf4 Mon Sep 17 00:00:00 2001 From: Nigel Armstrong Date: Wed, 17 Apr 2019 00:33:13 -0700 Subject: [PATCH] Fix dirty flag Git diff-index doesn't rebuild index, so files with modified dates or touched are marked as modified with a SHA1 of all 0. To fix this, we run update-index --refresh before diff index. Any touched files are updated in the index. https://stackoverflow.com/questions/36367190/git-diff-files-output-changes-after-git-status --- selfdrive/version.py | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/version.py b/selfdrive/version.py index 0353f9845..d1e263aec 100644 --- a/selfdrive/version.py +++ b/selfdrive/version.py @@ -13,6 +13,7 @@ try: else: branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip() branch = 'origin/' + branch + subprocess.check_call(["git", "update-index", "--refresh"]) #This is needed otherwise touched files might show up as modified dirty = subprocess.call(["git", "diff-index", "--quiet", branch, "--"]) != 0 if dirty: dirty_files = subprocess.check_output(["git", "diff-index", branch, "--"])