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

DiffParser: ignore chmod change #49

Open
Luolc opened this issue Jul 6, 2017 · 1 comment
Open

DiffParser: ignore chmod change #49

Luolc opened this issue Jul 6, 2017 · 1 comment
Assignees

Comments

@Luolc
Copy link
Collaborator

Luolc commented Jul 6, 2017

Taken from #22 (comment)

If the only change is a chmod(no changes to the contents of the file), we should ignore the change altogether.

After this if fixed, the UT of only chmod change in #22 should update.

We will need a new test for this: chmod plus file change.

@Luolc
Copy link
Collaborator Author

Luolc commented Jul 6, 2017

Some experiment:

$ git init
$ echo hello > HelloWorld
$ git add .
$ git commit -m "initial commit"
[master (root-commit) 83e0652] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 HelloWorld
$
$ git checkout -b foo
Switched to a new branch 'foo'
$ chmod 755 HelloWorld
$ git status
On branch foo
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   HelloWorld

no changes added to commit (use "git add" and/or "git commit -a")
$ git add .
$ git commit -m "change filemode"
[foo f3c937d] change filemode
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 HelloWorld
$
$ git diff master
diff --git a/HelloWorld b/HelloWorld
old mode 100644
new mode 100755
$ git config core.filemode false
$ git diff master
diff --git a/HelloWorld b/HelloWorld
old mode 100644
new mode 100755
$
$ chmod 644 HelloWorld
$ git status
On branch foo
nothing to commit, working tree clean

So we can't ignore filemode change after a mode change is already committed. core.filemode could only works for detecting new changes, but not for showing existed diff. The only way I could find now is checking this by the size of "edit lines". If the size is zero, then this is only a filemode change.

IMO, we'd better work on this after we introducing line changes in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants