Comments (9)
ruby-git status
behind the scenes calls git diff-files
instead of actual git status
. git diff-files
shows all changes made to files (including mode and modification date changes), but only until git diff
is called once. So strange...
Finally, I ended up with:
@g.status.changed.each do
@g.diff.entries
end
This is similar to the solution proposed by @josh803316 , yet just calling diff.entries
once for each element of g.status.changed
enumeration is sufficient to sanitize the contents of @g.status.changed
and once it's done, g.status.changed
can enumerated again, this time with correct result.
I'm sorry, but I have no idea, why it is so.
ruby-git version is 1.2.8
ruby binary version is 2.1.2p95
from ruby-git.
I was able to circumvent the problem by doing this, in case anyone else has run into the same issue
@git.status.changed.each do |file|
if file[0] =~ /#{intersection}/
result = @git.diff('HEAD',"#{dir}/")
has_changes = true unless result.entries.length < 1
end
end
from ruby-git.
I'm having this issue as well.
EDIT
Curiously, shelling out to git status
from ruby before, e.g. @git.status
seems to result in the latter reporting status accurately.
from ruby-git.
I found out that after touching a file (updating its modification date) Git needs to be reopened again. Here is the experiment I made in irb:
2.1.2 :001 > require 'git'
=> true
2.1.2 :002 > g=Git.open('.')
=> #<Git::Base:0x007fe5931d4608 ...>
2.1.2 :003 > g.status.changed.size
=> 0
2.1.2 :004 > g.diff('HEAD').size
=> 0
2.1.2 :005 > system "touch example.txt"
=> true
2.1.2 :006 > g.status.changed.size
=> 1
2.1.2 :007 > g.diff('HEAD').size
=> 0
2.1.2 :008 > g=Git.open('.')
=> #<Git::Base:0x007fe5938101c0 ...>
2.1.2 :009 > g.status.changed.size
=> 0
2.1.2 :010 > g.diff('HEAD').size
=> 0
from ruby-git.
This is affecting me as well. Why can't ruby-git status
call git status
instead of git diff-files
? This implementation is confusing because it differs from git
's implementation.
from ruby-git.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from ruby-git.
I'm running into the same behavior as listed above, so I would say this issue should be reopened.
I'm having this issue as well.
EDIT
Curiously, shelling out to git status from ruby before, e.g. @git.status seems to result in the latter reporting status accurately.
I'm using ruby-git 1.5.0
and git version 2.15.2 (Apple Git-101.1)
.
from ruby-git.
Running git diff-files on one of my repos, all of the files look like this:
$ git diff-files | head -n2
:100644 100644 51e14f30f818cde956880833f3c9a5822b54ad03 0000000000000000000000000000000000000000 M .gitignore
:100644 100644 93deb154ae39ea2ae76c9a70ddf51be9dcbd8f4a 0000000000000000000000000000000000000000 M README.md
from ruby-git.
Thank you for your report. As the issue is now seven years old and we can't be sure how the issue has changed over the many years. Please create a new issue witt all relevant data.
from ruby-git.
Related Issues (20)
- Command injection vulnerability in Git::Lib#fetch HOT 1
- Diff parsing fails with opaque error when SSH warnings preceed the standard header HOT 3
- Can't use diff with multiple paths
- `Status#changed?` is case-sensitive despite git config
- Failing test due to hardcoded `refs/heads/master` in tests/units/test_init.rb@test_git_init HOT 1
- Open git repository from child directory of git repository
- Git::Branch function update_ref doesn't work as expected
- Git::Branch private function parse_name doesn't work as documented
- failure using git built from source HOT 3
- Clarify how to use push with previously cloned repo HOT 1
- Test ticket from Code Climate
- Does this lib support git submodule operation? HOT 4
- Can't use `Git::Lib#remove` with `recursive` or `cached` options
- Checking out branches containing slashes broken since `1.15.0`? HOT 5
- 1.17.0 broke compatibility with ruby <2.7 HOT 5
- Redesign using `git config` with this gem
- Implement a way to mark a public API as deprecated HOT 1
- `cmd can not include a nested array` in 1.14.0 or higher HOT 1
- `remote.origin.fetch` is limited to the default branch HOT 1
- worktree.add corrupts repository index HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-git.