1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2020-2021 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "DiffLinesForStaging.h"
22 enum class StagingType
30 class StagingOperations
33 StagingOperations(const CDiffLinesForStaging
* lines
)
37 std::string
CreatePatchBufferToStageOrUnstageSelectedHunks() const;
38 std::string
CreatePatchBufferToStageOrUnstageSelectedLines(StagingType stagingType
) const;
39 static CString
WritePatchBufferToTemporaryFile(const std::string
& data
);
42 const CDiffLinesForStaging
* m_lines
;
43 bool IsWithinFileHeader(int line
) const;
44 int FindHunkStartBackwardsFrom(int line
, int topBoundaryLine
) const;
45 int FindHunkStartForwardsFrom(int line
, int bottomBoundaryLine
) const;
46 int FindHunkEndForwardsFrom(int line
, int topBoundaryLine
) const;
47 int FindHunkEndGivenHunkStartAndCounts(int hunkStart
, int oldCount
, int newCount
) const;
48 std::string
FindFileHeaderBackwardsFrom(int line
) const;
49 #ifdef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
52 std::string
ChangeOldAndNewLinesCount(const std::string
& strHunkStart
, int oldCount
, int newCount
) const;
55 bool ParseHunkOnEitherSelectionBoundary(std::string
& hunkWithoutStartLine
, int hunkStartLine
, int hunkLastLine
, int firstLineSelected
, int lastLineSelected
, int* oldCount
, int* newCount
, StagingType stagingType
) const;