Menu

#1 GitStatusResponse API

open
nobody
None
7
2008-07-29
2008-07-29
No

None of the methods in the GitStatus Response really do what I want:

I have a list/array of files. I want to call GitStatus once, then iterate over my list and get the status of each file.

eg.
GitStatusResponse gsr = new GitStatus().status(myroot);

for (File f : myfileList) {
stat.add(gsr.getStatus(f));
}

or something like that.

Currently that does not seem to be possible in the existing api.

Discussion

  • Paul M Bethe

    Paul M Bethe - 2008-07-29

    Logged In: YES
    user_id=308431
    Originator: YES

    ALSO, in this new getStatus method, please consider returning untracked for files which are in an untracked folder.

     
  • Maxim A.

    Maxim A. - 2008-08-02

    Logged In: YES
    user_id=2155661
    Originator: NO

    There is a different way to get the status of the of a file. You can use higher level API. WorkingTree class has a method GitFile getFile(File file), which returns you an instance of GitFile. You can then simply call GitFile's getStatus() method.

    If you really do not want to use that API, I've also recently added a new method to GitStatus: getFileStatus(). Then you can simply do the following:

    File repositoryDirectory;
    /*
    init repository directory...
    */

    File myFile("foo");
    GitFileSystemObject.Status status = new GitStatus().getSingleFileStatus(repositoryDirectory, myFile);

    GitFileSystemObject.Status is an enumeration. See GitFileSystemObject.java for details.

     
  • Maxim A.

    Maxim A. - 2008-08-02

    Logged In: YES
    user_id=2155661
    Originator: NO

    Paul,
    I apologize, I actually misunderstood your original question. However, if you use API, you can still get list of GitFileSystemObjects from WorkingTree (getTree()) and then iterate through the list and call getStatus() on each object. There is one complication: you have to check if GitFileSystemObject object is a GitFile object, and then convert it to one, before you call getStatus().

     
  • Maxim A.

    Maxim A. - 2008-08-09

    Logged In: YES
    user_id=2155661
    Originator: NO

    I have added a new method to GitStatusResponse class: getFileStatus(), which takes java.io.File object as a parameter and return GitFileSystemObject.Status value. For the simplest example, check out getFileStatus() in GitStatus.java (/javagit/trunk/javagit/src/main/java/edu/nyu/cs/javagit/api/commands). That should allow you to query the status of any file the way you wanted.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.