@@ -120,65 +120,11 @@ - (IBAction) commit:(id) sender
120120 [cachedFilesController setSelectionIndexes: [NSIndexSet indexSet ]];
121121 [unstagedFilesController setSelectionIndexes: [NSIndexSet indexSet ]];
122122
123- NSString *commitSubject;
124- NSRange newLine = [commitMessage rangeOfString: @" \n " ];
125- if (newLine.location == NSNotFound )
126- commitSubject = commitMessage;
127- else
128- commitSubject = [commitMessage substringToIndex: newLine.location];
129-
130- commitSubject = [@" commit: " stringByAppendingString: commitSubject];
131-
132- NSString *commitMessageFile;
133- commitMessageFile = [repository.fileURL.path
134- stringByAppendingPathComponent: @" COMMIT_EDITMSG" ];
135-
136- [commitMessage writeToFile: commitMessageFile atomically: YES encoding: NSUTF8StringEncoding error: nil ];
137-
138- // self.busy++;
139- self.status = @" Creating tree.." ;
140- NSString *tree = [repository outputForCommand: @" write-tree" ];
141- if ([tree length ] != 40 )
142- return [self commitFailedBecause: @" Could not create a tree" ];
143-
144- int ret;
145-
146- NSMutableArray *arguments = [NSMutableArray arrayWithObjects: @" commit-tree" , tree, nil ];
147- NSString *parent = index.amend ? @" HEAD^" : @" HEAD" ;
148- if ([repository parseReference: parent]) {
149- [arguments addObject: @" -p" ];
150- [arguments addObject: parent];
151- }
123+ [index commitWithMessage: commitMessage];
152124
153- NSString *commit = [repository outputForArguments: arguments
154- inputString: commitMessage
155- byExtendingEnvironment: amendEnvironment
156- retValue: &ret];
125+ [webController setStateMessage: [NSString stringWithFormat: @" Successfully created commit" ]];
157126
158- if (ret || [commit length ] != 40 )
159- return [self commitFailedBecause: @" Could not create a commit object" ];
160-
161- if (![repository executeHook: @" pre-commit" output: nil ])
162- return [self commitFailedBecause: @" Pre-commit hook failed" ];
163-
164- if (![repository executeHook: @" commit-msg" withArgs: [NSArray arrayWithObject: commitMessageFile] output: nil ])
165- return [self commitFailedBecause: @" Commit-msg hook failed" ];
166-
167- [repository outputForArguments: [NSArray arrayWithObjects: @" update-ref" , @" -m" , commitSubject, @" HEAD" , commit, nil ]
168- retValue: &ret];
169- if (ret)
170- return [self commitFailedBecause: @" Could not update HEAD" ];
171-
172- if (![repository executeHook: @" post-commit" output: nil ])
173- [webController setStateMessage: [NSString stringWithFormat: @" Post-commit hook failed, however, successfully created commit %@ " , commit]];
174- else
175- [webController setStateMessage: [NSString stringWithFormat: @" Successfully created commit %@ " , commit]];
176-
177- repository.hasChanged = YES ;
178- // self.busy--;
179127 [commitMessageView setString: @" " ];
180- amendEnvironment = nil ;
181- index.amend = NO ;
182128}
183129
184130- (void ) stageHunk : (NSString *)hunk reverse : (BOOL )reverse
0 commit comments