-
Notifications
You must be signed in to change notification settings - Fork 126
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
Conversation
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Have not tested with git 2.46.0 but could it be that somehow the conflicting files has been staged ?
One thing I have observed is that if there are staged changes, then git diff --exit-code
will also return 0.
To check if there are staged changes, one must actually run git diff --cached --exit-code
.
Is not considering staged files perhaps another potential bug.
Thanks @tejlmand for taking a look!
Yes and I think that Works As Intended. In either case, the This
It's not too surprising that |
I know it wont, but the user can. Have you ever experienced someone committing code containing conflict markers 🙈 I actually tried to play a little, and can inform that same behavior is seen with git v2.34.1. |
as a side-note, |
Fixes 2020 commit a53ec10 ("west diff: only print output for projects with nonempty diffs")
Fixes #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:
Try for instance
west diff --fubar
andwest -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:
failed.append(project)
when --exit-code > 1This drops one
elif
which also simplifies the logic.