test/index: add more tests
[GitX.git] / PBGitIndex.h
blob7ca1db78b4345c77fb3c814d6a5d2c77d15d9e17
1 //
2 // PBGitIndex.h
3 // GitX
4 //
5 // Created by Pieter de Bie on 9/12/09.
6 // Copyright 2009 Pieter de Bie. All rights reserved.
7 //
9 #import <Cocoa/Cocoa.h>
11 @class PBGitRepository;
12 @class PBChangedFile;
15 * Notifications this class will send
18 // Refreshing index
19 extern NSString *PBGitIndexIndexRefreshStatus;
20 extern NSString *PBGitIndexIndexRefreshFailed;
21 extern NSString *PBGitIndexFinishedIndexRefresh;
23 // The "indexChanges" array has changed
24 extern NSString *PBGitIndexIndexUpdated;
26 // Committing files
27 extern NSString *PBGitIndexCommitStatus;
28 extern NSString *PBGitIndexCommitFailed;
29 extern NSString *PBGitIndexFinishedCommit;
31 // Changing to amend
32 extern NSString *PBGitIndexAmendMessageAvailable;
34 // This is for general operations, like applying a patch
35 extern NSString *PBGitIndexOperationFailed;
39 // Represents a git index for a given work tree.
40 // As a single git repository can have multiple trees,
41 // the tree has to be given explicitly, even though
42 // multiple trees is not yet supported in GitX
43 @interface PBGitIndex : NSObject {
45 @private
46 PBGitRepository *repository;
47 NSURL *workingDirectory;
48 NSMutableArray *files;
50 NSUInteger refreshStatus;
51 NSDictionary *amendEnvironment;
52 BOOL amend;
55 // Whether we want the changes for amending,
56 // or for
57 @property BOOL amend;
59 - (id)initWithRepository:(PBGitRepository *)repository workingDirectory:(NSURL *)workingDirectory;
61 // A list of PBChangedFile's with differences between the work tree and the index
62 // This method is KVO-aware, so changes when any of the index-modifying methods are called
63 // (including -refresh)
64 - (NSArray *)indexChanges;
66 // Refresh the index
67 - (void)refresh;
69 - (void)commitWithMessage:(NSString *)commitMessage;
71 // Inter-file changes:
72 - (BOOL)stageFiles:(NSArray *)stageFiles;
73 - (BOOL)unstageFiles:(NSArray *)unstageFiles;
74 - (void)discardChangesForFiles:(NSArray *)discardFiles;
76 // Intra-file changes
77 - (BOOL)applyPatch:(NSString *)hunk stage:(BOOL)stage reverse:(BOOL)reverse;
78 - (NSString *)diffForFile:(PBChangedFile *)file staged:(BOOL)staged contextLines:(NSUInteger)context;
80 @end