Skip to content

add --chmod --dry-run should reject symlink index entries #489

Description

@genedna

Summary

libra add --chmod=+x --dry-run <symlink> exits 0 and silently treats the invalid chmod as a successful no-op. Git rejects applying an executable bit to a non-regular index entry, exits non-zero, and reports the affected path.

This is tracked by libra-testcases as TC-0008, based on upstream Git t/t3700-add.sh test 52 (git add --chmod --dry-run reports error for non regular files).

Versions

  • Libra: 0.22.19
  • Git control: 2.55.0.782.g1630431f32
  • Platform: macOS/Darwin, case-insensitive APFS
  • Upstream source: Git commit 1630431f326e15fcde608827b5ff38422528eb59, t/t3700-add.sh lines 508-513

Reproduction

set -eu

work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT

"$LIBRA" init -q --initial-branch=main "$work/repo"
cd "$work/repo"

printf 'target\n' >foo
ln -s foo foo4
"$LIBRA" update-index --add foo4

"$LIBRA" ls-files --stage -- foo4
"$LIBRA" add --chmod=+x --dry-run foo4 >out 2>err
rc=$?
printf 'exit=%s\n' "$rc"
cat out
cat err
"$LIBRA" ls-files --stage -- foo4

The setup creates a symlink entry with index mode 120000.

Actual behavior

$ libra ls-files --stage -- foo4
120000 19102815663d23f8b75a47e7a01965dcdc96468c 0 foo4

$ libra add --chmod=+x --dry-run foo4
(dry run, no files were staged)
exit=0

stderr is empty. The index correctly remains unchanged at mode 120000, but the invalid operation is reported as successful.

Expected behavior

Git produces:

$ git add --chmod=+x --dry-run foo4
error: cannot chmod +x 'foo4'
exit=255

The index remains unchanged at mode 120000.

The exact numeric error code and prose do not need to be identical, but Libra should:

  1. Exit with a regular non-zero status, not 0 or a timeout/signal status.
  2. Identify foo4 and explain that +x/chmod cannot be applied to the non-regular entry.
  3. Leave the index mode and object ID unchanged.
  4. Continue to allow product-specific Error-Code, Hint, JSON, or other explanatory output.

Rationale

--dry-run suppresses index writes; it should not suppress validation. An index symlink uses mode 120000 and has no regular-file executable bit to change. Treating this as a successful no-op can make preflight checks accept an invalid operation.

Test tracking

  • cases/tc0008-add-chmod-dry-run-nonregular/tc0008-add-chmod-dry-run-nonregular.sh
  • libra-git-testcases-spec.md TC-0008
  • results/libra-0.22.19/notes.md TC-0008
  • libra-git-testcases-review.md TC-0008

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtestvcs

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions