Add force option
[vng.git] / Remove.cpp
blobdabd6970b751435a083e257afe6a70a8f47abb55
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
4 * Copyright (C) 2002-2004 David Roundy
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (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, see <http://www.gnu.org/licenses/>.
20 #include "Remove.h"
21 #include "CommandLineParser.h"
22 #include "GitRunner.h"
24 Remove::Remove()
25 : AbstractCommand("remove")
27 CommandLineParser::setArgumentDefinition("rename <FILE or DIRECTORY>" );
30 AbstractCommand::ReturnCodes Remove::run()
32 if (! checkInRepository())
33 return NotInRepo;
34 moveToRoot();
35 // all we need to do is tell gits index that the file is deleted.
36 // easiest way to do that is to call update-index --remove --force-remove [file]
38 if (dryRun())
39 return Ok;
41 QProcess git;
42 QStringList arguments;
43 arguments << "update-index" << "--remove" << "--force-remove";
44 arguments += rebasedArguments();
45 GitRunner runner(git, arguments);
46 return runner.start(GitRunner::WaitUntilFinished);
49 QString Remove::argumentDescription() const
51 return "<FILE or DIRECTORY>";
54 QString Remove::commandDescription() const
56 return "Remove should be called when you want to remove a file from your project,\n"
57 "but don't actually want to delete the file. Otherwise just delete the\n"
58 "file or directory, and vng will notice that it has been removed.\n"
59 "Be aware that the file WILL be deleted from any other copy of the\n"
60 "repository to which you later apply the patch.\n";