Includes cleanup
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob5c55110e8d192172056396516c80a8db4bab0441
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - TortoiseGit
4 // Copyright (C) 2007-2009 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "Command.h"
22 #include "MessageBox.h"
23 #include "AboutCommand.h"
24 #include "AutoTextTestCommand.h"
25 #include "CommitCommand.h"
26 #include "LogCommand.h"
28 #include "CreateRepositoryCommand.h"
29 #include "CloneCommand.h"
30 #include "PrevDiffCommand.h"
31 #include "DiffCommand.h"
33 #include "RenameCommand.h"
34 #include "RepoStatusCommand.h"
36 #include "RevertCommand.h"
37 #include "RemoveCommand.h"
38 #include "PullCommand.h"
39 #include "FetchCommand.h"
40 #include "PushCommand.h"
41 #include "BranchCommand.h"
42 #include "TagCommand.h"
43 #include "MergeCommand.h"
44 #include "SwitchCommand.h"
45 #include "ExportCommand.h"
46 #include "AddCommand.h"
47 #include "IgnoreCommand.h"
48 #include "FormatPatchCommand.h"
49 #include "ImportPatchCommand.h"
50 #include "BlameCommand.h"
51 #include "SettingsCommand.h"
52 #include "ConflictEditorCommand.h"
53 #include "CleanupCommand.h"
54 #include "RebaseCommand.h"
55 #include "ResolveCommand.h"
56 #include "DropMoveCommand.h"
57 #include "DropCopyAddCommand.h"
58 #include "DropCopyCommand.h"
59 #include "HelpCommand.h"
60 #include "StashCommand.h"
61 #include "SubmoduleCommand.h"
62 #include "ReflogCommand.h"
63 #include "SendMailCommand.h"
64 #include "CatCommand.h"
65 #include "RefBrowseCommand.h"
66 #include "SVNDCommitCommand.h"
67 #include "SVNRebaseCommand.h"
68 #include "SVNFetchCommand.h"
69 #include "SyncCommand.h"
70 #include "RequestPullCommand.h"
71 #include "UpdateCheckCommand.h"
72 #include "PasteCopyCommand.h"
73 #include "PasteMoveCommand.h"
74 #include "SVNIgnoreCommand.h"
75 #include "BisectCommand.h"
76 #include "RepositoryBrowserCommand.h"
77 #include "RevisiongraphCommand.h"
78 #include "ShowCompareCommand.h"
79 #include "DaemonCommand.h"
81 #if 0
84 #include "CopyCommand.h"
85 #include "CrashCommand.h"
91 #include "PropertiesCommand.h"
92 #include "RebuildIconCacheCommand.h"
93 #include "RemoveCommand.h"
97 #include "RevertCommand.h"
98 #include "RTFMCommand.h"
100 #include "UnIgnoreCommand.h"
102 #endif
103 typedef enum
105 cmdAbout,
106 cmdAdd,
107 cmdAutoTextTest,
108 cmdBlame,
109 cmdBranch,
110 cmdCat,
111 cmdCleanup,
112 cmdClone,
113 cmdCommit,
114 cmdConflictEditor,
115 cmdCopy,
116 cmdCrash,
117 cmdDiff,
118 cmdDropCopy,
119 cmdDropCopyAdd,
120 cmdDropMove,
121 cmdFetch,
122 cmdFormatPatch,
123 cmdExport,
124 cmdHelp,
125 cmdIgnore,
126 cmdImportPatch,
127 cmdLog,
128 cmdMerge,
129 cmdPasteCopy,
130 cmdPasteMove,
131 cmdPrevDiff,
132 cmdProperties,
133 cmdPull,
134 cmdPush,
135 cmdRTFM,
136 cmdRebuildIconCache,
137 cmdRemove,
138 cmdRebase,
139 cmdRename,
140 cmdRepoCreate,
141 cmdRepoStatus,
142 cmdResolve,
143 cmdRevert,
144 cmdSendMail,
145 cmdSettings,
146 cmdShowCompare,
147 cmdSwitch,
148 cmdTag,
149 cmdUnIgnore,
150 cmdUpdateCheck,
151 cmdStashSave,
152 cmdStashApply,
153 cmdStashPop,
154 cmdStashList,
155 cmdSubAdd,
156 cmdSubUpdate,
157 cmdSubSync,
158 cmdRefLog,
159 cmdRefBrowse,
160 cmdSVNDCommit,
161 cmdSVNRebase,
162 cmdSVNFetch,
163 cmdSVNIgnore,
164 cmdSync,
165 cmdRequestPull,
166 cmdBisect,
167 cmdRepoBrowser,
168 cmdRevisionGraph,
169 cmdDaemon,
170 cmdPGPFP,
171 } TGitCommand;
173 static const struct CommandInfo
175 TGitCommand command;
176 LPCTSTR pCommandName;
177 } commandInfo[] =
179 { cmdAbout, _T("about") },
180 { cmdAdd, _T("add") },
181 { cmdAutoTextTest, _T("autotexttest") },
182 { cmdBlame, _T("blame") },
183 { cmdBranch, _T("branch") },
184 { cmdCat, _T("cat") },
185 { cmdCleanup, _T("cleanup") },
186 { cmdClone, _T("clone") },
187 { cmdCommit, _T("commit") },
188 { cmdConflictEditor, _T("conflicteditor") },
189 { cmdCopy, _T("copy") },
190 { cmdCrash, _T("crash") },
191 { cmdDiff, _T("diff") },
192 { cmdDropCopy, _T("dropcopy") },
193 { cmdDropCopyAdd, _T("dropcopyadd") },
194 { cmdDropMove, _T("dropmove") },
195 { cmdFetch, _T("fetch") },
196 { cmdFormatPatch, _T("formatpatch") },
197 { cmdExport, _T("export") },
198 { cmdHelp, _T("help") },
199 { cmdIgnore, _T("ignore") },
200 { cmdImportPatch, _T("importpatch") },
201 { cmdLog, _T("log") },
202 { cmdMerge, _T("merge") },
203 { cmdPasteCopy, _T("pastecopy") },
204 { cmdPasteMove, _T("pastemove") },
205 { cmdPrevDiff, _T("prevdiff") },
206 { cmdProperties, _T("properties") },
207 { cmdPull, _T("pull") },
208 { cmdPush, _T("push") },
209 { cmdRTFM, _T("rtfm") },
210 { cmdRebuildIconCache,_T("rebuildiconcache") },
211 { cmdRemove, _T("remove") },
212 { cmdRebase, _T("rebase") },
213 { cmdRename, _T("rename") },
214 { cmdRepoCreate, _T("repocreate") },
215 { cmdRepoStatus, _T("repostatus") },
216 { cmdResolve, _T("resolve") },
217 { cmdRevert, _T("revert") },
218 { cmdSendMail, _T("sendmail") },
219 { cmdSettings, _T("settings") },
220 { cmdShowCompare, _T("showcompare") },
221 { cmdSwitch, _T("switch") },
222 { cmdTag, _T("tag") },
223 { cmdUnIgnore, _T("unignore") },
224 { cmdUpdateCheck, _T("updatecheck") },
225 { cmdStashSave, _T("stashsave") },
226 { cmdStashApply, _T("stashapply") },
227 { cmdStashPop, _T("stashpop") },
228 { cmdStashList, _T("stashlist") },
229 { cmdSubAdd, _T("subadd") },
230 { cmdSubUpdate, _T("subupdate") },
231 { cmdSubSync, _T("subsync") },
232 { cmdRefLog, _T("reflog") },
233 { cmdRefBrowse, _T("refbrowse") },
234 { cmdSVNDCommit, _T("svndcommit") },
235 { cmdSVNRebase, _T("svnrebase") },
236 { cmdSVNFetch, _T("svnfetch") },
237 { cmdSVNIgnore, _T("svnignore") },
238 { cmdSync, _T("sync") },
239 { cmdRequestPull, _T("requestpull") },
240 { cmdBisect, _T("bisect") },
241 { cmdRepoBrowser, _T("repobrowser") },
242 { cmdRevisionGraph, _T("revisiongraph") },
243 { cmdDaemon, _T("daemon") },
244 { cmdPGPFP, _T("pgpfp") },
248 Command * CommandServer::GetCommand(const CString& sCmd)
250 // Look up the command
251 TGitCommand command = cmdAbout; // Something harmless as a default
252 for (int nCommand = 0; nCommand < _countof(commandInfo); ++nCommand)
254 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
256 // We've found the command
257 command = commandInfo[nCommand].command;
258 // If this fires, you've let the enum get out of sync with the commandInfo array
259 ASSERT((int)command == nCommand);
260 break;
264 // CBrowseRefsDlg dialog
265 switch (command)
267 case cmdAbout:
268 return new AboutCommand;
269 case cmdAutoTextTest:
270 return new AutoTextTestCommand;
271 case cmdCommit:
272 return new CommitCommand;
273 case cmdLog:
274 return new LogCommand;
275 case cmdRepoCreate:
276 return new CreateRepositoryCommand;
277 case cmdClone:
278 return new CloneCommand;
279 case cmdPrevDiff:
280 return new PrevDiffCommand;
281 case cmdDiff:
282 return new DiffCommand;
283 case cmdRename:
284 return new RenameCommand;
285 case cmdRepoStatus:
286 return new RepoStatusCommand;
287 case cmdRemove:
288 return new RemoveCommand;
289 case cmdRevert:
290 return new RevertCommand;
291 case cmdPull:
292 return new PullCommand;
293 case cmdFetch:
294 return new FetchCommand;
295 case cmdPush:
296 return new PushCommand;
297 case cmdBranch:
298 return new BranchCommand;
299 case cmdTag:
300 return new TagCommand;
301 case cmdMerge:
302 return new MergeCommand;
303 case cmdSwitch:
304 return new SwitchCommand;
305 case cmdExport:
306 return new ExportCommand;
307 case cmdAdd:
308 return new AddCommand;
309 case cmdIgnore:
310 return new IgnoreCommand;
311 case cmdFormatPatch:
312 return new FormatPatchCommand;
313 case cmdImportPatch:
314 return new ImportPatchCommand;
315 case cmdBlame:
316 return new BlameCommand;
317 case cmdSettings:
318 return new SettingsCommand;
319 case cmdConflictEditor:
320 return new ConflictEditorCommand;
321 case cmdCleanup:
322 return new CleanupCommand;
323 case cmdRebase:
324 return new RebaseCommand;
325 case cmdResolve:
326 return new ResolveCommand;
327 case cmdDropMove:
328 return new DropMoveCommand;
329 case cmdDropCopy:
330 return new DropCopyCommand;
331 case cmdDropCopyAdd:
332 return new DropCopyAddCommand;
333 case cmdHelp:
334 return new HelpCommand;
335 case cmdStashSave:
336 return new StashSaveCommand;
337 case cmdStashApply:
338 return new StashApplyCommand;
339 case cmdStashPop:
340 return new StashPopCommand;
341 case cmdSubAdd:
342 return new SubmoduleAddCommand;
343 case cmdSubUpdate:
344 return new SubmoduleUpdateCommand;
345 case cmdRefLog:
346 return new RefLogCommand;
347 case cmdSubSync:
348 return new SubmoduleSyncCommand;
349 case cmdSendMail:
350 return new SendMailCommand;
351 case cmdCat:
352 return new CatCommand;
353 case cmdRefBrowse:
354 return new RefBrowseCommand;
355 case cmdSVNDCommit:
356 return new SVNDCommitCommand;
357 case cmdSVNRebase:
358 return new SVNRebaseCommand;
359 case cmdSVNFetch:
360 return new SVNFetchCommand;
361 case cmdSync:
362 return new SyncCommand;
363 case cmdRequestPull:
364 return new RequestPullCommand;
365 case cmdUpdateCheck:
366 return new UpdateCheckCommand;
367 case cmdPasteCopy:
368 return new PasteCopyCommand;
369 case cmdPasteMove:
370 return new PasteMoveCommand;
371 case cmdSVNIgnore:
372 return new SVNIgnoreCommand;
373 case cmdBisect:
374 return new BisectCommand;
375 case cmdRepoBrowser:
376 return new RepositoryBrowserCommand;
377 case cmdRevisionGraph:
378 return new RevisionGraphCommand;
379 case cmdShowCompare:
380 return new ShowCompareCommand;
381 case cmdDaemon:
382 return new DaemonCommand;
384 #if 0
388 case cmdCopy:
389 return new CopyCommand;
390 case cmdCrash:
391 return new CrashCommand;
395 case cmdPrevDiff:
396 return new PrevDiffCommand;
397 case cmdProperties:
398 return new PropertiesCommand;
399 case cmdRTFM:
400 return new RTFMCommand;
401 case cmdRebuildIconCache:
402 return new RebuildIconCacheCommand;
403 case cmdUnIgnore:
404 return new UnIgnoreCommand;
405 #endif
406 case cmdPGPFP:
408 CMessageBox::Show(hWndExplorer, _T("This is the fingerprint of the TortoiseGit Release Signing Key.\nIt can be used to establish a trust path from this release to another one.\n\nTortoiseGit Release Signing Key, 4096-bit RSA:\n74A2 1AE3 01B3 CA5B D807 2F5E F7F1 7B3F 9DD9 539E"), _T("TortoiseGit"), MB_OK);
409 return nullptr;
411 default:
412 CMessageBox::Show(hWndExplorer, _T("Command not implemented"), _T("TortoiseGit"), MB_ICONERROR);
413 return new AboutCommand;