title: Proper way to stage files, and commit
body: <p>When I try to do the following, i simply end up generating empty commits; that is, it creates a commit with nothing changed in it.</p>
  
  <pre><code>string filename = "path/to/file";
  repo.Index.Stage(filename);
  repo.Commit();
  </code></pre>
  
  <p>please note that the path is relative, meaning, i create my <code>Repository</code> using <code>Repository repo = new Repository(".");</code> and then use paths (called filename above) like <code> ".gitignore"</code> or <code>"files/text.txt"</code> which seems to be the correct way to do it, but it doesn't work. </p>
  
  <p>The code that demonstrates this "in action" can be found in full <a href="https://github.com/b3ngr33ni3r/unityGit/blob/master/Assets/editor/GitTool" rel="nofollow noreferrer">here</a> but is essentially ran though like this:</p>
  
  <pre><code>int count = 0;
  //iterate all entries in the index (correct me if i'm wrong, but this should be all the changed files? or is it just all the files..)
  //this is in AddWindow.cs
  foreach (LibGit2Sharp.IndexEntry entry in vcs.GetRepository().Index)
          {
              //store an the entry.Path as Representation in an Object FileToggle
              toggles[count] = new FileToggle(entry.Path);
              count++;
          }
  
  //then later, we do this (also in AddWindow.cs)
  foreach (FileToggle f in toggles)
          {
              if (f.GetToggle()) //this is a bool set by user, so lets assume its on
                  vcs.GetRepository().Index.Stage(f.GetRepresenation()); //stage all selected files, using their representation (ie entry.Path set above)
          } 
  
  //and then finally, later, we do this in CommitWindow.cs
     if (message != null &amp;&amp; signature != null &amp;&amp; email != null)
                      vcs.GetRepository().Commit(message, new LibGit2Sharp.Signature(signature, email, System.DateTimeOffset.Now), new LibGit2Sharp.Signature(signature, email, System.DateTimeOffset.Now));
  </code></pre>
  
  <p>it's also important to note that <code>vcs.GetRepository()</code> returns a <code>Repository</code><br>
  you can also see some examples of blank commits, as i used the tool to try
  to commit itself. check out one <a href="https://github.com/b3ngr33ni3r/unityGit/commit/2491d5e0c4a0a63072b47b1cdeb7235af0c7d33c" rel="nofollow noreferrer">here</a>. </p>
  
  <p>Furthermore, I have verified that I'm attempting to stage and then commit files that are marked as modified in the command line, using <code>git status</code>. So, I am not just attempting to commit files that are not modified, nor am i commiting files that are already staged. I am (as far as i know) trying to do this <code>.Stage() .Commit()</code> process for files that ARE in need of update. </p>
  
  <p><strong>Update</strong></p>
  
  <p>as per nulltoken's requests:</p>
  
  <blockquote>
    <p>Add Console.WriteLine(string.Format("{0} - {1}", f.GetRepresenation(), vcs.GetRepository().Index.RetrieveStatus(f.GetRepresenation()))) before the line invoking Index.Stage().</p>
  </blockquote>
  
  <p>the resulting output when staging my "test" files is </p>
  
  <pre><code>Assets\editor\GitTool\AddWindow.cs - Modified
  Assets\editor\GitTool\CommitWindow.cs - Modified
  </code></pre>
  
  <blockquote>
    <p>Add a breakpoint on the line performing the call to repo.Commit
    Run the code. When you hit the breakpoint, please run git status against the repository pointed at by vcs.GetRepository()</p>
  </blockquote>
  
  <p>this yields the output of git status indicating </p>
  
  <pre><code># Changes not staged for commit:
  #   (use "git add/rm &lt;file&gt;..." to update what will be committed)
  #   (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
  #
  #       modified:   Assets/editor/GitTool/AddWindow.cs
  #       modified:   Assets/editor/GitTool/CommitWindow.cs
  </code></pre>
  
  <p>both before and after letting <code>Commit()</code> execute. Although after, it does contain</p>
  
  <p><code># Your branch is ahead of 'origin/master' by 1 commit.</code> as well.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>This behaves as expected, producing the following output after staging:</p>
  
  <pre><code># Changes to be committed:
  #   (use "git reset HEAD &lt;file&gt;..." to unstage)
  #
  #       modified:   Assets/editor/GitTool/AddWindow.cs
  </code></pre>
  
  <p>then i call Commit immediately, and i get:</p>
  
  <pre><code># Your branch is ahead of 'origin/master' by 2 commits.
  #
  # Changes not staged for commit:
  #   (use "git add/rm &lt;file&gt;..." to update what will be committed)
  #   (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
  #
  #       modified:   Assets/editor/GitTool/AddWindow.cs
  </code></pre>
  
  <p>so, the ahead by count incremented up once, indicating there was a commit, but the file is still being reported as newly changed, even though to the best of my knowledge it isn't! </p>
  
  <p><strong>update 3</strong></p>
  
  <p>i just noticed something upon running <code>git diff</code>. the differences being picked up there are file mode changes (ie 100644 to 100755) perhaps this is whats actually happening. I'm going to try everything with a file that can CLEARLY remain static (won't be open ANYWHERE and see if the system is functioning like git properly, but the editor is doing some weird file mode things). </p>
  
  <p><strong>update 4</strong></p>
  
  <p>in response to update 3, <strong>i realized that i am an idiot</strong>. lib2gitsharp is functioning properly, but i was stupidly not checking to see if anything that github (apparently) doesn't visually show had changed. In this case, the file modes of the things i was trying to <code>Stage</code> and <code>Commit</code> were changing constantly (for whatever reason, though i'm blaming unity). This was causing it to appear that nothing was changing, when really stuff was changing, just not <em>file content</em>. So all in all, this question answered itself, it just took me way too long to realize it. </p>
  
  <p>I'll also take a minute to give a shoutout to <em><a href="https://stackoverflow.com/users/335418/nulltoken">nulltoken</a></em> because despite <strong><em>my</em> inability</strong> to realize little things, he provided some great help, that got me there in the end.</p>