Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754589AbbHNBIW (ORCPT ); Thu, 13 Aug 2015 21:08:22 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34109 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752624AbbHNBIV (ORCPT ); Thu, 13 Aug 2015 21:08:21 -0400 From: Gregory Fong To: Michal Marek Cc: linux-kernel@vger.kernel.org, Gregory Fong Subject: [PATCH v2] scripts/setlocalversion: fix false positive -dirty tag from ctime Date: Thu, 13 Aug 2015 18:08:22 -0700 Message-Id: <1439514502-30291-1-git-send-email-gregory.0xf0@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2405 Lines: 61 git-diff-index cannot detect that a file hasn't actually changed when the file's ctime has changed (e.g. if chmod was used but didn't actually result in any changes), which was causing setlocalversion to incorrectly add a -dirty tag. Run git-update-index beforehand to make sure that the index is correct. Test prep: make defconfig && make prepare Before, starting from clean index: $ ls -l Kbuild -rw-rw-r-- 1 gregory gregory 2622 Aug 10 12:38 Kbuild $ chmod u+w Kbuild # intentional no-op that updates ctime $ CONFIG_LOCALVERSION_AUTO=y /bin/sh scripts/setlocalversion $PWD -00130-g7ddab73-dirty After, starting from clean index: $ ls -l Kbuild -rw-rw-r-- 1 gregory gregory 2622 Aug 10 12:38 Kbuild $ chmod u+w Kbuild # intentional no-op that updates ctime $ CONFIG_LOCALVERSION_AUTO=y /bin/sh scripts/setlocalversion $PWD -00131-gfa3477d Signed-off-by: Gregory Fong --- I sent this a few months ago[1] but didn't really include enough info about how to reproduce the problem. This is indeed probably a very unusual issue for someone to have, but sometimes people write braindead scripts that do things like update ctime for no reason, and it can be really hard to track down why the kernel build gets marked as '-dirty' when there aren't any modifications to the tree if you're not intimately familiar with the difference between git's plumbing and porcelain commands. [1] https://lkml.org/lkml/2015/3/10/793 scripts/setlocalversion | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 63d91e2..4ba52fc 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -45,6 +45,9 @@ scm_version() # Check for git and a git repo. if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + # In case ctime has changed but there are not actually any + # changes that would be committed. + git update-index -q --refresh # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/