Correct Handle case when patch file is not in repository path.
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blobca02b315713d1e55d18be51c928b24214878ca02
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "StdAfx.h"
20 #include "Command.h"
22 #include "AboutCommand.h"
23 #include "CommitCommand.h"
24 #include "LogCommand.h"
26 #include "CreateRepositoryCommand.h"
27 #include "CloneCommand.h"
28 #include "PrevDiffCommand.h"
29 #include "DiffCommand.h"
31 #include "RenameCommand.h"
32 #include "RepoStatusCommand.h"
34 #include "RevertCommand.h"
35 #include "RemoveCommand.h"
36 #include "PullCommand.h"
37 #include "FetchCommand.h"
38 #include "PushCommand.h"
39 #include "BranchCommand.h"
40 #include "TagCommand.h"
41 #include "MergeCommand.h"
42 #include "SwitchCommand.h"
43 #include "ExportCommand.h"
44 #include "AddCommand.h"
45 #include "IgnoreCommand.h"
46 #include "FormatPatchCommand.h"
47 #include "ImportPatchCommand.h"
48 #include "BlameCommand.h"
49 #include "SettingsCommand.h"
50 #include "ConflictEditorCommand.h"
51 #include "CleanupCommand.h"
52 #include "RebaseCommand.h"
53 #include "ResolveCommand.h"
54 #include "DropMoveCommand.h"
55 #include "DropCopyAddCommand.h"
56 #include "DropCopyCommand.h"
57 #include "DropExportCommand.h"
58 #include "HelpCommand.h"
59 #include "StashCommand.h"
60 #include "SubmoduleCommand.h"
61 #include "ReflogCommand.h"
63 #if 0
66 #include "CatCommand.h"
67 #include "CheckoutCommand.h"
71 #include "CopyCommand.h"
72 #include "CrashCommand.h"
73 #include "CreatePatchCommand.h"
75 #include "DelUnversionedCommand.h"
82 #include "ImportCommand.h"
83 #include "LockCommand.h"
86 #include "MergeAllCommand.h"
87 #include "PasteCopyCommand.h"
88 #include "PasteMoveCommand.h"
90 #include "PropertiesCommand.h"
91 #include "RebuildIconCacheCommand.h"
92 #include "RelocateCommand.h"
93 #include "RemoveCommand.h"
95 #include "RepositoryBrowserCommand.h"
98 #include "RevertCommand.h"
99 #include "RevisiongraphCommand.h"
100 #include "RTFMCommand.h"
102 #include "ShowCompareCommand.h"
104 #include "UnIgnoreCommand.h"
105 #include "UnLockCommand.h"
106 #include "UpdateCheckCommand.h"
107 #include "UpdateCommand.h"
108 #include "UrlDiffCommand.h"
109 #endif
110 typedef enum
112 cmdAbout,
113 cmdAdd,
114 cmdBlame,
115 cmdBranch,
116 cmdCat,
117 cmdCheckout,
118 cmdCleanup,
119 cmdClone,
120 cmdCommit,
121 cmdConflictEditor,
122 cmdCopy,
123 cmdCrash,
124 cmdCreatePatch,
125 cmdDelUnversioned,
126 cmdDiff,
127 cmdDropCopy,
128 cmdDropCopyAdd,
129 cmdDropExport,
130 cmdDropMove,
131 cmdFetch,
132 cmdFormatPatch,
133 cmdExport,
134 cmdHelp,
135 cmdIgnore,
136 cmdImport,
137 cmdImportPatch,
138 cmdLock,
139 cmdLog,
140 cmdMerge,
141 cmdMergeAll,
142 cmdPasteCopy,
143 cmdPasteMove,
144 cmdPrevDiff,
145 cmdProperties,
146 cmdPull,
147 cmdPush,
148 cmdRTFM,
149 cmdRebuildIconCache,
150 cmdRelocate,
151 cmdRemove,
152 cmdRebase,
153 cmdRename,
154 cmdRepoBrowser,
155 cmdRepoCreate,
156 cmdRepoStatus,
157 cmdResolve,
158 cmdRevert,
159 cmdRevisionGraph,
160 cmdSettings,
161 cmdShowCompare,
162 cmdSwitch,
163 cmdTag,
164 cmdUnIgnore,
165 cmdUnlock,
166 cmdUpdate,
167 cmdUpdateCheck,
168 cmdUrlDiff,
169 cmdStashSave,
170 cmdStashApply,
171 cmdStashList,
172 cmdSubAdd,
173 cmdSubUpdate,
174 cmdSubSync,
175 cmdRefLog,
177 } TGitCommand;
179 static const struct CommandInfo
181 TGitCommand command;
182 LPCTSTR pCommandName;
183 } commandInfo[] =
185 { cmdAbout, _T("about") },
186 { cmdAdd, _T("add") },
187 { cmdBlame, _T("blame") },
188 { cmdBranch, _T("branch") },
189 { cmdCat, _T("cat") },
190 { cmdCheckout, _T("checkout") },
191 { cmdCleanup, _T("cleanup") },
192 { cmdClone, _T("clone") },
193 { cmdCommit, _T("commit") },
194 { cmdConflictEditor, _T("conflicteditor") },
195 { cmdCopy, _T("copy") },
196 { cmdCrash, _T("crash") },
197 { cmdCreatePatch, _T("createpatch") },
198 { cmdDelUnversioned, _T("delunversioned") },
199 { cmdDiff, _T("diff") },
200 { cmdDropCopy, _T("dropcopy") },
201 { cmdDropCopyAdd, _T("dropcopyadd") },
202 { cmdDropExport, _T("dropexport") },
203 { cmdDropMove, _T("dropmove") },
204 { cmdFetch, _T("fetch") },
205 { cmdFormatPatch, _T("formatpatch") },
206 { cmdExport, _T("export") },
207 { cmdHelp, _T("help") },
208 { cmdIgnore, _T("ignore") },
209 { cmdImport, _T("import") },
210 { cmdImportPatch, _T("importpatch") },
211 { cmdLock, _T("lock") },
212 { cmdLog, _T("log") },
213 { cmdMerge, _T("merge") },
214 { cmdMergeAll, _T("mergeall") },
215 { cmdPasteCopy, _T("pastecopy") },
216 { cmdPasteMove, _T("pastemove") },
217 { cmdPrevDiff, _T("prevdiff") },
218 { cmdProperties, _T("properties") },
219 { cmdPull, _T("pull") },
220 { cmdPush, _T("push") },
221 { cmdRTFM, _T("rtfm") },
222 { cmdRebuildIconCache,_T("rebuildiconcache") },
223 { cmdRelocate, _T("relocate") },
224 { cmdRemove, _T("remove") },
225 { cmdRebase, _T("rebase") },
226 { cmdRename, _T("rename") },
227 { cmdRepoBrowser, _T("repobrowser") },
228 { cmdRepoCreate, _T("repocreate") },
229 { cmdRepoStatus, _T("repostatus") },
230 { cmdResolve, _T("resolve") },
231 { cmdRevert, _T("revert") },
232 { cmdRevisionGraph, _T("revisiongraph") },
233 { cmdSettings, _T("settings") },
234 { cmdShowCompare, _T("showcompare") },
235 { cmdSwitch, _T("switch") },
236 { cmdTag, _T("tag") },
237 { cmdUnIgnore, _T("unignore") },
238 { cmdUnlock, _T("unlock") },
239 { cmdUpdate, _T("update") },
240 { cmdUpdateCheck, _T("updatecheck") },
241 { cmdUrlDiff, _T("urldiff") },
242 { cmdStashSave, _T("stashsave") },
243 { cmdStashApply, _T("stashapply") },
244 { cmdStashList, _T("stashlist") },
245 { cmdSubAdd, _T("subadd") },
246 { cmdSubUpdate, _T("subupdate") },
247 { cmdSubSync, _T("subsync") },
248 { cmdRefLog, _T("reflog") }
254 Command * CommandServer::GetCommand(const CString& sCmd)
256 // Look up the command
257 TGitCommand command = cmdAbout; // Something harmless as a default
258 for (int nCommand = 0; nCommand < (sizeof(commandInfo)/sizeof(commandInfo[0])); nCommand++)
260 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
262 // We've found the command
263 command = commandInfo[nCommand].command;
264 // If this fires, you've let the enum get out of sync with the commandInfo array
265 ASSERT((int)command == nCommand);
266 break;
272 switch (command)
274 case cmdAbout:
275 return new AboutCommand;
276 case cmdCommit:
277 return new CommitCommand;
278 case cmdLog:
279 return new LogCommand;
280 case cmdRepoCreate:
281 return new CreateRepositoryCommand;
282 case cmdClone:
283 return new CloneCommand;
284 case cmdPrevDiff:
285 return new PrevDiffCommand;
286 case cmdDiff:
287 return new DiffCommand;
288 case cmdRename:
289 return new RenameCommand;
290 case cmdRepoStatus:
291 return new RepoStatusCommand;
292 case cmdRemove:
293 return new RemoveCommand;
294 case cmdRevert:
295 return new RevertCommand;
296 case cmdPull:
297 return new PullCommand;
298 case cmdFetch:
299 return new FetchCommand;
300 case cmdPush:
301 return new PushCommand;
302 case cmdBranch:
303 return new BranchCommand;
304 case cmdTag:
305 return new TagCommand;
306 case cmdMerge:
307 return new MergeCommand;
308 case cmdSwitch:
309 return new SwitchCommand;
310 case cmdExport:
311 return new ExportCommand;
312 case cmdAdd:
313 return new AddCommand;
314 case cmdIgnore:
315 return new IgnoreCommand;
316 case cmdFormatPatch:
317 return new FormatPatchCommand;
318 case cmdImportPatch:
319 return new ImportPatchCommand;
320 case cmdBlame:
321 return new BlameCommand;
322 case cmdSettings:
323 return new SettingsCommand;
324 case cmdConflictEditor:
325 return new ConflictEditorCommand;
326 case cmdCleanup:
327 return new CleanupCommand;
328 case cmdRebase:
329 return new RebaseCommand;
330 case cmdResolve:
331 return new ResolveCommand;
332 case cmdDropMove:
333 return new DropMoveCommand;
334 // case cmdDropCopy:
335 // return new DropCopyCommand;
336 // case cmdDropCopyAdd:
337 // return new DropCopyAddCommand;
338 // case cmdDropExport:
339 // return new DropExportCommand;
340 case cmdHelp:
341 return new HelpCommand;
342 case cmdStashSave:
343 return new StashSaveCommand;
344 case cmdStashApply:
345 return new StashApplyCommand;
346 case cmdSubAdd:
347 return new SubmoduleAddCommand;
348 case cmdSubUpdate:
349 return new SubmoduleUpdateCommand;
350 case cmdRefLog:
351 return new RefLogCommand;
352 case cmdSubSync:
353 return new SubmoduleSyncCommand;
355 #if 0
357 case cmdCat:
358 return new CatCommand;
359 case cmdCheckout:
360 return new CheckoutCommand;
364 case cmdCopy:
365 return new CopyCommand;
366 case cmdCrash:
367 return new CrashCommand;
368 case cmdCreatePatch:
369 return new CreatePatchCommand;
370 case cmdDelUnversioned:
371 return new DelUnversionedCommand;
375 case cmdImport:
376 return new ImportCommand;
377 case cmdLock:
378 return new LockCommand;
379 case cmdMergeAll:
380 return new MergeAllCommand;
381 case cmdPasteCopy:
382 return new PasteCopyCommand;
383 case cmdPasteMove:
384 return new PasteMoveCommand;
385 case cmdPrevDiff:
386 return new PrevDiffCommand;
387 case cmdProperties:
388 return new PropertiesCommand;
389 case cmdRTFM:
390 return new RTFMCommand;
391 case cmdRebuildIconCache:
392 return new RebuildIconCacheCommand;
393 case cmdRelocate:
394 return new RelocateCommand;
395 case cmdRepoBrowser:
396 return new RepositoryBrowserCommand;
397 case cmdRevisionGraph:
398 return new RevisionGraphCommand;
399 case cmdShowCompare:
400 return new ShowCompareCommand;
401 case cmdUnIgnore:
402 return new UnIgnoreCommand;
403 case cmdUnlock:
404 return new UnLockCommand;
405 case cmdUpdate:
406 return new UpdateCommand;
407 case cmdUpdateCheck:
408 return new UpdateCheckCommand;
409 case cmdUrlDiff:
410 return new UrlDiffCommand;
411 #endif
412 default:
413 CMessageBox::Show(hWndExplorer, _T("Have not implemented"), _T("TortoiseGit"), MB_ICONERROR);
414 return new AboutCommand;