Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

fix 'git add' on executable files #1272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix 'git add' on executable files #1272

wants to merge 1 commit into from

Conversation

greenfoo
Copy link

@greenfoo greenfoo commented Jan 3, 2020

Before this change, when adding an "executable" file with worktree.Add(), something really strange happened: the git index file entry associated with that file had its SHA1 updated but not its size; which caused the file to appear both as "staged" and "unstaged" when running git status:

$ git status
On branch xxx
Your branch is ahead of 'origin/r54+x' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   ci/integrity_checks.py <-------------------------- HERE

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   ci/integrity_checks.py <-------------------------- AND HERE

However, when running git diff, nothing shows up (ie. the fact that this file appears as unstaged is just an artifact of the file length not matching the one registered on the index)

I guess (but I could be wrong) that the original intent of the line I changed was to avoid updating the size when dealing with a folder or a pipe or something like that... but for some reason, IsRegular() was used instead of IsFile().

If there is some hidden reason to use IsRegular() that I'm not aware of, please simply discard this pull request.

Signed-off-by: Fernando Ramos <greenfoo@gluegarage.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant