5 // Created by Pieter de Bie on 9/12/09.
6 // Copyright 2009 Pieter de Bie. All rights reserved.
9 #import <Cocoa/Cocoa.h>
11 @
class PBGitRepository
;
15 * Notifications this class will send
19 extern NSString
*PBGitIndexIndexRefreshStatus
;
20 extern NSString
*PBGitIndexIndexRefreshFailed
;
21 extern NSString
*PBGitIndexFinishedIndexRefresh
;
23 // The "indexChanges" array has changed
24 extern NSString
*PBGitIndexIndexUpdated
;
27 extern NSString
*PBGitIndexCommitStatus
;
28 extern NSString
*PBGitIndexCommitFailed
;
29 extern NSString
*PBGitIndexFinishedCommit
;
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
{
46 PBGitRepository
*repository
;
47 NSURL
*workingDirectory
;
48 NSMutableArray
*files
;
50 NSUInteger refreshStatus
;
51 NSDictionary
*amendEnvironment
;
55 // Whether we want the changes for amending,
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
;
69 - (void)commitWithMessage
:(NSString
*)commitMessage
;
71 // Inter-file changes:
72 - (BOOL
)stageFiles
:(NSArray
*)stageFiles
;
73 - (BOOL
)unstageFiles
:(NSArray
*)unstageFiles
;
74 - (void)discardChangesForFiles
:(NSArray
*)discardFiles
;
77 - (BOOL
)applyPatch
:(NSString
*)hunk stage
:(BOOL
)stage reverse
:(BOOL
)reverse
;
78 - (NSString
*)diffForFile
:(PBChangedFile
*)file staged
:(BOOL
)staged contextLines
:(NSUInteger
)context
;