From 5f6a681c85ac35c26228610db576f3bb252a0910 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 20 Jul 2009 23:40:33 +0300 Subject: [PATCH] Make 'revert' clean up after itself correctly in case of added/renamed files. --- src/commands/Revert.cpp | 19 ++++++++++++++++++- todo | 3 +-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/commands/Revert.cpp b/src/commands/Revert.cpp index 012bced..4a1ca17 100644 --- a/src/commands/Revert.cpp +++ b/src/commands/Revert.cpp @@ -1,6 +1,6 @@ /* * This file is part of the vng project - * Copyright (C) 2008 Thomas Zander + * Copyright (C) 2008-2009 Thomas Zander * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +95,23 @@ AbstractCommand::ReturnCodes Revert::run() outFile.remove(); return rc; } + + arguments.clear(); + arguments << QLatin1String("update-index") << QLatin1String("--add"); + for (int i = 0; i < changeSet.count(); ++i) { + File file = changeSet.file(i); + if ((all || file.renameAcceptance() == Vng::Accepted) + && file.oldFileName() != file.fileName()) { + if (!file.oldFileName().isEmpty()) + arguments << file.oldFileName(); + } else if (all || file.changesAcceptance() == Vng::Accepted) { + arguments << file.fileName(); + } + } + if (arguments.count() > 2) { + runner.setArguments(arguments); + runner.start(GitRunner::WaitUntilFinished); + } } Logger::warn() << "Finished reverting." << endl; diff --git a/todo b/todo index a4c7321..0b3bee7 100644 --- a/todo +++ b/todo @@ -29,8 +29,7 @@ Missing features; * Make the --debug option only available when compiling as debug-build Bugs -* Also show / store file permissions in the diff and thus in revert -* After a revert, and the file ends up with no changes, we should do an update-index on it. +unrevert doesn't work for file renames/adds use git-read-tree --reset HEAD and git-update-index --refresh to implement 'check' use 'prune' and 'pack' to implement optimize. -- 2.11.4.GIT