From b620d43b4848cda7bbab965bb3a3648fa32bf0dd Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 1 Aug 2012 00:03:16 +0200 Subject: [PATCH] Add context menu entries to toggle assume-valid flag Signed-off-by: Sven Strickroth --- src/TortoiseProc/Commands/AssumeValidCommand.h | 54 ++++++++++++++++++++++++++ src/TortoiseProc/Commands/Command.cpp | 5 +++ src/TortoiseProc/TortoiseProc.vcproj | 8 ++++ src/TortoiseShell/ContextMenu.cpp | 18 +++++++++ src/TortoiseShell/Globals.h | 3 ++ src/TortoiseShell/MenuInfo.cpp | 6 +++ src/TortoiseShell/MenuInfo.h | 2 + src/TortoiseShell/resource.h | 4 ++ src/TortoiseShell/resourceshell.rc | 29 ++++++++------ 9 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 src/TortoiseProc/Commands/AssumeValidCommand.h diff --git a/src/TortoiseProc/Commands/AssumeValidCommand.h b/src/TortoiseProc/Commands/AssumeValidCommand.h new file mode 100644 index 000000000..df7078342 --- /dev/null +++ b/src/TortoiseProc/Commands/AssumeValidCommand.h @@ -0,0 +1,54 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2012 - TortoiseGit + +// 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 the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#pragma once +#include "Command.h" + +/** + * \ingroup TortoiseProc + * crashes the application to test the crash handler. + */ +class AssumeValidCommand : public Command +{ +public: + /** + * Executes the command. + */ + virtual bool Execute() + { + CString cmdTemplate; + if (parser.HasKey(_T("unset"))) + { + cmdTemplate = _T("git.exe update-index --no-assume-unchanged \"%s\""); + } + else + { + cmdTemplate = _T("git.exe update-index --assume-unchanged \"%s\""); + } + for (int i = 0; i < pathList.GetCount(); i++) + { + CString cmd, output; + cmd.Format(cmdTemplate, pathList[i].GetGitPathString()); + if (g_Git.Run(cmd, &output, CP_UTF8)) + { + MessageBox(NULL, output, _T("TortoiseGit"), MB_ICONERROR); + } + } + return true; + } +}; diff --git a/src/TortoiseProc/Commands/Command.cpp b/src/TortoiseProc/Commands/Command.cpp index e490db1c6..e10b017cd 100644 --- a/src/TortoiseProc/Commands/Command.cpp +++ b/src/TortoiseProc/Commands/Command.cpp @@ -73,6 +73,7 @@ #include "SVNIgnoreCommand.h" #include "BisectCommand.h" #include "RepositoryBrowserCommand.h" +#include "AssumeValidCommand.h" #if 0 @@ -162,6 +163,7 @@ typedef enum cmdRequestPull, cmdBisect, cmdRepoBrowser, + cmdAssumeValid, } TGitCommand; static const struct CommandInfo @@ -232,6 +234,7 @@ static const struct CommandInfo { cmdRequestPull, _T("requestpull") }, { cmdBisect, _T("bisect") }, { cmdRepoBrowser, _T("repobrowser") }, + { cmdAssumeValid, _T("assumevalid") }, }; @@ -362,6 +365,8 @@ Command * CommandServer::GetCommand(const CString& sCmd) return new BisectCommand; case cmdRepoBrowser: return new RepositoryBrowserCommand; + case cmdAssumeValid: + return new AssumeValidCommand; #if 0 diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index cfff29f77..7001858ee 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -2189,6 +2189,14 @@ > + + + + entry)&&(stat.status->entry->uuid)) // uuidSource = CUnicodeUtils::StdGetUnicode(stat.status->entry->uuid); + if (stat.status->assumeValid) + itemStates |= ITEMIS_ASSUMEVALID; } else { @@ -256,6 +258,8 @@ STDMETHODIMP CShellExt::Initialize_Wrap(LPCITEMIDLIST pIDFolder, //} //if ((stat.status->entry)&&(stat.status->entry->uuid)) // uuidSource = CUnicodeUtils::StdGetUnicode(stat.status->entry->uuid); + if (stat.status->assumeValid) + itemStates |= ITEMIS_ASSUMEVALID; } else { @@ -1670,6 +1674,20 @@ STDMETHODIMP CShellExt::InvokeCommand_Wrap(LPCMINVOKECOMMANDINFO lpcmi) gitCmd += folder_; gitCmd += _T("\""); break; + case ShellMenuAssumeValid: + tempfile = WriteFileListToTempFile(); + gitCmd += _T("assumevalid /pathfile:\""); + gitCmd += tempfile; + gitCmd += _T("\""); + gitCmd += _T(" /deletepathfile"); + break; + case ShellMenuNoAssumeValid: + tempfile = WriteFileListToTempFile(); + gitCmd += _T("assumevalid /pathfile:\""); + gitCmd += tempfile; + gitCmd += _T("\""); + gitCmd += _T(" /deletepathfile /unset"); + break; case ShellMenuShowChanged: if (files_.size() > 1) { diff --git a/src/TortoiseShell/Globals.h b/src/TortoiseShell/Globals.h index 7f2432931..146c4fe11 100644 --- a/src/TortoiseShell/Globals.h +++ b/src/TortoiseShell/Globals.h @@ -72,6 +72,8 @@ #define MENUBISECTBAD 0x0020000000000000 #define MENUBISECTRESET 0x0040000000000000 #define MENUSVNFETCH 0x0080000000000000 +#define MENUASSUMEVALID 0x0100000000000000 +#define MENUNOASSUMEVALID 0x0200000000000000 #define MENUSETTINGS 0x2000000000000000 #define MENUHELP 0x4000000000000000 @@ -121,3 +123,4 @@ enum FileState #define ITEMIS_WCROOT 0x00200000 #define ITEMIS_BISECT 0x00400000 #define ITEMIS_BAREREPO 0x00800000 +#define ITEMIS_ASSUMEVALID 0x01000000 diff --git a/src/TortoiseShell/MenuInfo.cpp b/src/TortoiseShell/MenuInfo.cpp index 031541388..ba461ecda 100644 --- a/src/TortoiseShell/MenuInfo.cpp +++ b/src/TortoiseShell/MenuInfo.cpp @@ -134,6 +134,12 @@ MenuInfo menuInfo[] = { ShellMenuRevert, MENUREVERT, IDI_REVERT, IDS_MENUREVERT, IDS_MENUDESCREVERT, ITEMIS_INGIT, ITEMIS_NORMAL, ITEMIS_FOLDERINGIT, 0, 0, 0, 0, 0 }, + { ShellMenuAssumeValid, MENUASSUMEVALID, 0, IDS_MENUASSUMEVALID, IDS_MENUDESCASSUMEVALID, + ITEMIS_INGIT, ITEMIS_NORMAL | ITEMIS_DELETED | ITEMIS_FOLDER | ITEMIS_ASSUMEVALID, 0, 0, 0, 0, 0, 0 }, + + { ShellMenuNoAssumeValid, MENUNOASSUMEVALID, 0, IDS_MENUNOASSUMEVALID, IDS_MENUDESCNOASSUMEVALID, + ITEMIS_ASSUMEVALID, 0, 0, 0, 0, 0, 0, 0 }, + { ShellMenuCleanup, MENUCLEANUP, IDI_CLEANUP, IDS_MENUCLEANUP, IDS_MENUDESCCLEANUP, ITEMIS_FOLDERINGIT|ITEMIS_FOLDER, 0, 0, 0, 0, 0, 0, 0 }, diff --git a/src/TortoiseShell/MenuInfo.h b/src/TortoiseShell/MenuInfo.h index aa5598c4b..7ac6de7fc 100644 --- a/src/TortoiseShell/MenuInfo.h +++ b/src/TortoiseShell/MenuInfo.h @@ -84,6 +84,8 @@ enum GitCommands ShellMenuBisectBad, ShellMenuBisectReset, ShellMenuRepoBrowse, + ShellMenuAssumeValid, + ShellMenuNoAssumeValid, ShellMenuLastEntry // used to mark the menu array end }; diff --git a/src/TortoiseShell/resource.h b/src/TortoiseShell/resource.h index f03a77f45..b448a054c 100644 --- a/src/TortoiseShell/resource.h +++ b/src/TortoiseShell/resource.h @@ -53,6 +53,7 @@ #define IDS_MENUDESCSWITCH 143 #define IDI_SHOWCHANGED 143 #define IDI_IGNORE 144 +#define IDS_MENUASSUMEVALID 144 #define IDS_MENUDESCEXPORT 145 #define IDS_MENUDESCABOUT 146 #define IDS_MENUDESCCREATEREPOS 147 @@ -120,10 +121,13 @@ #define IDS_MENUDESCCREATEPATCH 208 #define IDS_MENUDESCAPPLYPATCH 209 #define IDS_MENUDESCSVNFETCH 210 +#define IDS_MENUDESCASSUMEVALID 211 #define IDS_MENUUNDOADD 212 #define IDS_MENUDESCUNDOADD 213 #define IDS_MENUPREVDIFF 214 #define IDS_MENUDESCPREVDIFF 215 +#define IDS_MENUNOASSUMEVALID 216 +#define IDS_MENUDESCNOASSUMEVALID 217 #define IDS_DROPEXPORTMENU 218 #define IDS_DROPEXPORTEXTENDEDMENU 219 #define IDS_MENUIGNOREMULTIPLEMASK 220 diff --git a/src/TortoiseShell/resourceshell.rc b/src/TortoiseShell/resourceshell.rc index 9b87401e3..276da0ca5 100644 --- a/src/TortoiseShell/resourceshell.rc +++ b/src/TortoiseShell/resourceshell.rc @@ -223,6 +223,7 @@ END STRINGTABLE BEGIN + IDS_MENUASSUMEVALID "Assume Unchanged" IDS_MENUDESCEXPORT "Exports a revision to a zip file" IDS_MENUDESCABOUT "Shows information about TortoiseGit" IDS_MENUDESCCREATEREPOS "Creates a repository database at the current location" @@ -322,8 +323,6 @@ BEGIN IDS_SETPROPTITLE "Setting properties..." IDS_MENUDESCBISECTBAD "Marks revision as bad" IDS_MENUDESCBISECTRESET "Stops bisect mode" - IDS_MENUREPOBROWSE "&Repo-browser" - IDS_MENUDESCREPOBROWSE "Opens the repository browser" IDS_MENUBLAME "&Blame" IDS_STATUSEXTERNAL "external" IDS_MENUDESCBLAME "Blames each line of a file on an author" @@ -333,6 +332,18 @@ END STRINGTABLE BEGIN + IDS_MENUCLIPPASTE "&Paste" + IDS_MENUDESCCLIPPASTE "Pastes the svn path from the clipboard, resulting in a move (cut) or copy operation" + IDS_MENUREPOBROWSE "&Repo-browser" + IDS_MENUDESCREPOBROWSE "Opens the repository browser" + IDS_ERR_PROPNOTONFILE "This property is only allowed on folders, not files." + IDS_MENUIGNOREMULTIPLE "&Ignore %d items by name" + IDS_MENUUNIGNORE "Remove from &ignore list" + IDS_MENUDESCUNIGNORE "Removes the file or filemask from the list of ignored items" +END + +STRINGTABLE +BEGIN IDS_MENUDIFF "&Diff" IDS_MENUDESCDIFF "Compares the file with the last committed revision to show you the changes you made" IDS_DROPCOPYADDMENU "Git Copy and add files to this WC" @@ -356,10 +367,13 @@ BEGIN IDS_MENUDESCCREATEPATCH "Creates a unified diff file with all changes you made" IDS_MENUDESCAPPLYPATCH "Review/apply a unified diff file with TortoiseMerge" IDS_MENUDESCSVNFETCH "Fetch from SVN repository" + IDS_MENUDESCASSUMEVALID "Sets the Assume Valid flag for this file" IDS_MENUUNDOADD "Undo Add..." IDS_MENUDESCUNDOADD "Reverts an addition to version control" IDS_MENUPREVDIFF "&Diff with previous version" IDS_MENUDESCPREVDIFF "Diffs the working tree file with the one before the last commit" + IDS_MENUNOASSUMEVALID "No Assume Unchanged" + IDS_MENUDESCNOASSUMEVALID "Unsets the Assume Valid flag for this file" IDS_DROPEXPORTMENU "Git Export versioned items here" IDS_DROPEXPORTEXTENDEDMENU "Git Export all items here" IDS_MENUIGNOREMULTIPLEMASK "Ignore %d items by &extension" @@ -379,16 +393,6 @@ END STRINGTABLE BEGIN - IDS_MENUCLIPPASTE "&Paste" - IDS_MENUDESCCLIPPASTE "Pastes the svn path from the clipboard, resulting in a move (cut) or copy operation" - IDS_ERR_PROPNOTONFILE "This property is only allowed on folders, not files." - IDS_MENUIGNOREMULTIPLE "&Ignore %d items by name" - IDS_MENUUNIGNORE "Remove from &ignore list" - IDS_MENUDESCUNIGNORE "Removes the file or filemask from the list of ignored items" -END - -STRINGTABLE -BEGIN IDS_DROPMOVERENAMEMENU "Git Move and rename versioned item here" IDS_MENUREMOVEKEEP "&Delete (keep local)" END @@ -434,3 +438,4 @@ LANGUAGE 9, 1 ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + -- 2.11.4.GIT