Fixed issue #820: Missing menu item for "git svn fetch"
[TortoiseGit.git] / src / TortoiseProc / Commands / Command.cpp
blob47121453f98f9ea355ec0f7062adadec733dc843
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
4 // Copyright (C) 2008-2011 - TortoiseGit
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"
76 #if 0
79 #include "CopyCommand.h"
80 #include "CrashCommand.h"
86 #include "PropertiesCommand.h"
87 #include "RebuildIconCacheCommand.h"
88 #include "RemoveCommand.h"
90 #include "RepositoryBrowserCommand.h"
93 #include "RevertCommand.h"
94 #include "RTFMCommand.h"
96 #include "ShowCompareCommand.h"
98 #include "UnIgnoreCommand.h"
100 #endif
101 typedef enum
103 cmdAbout,
104 cmdAdd,
105 cmdBlame,
106 cmdBranch,
107 cmdCat,
108 cmdCleanup,
109 cmdClone,
110 cmdCommit,
111 cmdConflictEditor,
112 cmdCopy,
113 cmdCrash,
114 cmdDiff,
115 cmdDropCopy,
116 cmdDropCopyAdd,
117 cmdDropMove,
118 cmdFetch,
119 cmdFormatPatch,
120 cmdExport,
121 cmdHelp,
122 cmdIgnore,
123 cmdImportPatch,
124 cmdLog,
125 cmdMerge,
126 cmdPasteCopy,
127 cmdPasteMove,
128 cmdPrevDiff,
129 cmdProperties,
130 cmdPull,
131 cmdPush,
132 cmdRTFM,
133 cmdRebuildIconCache,
134 cmdRemove,
135 cmdRebase,
136 cmdRename,
137 cmdRepoCreate,
138 cmdRepoStatus,
139 cmdResolve,
140 cmdRevert,
141 cmdSendMail,
142 cmdSettings,
143 cmdShowCompare,
144 cmdSwitch,
145 cmdTag,
146 cmdUnIgnore,
147 cmdUpdateCheck,
148 cmdStashSave,
149 cmdStashApply,
150 cmdStashPop,
151 cmdStashList,
152 cmdSubAdd,
153 cmdSubUpdate,
154 cmdSubSync,
155 cmdRefLog,
156 cmdRefBrowse,
157 cmdSVNDCommit,
158 cmdSVNRebase,
159 cmdSVNFetch,
160 cmdSVNIgnore,
161 cmdSync,
162 cmdRequestPull,
163 cmdBisect
164 } TGitCommand;
166 static const struct CommandInfo
168 TGitCommand command;
169 LPCTSTR pCommandName;
170 } commandInfo[] =
172 { cmdAbout, _T("about") },
173 { cmdAdd, _T("add") },
174 { cmdBlame, _T("blame") },
175 { cmdBranch, _T("branch") },
176 { cmdCat, _T("cat") },
177 { cmdCleanup, _T("cleanup") },
178 { cmdClone, _T("clone") },
179 { cmdCommit, _T("commit") },
180 { cmdConflictEditor, _T("conflicteditor") },
181 { cmdCopy, _T("copy") },
182 { cmdCrash, _T("crash") },
183 { cmdDiff, _T("diff") },
184 { cmdDropCopy, _T("dropcopy") },
185 { cmdDropCopyAdd, _T("dropcopyadd") },
186 { cmdDropMove, _T("dropmove") },
187 { cmdFetch, _T("fetch") },
188 { cmdFormatPatch, _T("formatpatch") },
189 { cmdExport, _T("export") },
190 { cmdHelp, _T("help") },
191 { cmdIgnore, _T("ignore") },
192 { cmdImportPatch, _T("importpatch") },
193 { cmdLog, _T("log") },
194 { cmdMerge, _T("merge") },
195 { cmdPasteCopy, _T("pastecopy") },
196 { cmdPasteMove, _T("pastemove") },
197 { cmdPrevDiff, _T("prevdiff") },
198 { cmdProperties, _T("properties") },
199 { cmdPull, _T("pull") },
200 { cmdPush, _T("push") },
201 { cmdRTFM, _T("rtfm") },
202 { cmdRebuildIconCache,_T("rebuildiconcache") },
203 { cmdRemove, _T("remove") },
204 { cmdRebase, _T("rebase") },
205 { cmdRename, _T("rename") },
206 { cmdRepoCreate, _T("repocreate") },
207 { cmdRepoStatus, _T("repostatus") },
208 { cmdResolve, _T("resolve") },
209 { cmdRevert, _T("revert") },
210 { cmdSendMail, _T("sendmail") },
211 { cmdSettings, _T("settings") },
212 { cmdShowCompare, _T("showcompare") },
213 { cmdSwitch, _T("switch") },
214 { cmdTag, _T("tag") },
215 { cmdUnIgnore, _T("unignore") },
216 { cmdUpdateCheck, _T("updatecheck") },
217 { cmdStashSave, _T("stashsave") },
218 { cmdStashApply, _T("stashapply") },
219 { cmdStashPop, _T("stashpop") },
220 { cmdStashList, _T("stashlist") },
221 { cmdSubAdd, _T("subadd") },
222 { cmdSubUpdate, _T("subupdate") },
223 { cmdSubSync, _T("subsync") },
224 { cmdRefLog, _T("reflog") },
225 { cmdRefBrowse, _T("refbrowse") },
226 { cmdSVNDCommit, _T("svndcommit") },
227 { cmdSVNRebase, _T("svnrebase") },
228 { cmdSVNFetch, _T("svnfetch") },
229 { cmdSVNIgnore, _T("svnignore") },
230 { cmdSync, _T("sync") },
231 { cmdRequestPull, _T("requestpull") },
232 { cmdBisect, _T("bisect") },
236 Command * CommandServer::GetCommand(const CString& sCmd)
238 // Look up the command
239 TGitCommand command = cmdAbout; // Something harmless as a default
240 for (int nCommand = 0; nCommand < _countof(commandInfo); nCommand++)
242 if (sCmd.Compare(commandInfo[nCommand].pCommandName) == 0)
244 // We've found the command
245 command = commandInfo[nCommand].command;
246 // If this fires, you've let the enum get out of sync with the commandInfo array
247 ASSERT((int)command == nCommand);
248 break;
252 // CBrowseRefsDlg dialog
253 switch (command)
255 case cmdAbout:
256 return new AboutCommand;
257 case cmdCommit:
258 return new CommitCommand;
259 case cmdLog:
260 return new LogCommand;
261 case cmdRepoCreate:
262 return new CreateRepositoryCommand;
263 case cmdClone:
264 return new CloneCommand;
265 case cmdPrevDiff:
266 return new PrevDiffCommand;
267 case cmdDiff:
268 return new DiffCommand;
269 case cmdRename:
270 return new RenameCommand;
271 case cmdRepoStatus:
272 return new RepoStatusCommand;
273 case cmdRemove:
274 return new RemoveCommand;
275 case cmdRevert:
276 return new RevertCommand;
277 case cmdPull:
278 return new PullCommand;
279 case cmdFetch:
280 return new FetchCommand;
281 case cmdPush:
282 return new PushCommand;
283 case cmdBranch:
284 return new BranchCommand;
285 case cmdTag:
286 return new TagCommand;
287 case cmdMerge:
288 return new MergeCommand;
289 case cmdSwitch:
290 return new SwitchCommand;
291 case cmdExport:
292 return new ExportCommand;
293 case cmdAdd:
294 return new AddCommand;
295 case cmdIgnore:
296 return new IgnoreCommand;
297 case cmdFormatPatch:
298 return new FormatPatchCommand;
299 case cmdImportPatch:
300 return new ImportPatchCommand;
301 case cmdBlame:
302 return new BlameCommand;
303 case cmdSettings:
304 return new SettingsCommand;
305 case cmdConflictEditor:
306 return new ConflictEditorCommand;
307 case cmdCleanup:
308 return new CleanupCommand;
309 case cmdRebase:
310 return new RebaseCommand;
311 case cmdResolve:
312 return new ResolveCommand;
313 case cmdDropMove:
314 return new DropMoveCommand;
315 case cmdDropCopy:
316 return new DropCopyCommand;
317 case cmdDropCopyAdd:
318 return new DropCopyAddCommand;
319 case cmdHelp:
320 return new HelpCommand;
321 case cmdStashSave:
322 return new StashSaveCommand;
323 case cmdStashApply:
324 return new StashApplyCommand;
325 case cmdStashPop:
326 return new StashPopCommand;
327 case cmdSubAdd:
328 return new SubmoduleAddCommand;
329 case cmdSubUpdate:
330 return new SubmoduleUpdateCommand;
331 case cmdRefLog:
332 return new RefLogCommand;
333 case cmdSubSync:
334 return new SubmoduleSyncCommand;
335 case cmdSendMail:
336 return new SendMailCommand;
337 case cmdCat:
338 return new CatCommand;
339 case cmdRefBrowse:
340 return new RefBrowseCommand;
341 case cmdSVNDCommit:
342 return new SVNDCommitCommand;
343 case cmdSVNRebase:
344 return new SVNRebaseCommand;
345 case cmdSVNFetch:
346 return new SVNFetchCommand;
347 case cmdSync:
348 return new SyncCommand;
349 case cmdRequestPull:
350 return new RequestPullCommand;
351 case cmdUpdateCheck:
352 return new UpdateCheckCommand;
353 case cmdPasteCopy:
354 return new PasteCopyCommand;
355 case cmdPasteMove:
356 return new PasteMoveCommand;
357 case cmdSVNIgnore:
358 return new SVNIgnoreCommand;
359 case cmdBisect:
360 return new BisectCommand;
362 #if 0
366 case cmdCopy:
367 return new CopyCommand;
368 case cmdCrash:
369 return new CrashCommand;
373 case cmdPrevDiff:
374 return new PrevDiffCommand;
375 case cmdProperties:
376 return new PropertiesCommand;
377 case cmdRTFM:
378 return new RTFMCommand;
379 case cmdRebuildIconCache:
380 return new RebuildIconCacheCommand;
381 case cmdShowCompare:
382 return new ShowCompareCommand;
383 case cmdUnIgnore:
384 return new UnIgnoreCommand;
385 #endif
386 default:
387 CMessageBox::Show(hWndExplorer, _T("Command not implemented"), _T("TortoiseGit"), MB_ICONERROR);
388 return new AboutCommand;