Bug 252028 - sys/conf/newvers.sh: git "-dirty" even when clean
Summary: sys/conf/newvers.sh: git "-dirty" even when clean
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-21 19:27 UTC by John Kennedy
Modified: 2022-09-06 19:09 UTC (History)
3 users (show)

See Also:


Attachments
git_tree_modiied inversion check patch (391 bytes, patch)
2020-12-21 19:27 UTC, John Kennedy
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Kennedy 2020-12-21 19:27:52 UTC
Created attachment 220789 [details]
git_tree_modiied inversion check patch

I've made a tiny shell script to demonstrate the problem, but it looks like the dirty/clean logic is inverted.

#!/bin/sh -

git_tree_modified()
{
        git -c core.checkStat=minimal -c core.fileMode=off diff --quiet
        if [ $? -eq 0 ]; then
                 return 1;
        else
                 return 0;
        fi
}

export git=foo

if git_tree_modified; then
        git="${git}-dirty"
fi

echo $git
Comment 1 Ed Maste freebsd_committer freebsd_triage 2020-12-22 01:58:14 UTC
Smaller change:

diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index f5e34b4946a5..5ce93567e3af 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -162,7 +162,7 @@ findvcs()
 
 git_tree_modified()
 {
-       $git_cmd "--work-tree=${VCSTOP}" -c core.checkStat=minimal -c core.fileMode=off diff --quiet
+       ! $git_cmd "--work-tree=${VCSTOP}" -c core.checkStat=minimal -c core.fileMode=off diff --quiet
 }

I'll commit this once the git repo is opened for commits
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-12-23 04:32:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=17eba5e32a2cf7a217bb9f1e5dcca351f2b71cfc

commit 17eba5e32a2cf7a217bb9f1e5dcca351f2b71cfc
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2020-12-23 04:31:15 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2020-12-23 04:31:15 +0000

    newvers.sh: fix sense of git dirty check

    Previously we reported -dirty for an unmodified tree, and no -dirty if
    there were changes.

    PR:             252028
    Reported by:    John Kennedy

 sys/conf/newvers.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-09-06 19:09:25 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=50a6ae40759607424052ca70ad0bf246c3ed6087

commit 50a6ae40759607424052ca70ad0bf246c3ed6087
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2020-12-17 00:00:21 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-09-06 17:25:49 +0000

    newvers.sh: Speed up git_tree_modified

    We're looking for file content differences, so ask the question of git
    more directly. This helps a lot, saving tens of thousands of fork()s,
    when the builder and editor see different stat() results (e.g., UIDs),
    as they might with containers.

    Submitted by:   Nathaniel Wesley Filardo <nwf20@cl.cam.ac.uk>
    Reviewed by:    bdrewery, emaste, imp
    Obtained from:  CheriBSD
    MFC after:      3 days
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D27646

    PR:             252028

    (cherry picked from commit 17eba5e32a2cf7a217bb9f1e5dcca351f2b71cfc)

 sys/conf/newvers.sh | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)