Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: project: fix git diff --exit-code logic #732

Merged
merged 1 commit into from
Sep 4, 2024

Commits on Sep 2, 2024

  1. app: project: fix git diff --exit-code logic

    Fixes 2020 commit a53ec10 ("west diff: only print output for
    projects with nonempty diffs")
    
    Fixes zephyrproject-rtos#731
    
    At least with git version 2.46.0, --exit-code is 0 when there has been a
    merge conflict! git bug or feature? Either way this causes west diff to
    wrongly assume there is no diff in that repo.
    
    Two other issues:
    1. if returncode is higher than 1 (= a git diff failure) AND -v is used,
       then failed.append(project) is never run.
    2. stderr is never, ever printed
    
    Try for instance `west diff --fubar` and `west -v --fubar` (which are
    possible since commit 73aee32). One fails and the other does
    not. Neither prints any useful error.
    
    The verbosity level should never have any side-effect.
    
    To fix:
    - Assume there is a diff when --exit-code is zero AND stdout is not
      empty. Treat this the same as --exit-code=1
    - Always `failed.append(project)` when --exit-code > 1
    - Print stderr when there is a diff or in verbose mode.
    
    This drops one `elif` which also simplifies the logic.
    
    Signed-off-by: Marc Herbert <marc.herbert@intel.com>
    marc-hb committed Sep 2, 2024
    Configuration menu
    Copy the full SHA
    b1a2a31 View commit details
    Browse the repository at this point in the history