Skip to content

hack/validate-git-marks.sh does not detect conflict markers #2953

Description

@ROKUMATE

make validate-local runs this script on every PR to catch leftover merge conflict markers.
It never catches any.

Line 9 tests grep's output instead of its exit status:

if [ $(grep -r "^\(<<<<<<<\|>>>>>>>\|^=======$\)" $f) ]; then

Git writes markers with a label (<<<<<<< HEAD), so the unquoted substitution hands [ two
or more arguments. [ fails with "too many arguments" and exits non-zero, so the if is
false and the file is never flagged.

Reproduce:

T=$(mktemp -d); cd "$T"; git init -q .; git config user.email t@t; git config user.name t
printf 'a\n<<<<<<< HEAD\nmine\n=======\ntheirs\n>>>>>>> feature\n' > conflicted.go
git add -A; git commit -qm t
bash /path/to/skopeo/hack/validate-git-marks.sh; echo "rc=$?"

Got:

validate-git-marks.sh: line 9: [: too many arguments
Congratulations!  There is no conflict.
rc=0

Expected: names conflicted.go, exits 1.

Not macOS-specific — the failure is in bash's [, not grep.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA defect in an existing functionality (or a PR fixing it)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions