Add context menu entries to toggle assume-valid flag
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blobe10b017cd265c7e6a787f4fce7e643cefb0c7b24
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2007-2008 - 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"
23 #include "AboutCommand.h"
24 #include "CommitCommand.h"
25 #include "LogCommand.h"
27 #include "CreateRepositoryCommand.h"
28 #include "CloneCommand.h"
29 #include "PrevDiffCommand.h"
30 #include "DiffCommand.h"
32 #include "RenameCommand.h"
33 #include "RepoStatusCommand.h"
35 #include "RevertCommand.h"
36 #include "RemoveCommand.h"
37 #include "PullCommand.h"
38 #include "FetchCommand.h"
39 #include "PushCommand.h"
40 #include "BranchCommand.h"
41 #include "TagCommand.h"
42 #include "MergeCommand.h"
43 #include "SwitchCommand.h"
44 #include "ExportCommand.h"
45 #include "AddCommand.h"
46 #include "IgnoreCommand.h"
47 #include "FormatPatchCommand.h"
48 #include "ImportPatchCommand.h"
49 #include "BlameCommand.h"
50 #include "SettingsCommand.h"
51 #include "ConflictEditorCommand.h"
52 #include "CleanupCommand.h"
53 #include "RebaseCommand.h"
54 #include "ResolveCommand.h"
55 #include "DropMoveCommand.h"
56 #include "DropCopyAddCommand.h"
57 #include "DropCopyCommand.h"
58 #include "HelpCommand.h"
59 #include "StashCommand.h"
60 #include "SubmoduleCommand.h"
61 #include "ReflogCommand.h"
62 #include "SendMailCommand.h"
63 #include "CatCommand.h"
64 #include "RefBrowseCommand.h"
65 #include "SVNDCommitCommand.h"
66 #include "SVNRebaseCommand.h"
67 #include "SVNFetchCommand.h"
68 #include "SyncCommand.h"
69 #include "RequestPullCommand.h"
70 #include "UpdateCheckCommand.h"
71 #include "PasteCopyCommand.h"
72 #include "PasteMoveCommand.h"
73 #include "SVNIgnoreCommand.h"
74 #include "BisectCommand.h"
75 #include "RepositoryBrowserCommand.h"
76 #include "AssumeValidCommand.h"
78 #if 0
81 #include "CopyCommand.h"
82 #include "CrashCommand.h"
88 #include "PropertiesCommand.h"
89 #include "RebuildIconCacheCommand.h"
90 #include "RemoveCommand.h"
94 #include "RevertCommand.h"
95 #include "RTFMCommand.h"
97 #include "ShowCompareCommand.h"
99 #include "UnIgnoreCommand.h"
101 #endif
102 typedef enum
104 cmdAbout,
105 cmdAdd,
106 cmdBlame,
107 cmdBranch,
108 cmdCat,
109 cmdCleanup,
110 cmdClone,
111 cmdCommit,
112 cmdConflictEditor,
113 cmdCopy,
114 cmdCrash,
115 cmdDiff,
116 cmdDropCopy,
117 cmdDropCopyAdd,
118 cmdDropMove,
119 cmdFetch,
120 cmdFormatPatch,
121 cmdExport,
122 cmdHelp,
123 cmdIgnore,
124 cmdImportPatch,
125 cmdLog,
126 cmdMerge,
127 cmdPasteCopy,
128 cmdPasteMove,
129 cmdPrevDiff,
130 cmdProperties,
131 cmdPull,
132 cmdPush,
133 cmdRTFM,
134 cmdRebuildIconCache,
135 cmdRemove,
136 cmdRebase,
137 cmdRename,
138 cmdRepoCreate,
139 cmdRepoStatus,
140 cmdResolve,
141 cmdRevert,
142 cmdSendMail,
143 cmdSettings,
144 cmdShowCompare,
145 cmdSwitch,
146 cmdTag,
147 cmdUnIgnore,
148 cmdUpdateCheck,
149 cmdStashSave,
150 cmdStashApply,
151 cmdStashPop,
152 cmdStashList,
153 cmdSubAdd,
154 cmdSubUpdate,
155 cmdSubSync,
156 cmdRefLog,
157 cmdRefBrowse,
158 cmdSVNDCommit,
159 cmdSVNRebase,
160 cmdSVNFetch,
161 cmdSVNIgnore,
162 cmdSync,
163 cmdRequestPull,
164 cmdBisect,
165 cmdRepoBrowser,
166 cmdAssumeValid,
167 } TGitCommand;
169 static const struct CommandInfo
171 TGitCommand command;
172 LPCTSTR pCommandName;
173 } commandInfo[] =
175 { cmdAbout, _T("about") },
176 { cmdAdd, _T("add") },
177 { cmdBlame, _T("blame") },
178 { cmdBranch, _T("branch") },
179 { cmdCat, _T("cat") },
180 { cmdCleanup, _T("cleanup") },
181 { cmdClone, _T("clone") },
182 { cmdCommit, _T("commit") },
183 { cmdConflictEditor, _T("conflicteditor") },
184 { cmdCopy, _T("copy") },
185 { cmdCrash, _T("crash") },
186 { cmdDiff, _T("diff") },
187 { cmdDropCopy, _T("dropcopy") },
188 { cmdDropCopyAdd, _T("dropcopyadd") },
189 { cmdDropMove, _T("dropmove") },
190 { cmdFetch, _T("fetch") },
191 { cmdFormatPatch, _T("formatpatch") },
192 { cmdExport, _T("export") },
193 { cmdHelp, _T("help") },
194 { cmdIgnore, _T("ignore") },
195 { cmdImportPatch, _T("importpatch") },
196 { cmdLog, _T("log") },
197 { cmdMerge, _T("merge") },
198 { cmdPasteCopy, _T("pastecopy") },
199 { cmdPasteMove, _T("pastemove") },
200 { cmdPrevDiff, _T("prevdiff") },
201 { cmdProperties, _T("properties") },
202 { cmdPull, _T("pull") },
203 { cmdPush, _T("push") },
204 { cmdRTFM, _T("rtfm") },
205 { cmdRebuildIconCache,_T("rebuildiconcache") },
206 { cmdRemove, _T("remove") },
207 { cmdRebase, _T("rebase") },
208 { cmdRename, _T("rename") },
209 { cmdRepoCreate, _T("repocreate") },
210 { cmdRepoStatus, _T("repostatus") },
211 { cmdResolve, _T("resolve") },
212 { cmdRevert, _T("revert") },
213 { cmdSendMail, _T("sendmail") },
214 { cmdSettings, _T("settings") },
215 { cmdShowCompare, _T("showcompare") },
216 { cmdSwitch, _T("switch") },
217 { cmdTag, _T("tag") },
218 { cmdUnIgnore, _T("unignore") },
219 { cmdUpdateCheck, _T("updatecheck") },
220 { cmdStashSave, _T("stashsave") },
221 { cmdStashApply, _T("stashapply") },
222 { cmdStashPop, _T("stashpop") },
223 { cmdStashList, _T("stashlist") },
224 { cmdSubAdd, _T("subadd") },
225 { cmdSubUpdate, _T("subupdate") },
226 { cmdSubSync, _T("subsync") },
227 { cmdRefLog, _T("reflog") },
228 { cmdRefBrowse, _T("refbrowse") },
229 { cmdSVNDCommit, _T("svndcommit") },
230 { cmdSVNRebase, _T("svnrebase") },
231 { cmdSVNFetch, _T("svnfetch") },
232 { cmdSVNIgnore, _T("svnignore") },
233 { cmdSync, _T("sync") },
234 { cmdRequestPull, _T("requestpull") },
235 { cmdBisect, _T("bisect") },
236 { cmdRepoBrowser, _T("repobrowser") },
237 { cmdAssumeValid, _T("assumevalid") },
241 Command * CommandServer::GetCommand(const CString& sCmd)
243 // Look up the command
244 TGitCommand command = cmdAbout; // Something harmless as a default
245 for (int nCommand = 0; nCommand < _countof(commandInfo); nCommand++)
247 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
249 // We've found the command
250 command = commandInfo[nCommand].command;
251 // If this fires, you've let the enum get out of sync with the commandInfo array
252 ASSERT((int)command == nCommand);
253 break;
257 // CBrowseRefsDlg dialog
258 switch (command)
260 case cmdAbout:
261 return new AboutCommand;
262 case cmdCommit:
263 return new CommitCommand;
264 case cmdLog:
265 return new LogCommand;
266 case cmdRepoCreate:
267 return new CreateRepositoryCommand;
268 case cmdClone:
269 return new CloneCommand;
270 case cmdPrevDiff:
271 return new PrevDiffCommand;
272 case cmdDiff:
273 return new DiffCommand;
274 case cmdRename:
275 return new RenameCommand;
276 case cmdRepoStatus:
277 return new RepoStatusCommand;
278 case cmdRemove:
279 return new RemoveCommand;
280 case cmdRevert:
281 return new RevertCommand;
282 case cmdPull:
283 return new PullCommand;
284 case cmdFetch:
285 return new FetchCommand;
286 case cmdPush:
287 return new PushCommand;
288 case cmdBranch:
289 return new BranchCommand;
290 case cmdTag:
291 return new TagCommand;
292 case cmdMerge:
293 return new MergeCommand;
294 case cmdSwitch:
295 return new SwitchCommand;
296 case cmdExport:
297 return new ExportCommand;
298 case cmdAdd:
299 return new AddCommand;
300 case cmdIgnore:
301 return new IgnoreCommand;
302 case cmdFormatPatch:
303 return new FormatPatchCommand;
304 case cmdImportPatch:
305 return new ImportPatchCommand;
306 case cmdBlame:
307 return new BlameCommand;
308 case cmdSettings:
309 return new SettingsCommand;
310 case cmdConflictEditor:
311 return new ConflictEditorCommand;
312 case cmdCleanup:
313 return new CleanupCommand;
314 case cmdRebase:
315 return new RebaseCommand;
316 case cmdResolve:
317 return new ResolveCommand;
318 case cmdDropMove:
319 return new DropMoveCommand;
320 case cmdDropCopy:
321 return new DropCopyCommand;
322 case cmdDropCopyAdd:
323 return new DropCopyAddCommand;
324 case cmdHelp:
325 return new HelpCommand;
326 case cmdStashSave:
327 return new StashSaveCommand;
328 case cmdStashApply:
329 return new StashApplyCommand;
330 case cmdStashPop:
331 return new StashPopCommand;
332 case cmdSubAdd:
333 return new SubmoduleAddCommand;
334 case cmdSubUpdate:
335 return new SubmoduleUpdateCommand;
336 case cmdRefLog:
337 return new RefLogCommand;
338 case cmdSubSync:
339 return new SubmoduleSyncCommand;
340 case cmdSendMail:
341 return new SendMailCommand;
342 case cmdCat:
343 return new CatCommand;
344 case cmdRefBrowse:
345 return new RefBrowseCommand;
346 case cmdSVNDCommit:
347 return new SVNDCommitCommand;
348 case cmdSVNRebase:
349 return new SVNRebaseCommand;
350 case cmdSVNFetch:
351 return new SVNFetchCommand;
352 case cmdSync:
353 return new SyncCommand;
354 case cmdRequestPull:
355 return new RequestPullCommand;
356 case cmdUpdateCheck:
357 return new UpdateCheckCommand;
358 case cmdPasteCopy:
359 return new PasteCopyCommand;
360 case cmdPasteMove:
361 return new PasteMoveCommand;
362 case cmdSVNIgnore:
363 return new SVNIgnoreCommand;
364 case cmdBisect:
365 return new BisectCommand;
366 case cmdRepoBrowser:
367 return new RepositoryBrowserCommand;
368 case cmdAssumeValid:
369 return new AssumeValidCommand;
371 #if 0
375 case cmdCopy:
376 return new CopyCommand;
377 case cmdCrash:
378 return new CrashCommand;
382 case cmdPrevDiff:
383 return new PrevDiffCommand;
384 case cmdProperties:
385 return new PropertiesCommand;
386 case cmdRTFM:
387 return new RTFMCommand;
388 case cmdRebuildIconCache:
389 return new RebuildIconCacheCommand;
390 case cmdShowCompare:
391 return new ShowCompareCommand;
392 case cmdUnIgnore:
393 return new UnIgnoreCommand;
394 #endif
395 default:
396 CMessageBox::Show(hWndExplorer, _T("Command not implemented"), _T("TortoiseGit"), MB_ICONERROR);
397 return new AboutCommand;