Giter VIP home page Giter VIP logo

Comments (9)

ohaleck avatar ohaleck commented on June 3, 2024 1

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.

josh803316 avatar josh803316 commented on June 3, 2024

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.

lukeasrodgers avatar lukeasrodgers commented on June 3, 2024

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.

ohaleck avatar ohaleck commented on June 3, 2024

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.

chilicheech avatar chilicheech commented on June 3, 2024

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.

stale avatar stale commented on June 3, 2024

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.

jon-rtr avatar jon-rtr commented on June 3, 2024

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.

jon-rtr avatar jon-rtr commented on June 3, 2024

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.

tarcinil avatar tarcinil commented on June 3, 2024

@jon-rtr

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.