Differentiate between Modified files and Unstaged changes #142

Closed
miketheman opened this Issue Sep 17, 2012 · 2 comments

Projects

None yet

2 participants

@miketheman

I poked around a lot for this, and couldn't find it.

Does Grit already have a method for inspecting a repo's Status for 'Changed and Staged' vs 'Changed and Unstaged'?

From testing some scenarios, it looks like that when a file is 'Changed and Staged', both the sha_repo and sha_index have git hashes.

It looks like if a file is 'Changed and Unstaged', the sha_index is a string of 40 0's - like so: "0000000000000000000000000000000000000000"

It would have been great to find a method in Status to help differentiate these.

Unless I'm missing something?

@miketheman

Oh, and here's a little loop over a Status to demonstrate:

gitrepo = Grit::Repo.new(@repo_root)
status = gitrepo.status
status.changed.each do |file|
  puts file[1].sha_index  
end

# => e3fe9b0197b5e06b3deee41ac99dcd9470044769
# => 0000000000000000000000000000000000000000
@bkeepers
Collaborator

Grit is no longer maintained. See #183 and check out libgit2/rugged.

@bkeepers bkeepers closed this Feb 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment