git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Wrong -dirty suffix set by setlocalversion (was: BUG in git diff-index)

From
MHMarc Herbert <marc.herbert@intel.com>
Date
May 25, 2018, 03:50 UTC
Message-ID
<0dc31052-4cfd-3b92-0a4a-96c8ecfafff6@intel.com>
In-Reply-To
<20180524230334.12452-1-michael.w.mason@intel.com>
On 24/05/2018 16:03, Mike Mason wrote:
Show 16 quoted lines
> diff --git a/scripts/setlocalversion b/scripts/setlocalversion
> index 71f39410691b..9da4c5e83285 100755
> --- a/scripts/setlocalversion
> +++ b/scripts/setlocalversion
> @@ -73,8 +73,10 @@ scm_version()
>  			printf -- '-svn%s' "`git svn find-rev $head`"
>  		fi
>  
> -		# Check for uncommitted changes
> -		if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
> +		# Check for uncommitted changes. Only check mtime and size.
> +       # Ignore insequential ctime, uid, gid and inode differences.
> +		if git -c "core.checkstat=minimal" diff-index --name-only HEAD | \
> +				grep -qv "^scripts/package"; then
>  			printf '%s' -dirty
>  		fi
FWIW:
Reported-by: Marc.Herbert@intel.com
Reviewed-by: Marc.Herbert@intel.com  (assuming a future and decent commit message)
Tested-by: Marc.Herbert@intel.com

So the real use case is making a copy of a whole tree before building. Typical in automated builds, old example: https://groups.google.com/a/chromium.org/d/msg/chromium-os-dev/zxOa0OLWFkw/N_Sb7EZOBwAJ

Here's a more complex but faster and more transparent way to test Mike's fix than copying an entire tree:

# Make sure you start from a clean state git describe --dirty # must not -dirty

make prepare

# Simulate a copy of the tree but with just one file rsync --perms --times README README.mtime_backup rm README rsync --perms --times README.mtime_backup README stat README README.mtime_backup

# Demo the BUG fixed by Mike ./scripts/setlocalversion # -dirty BUG! because spurious inode ctime difference git diff-index HEAD git describe --dirty # not -dirty ./scripts/setlocalversion # not -dirty any more cause describe refreshed index

# Make sure mtime still causes -dirty with AND without Mike's fix touch README ./scripts/setlocalversion # -dirty

Previous: Mike Mason
Message 13 of 13 in “BUG in git diff-index”
  1. Andy LowryMar 31, 2016
  2. Carlos Martín NietoMar 31, 2016
  3. Jeff KingMar 31, 2016
  4. Andy LowryMar 31, 2016
  5. Jeff KingMar 31, 2016
  6. Andy LowryMar 31, 2016
  7. Junio C HamanoMar 31, 2016
  8. Marc HerbertSep 26, 2017
  9. Eric WongSep 26, 2017
  10. Google indexing https://public-inbox.org/git (was: BUG in git diff-index)Marc Herbert, Sep 26, 2017
  11. Wrong -dirty suffix set by setlocalversion (was: BUG in git diff-index)Marc Herbert, Sep 27, 2017
  12. Mike MasonMay 24, 2018
  13. Marc HerbertMay 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.