1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2013-2014 - 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 "GitProgressList.h"
21 #include "../TortoiseShell/resource.h"
24 class RemoteProgressCommand
: public ProgressCommand
31 static int RemoteProgressCallback(const char* str
, int len
, void* data
)
33 ((CGitProgressList
*)data
)->SetProgressLabelText(CUnicodeUtils::GetUnicode(CStringA(str
, len
)));
36 static int RemoteCompletionCallback(git_remote_completion_type
/*type*/, void* /*data*/)
38 // this method is unused by libgit2 so far
39 // TODO: "m_pAnimate->Stop();" and "m_pAnimate->ShowWindow(SW_HIDE);", cleanup possible in GitProgressList::Notify
42 static int RemoteUpdatetipsCallback(const char* refname
, const git_oid
* oldOid
, const git_oid
* newOid
, void* data
)
44 ((CGitProgressList
*)data
)->AddNotify(new RefUpdateNotificationData(refname
, oldOid
, newOid
));
48 class RefUpdateNotificationData
: public CGitProgressList::NotificationData
51 RefUpdateNotificationData(const char* refname
, const git_oid
* oldOid
, const git_oid
* newOid
)
54 CString str
= CUnicodeUtils::GetUnicode(refname
);
55 m_NewHash
= newOid
->id
;
56 m_OldHash
= oldOid
->id
;
57 sActionColumnText
.LoadString(IDS_GITACTION_UPDATE_REF
);
58 sPathColumnText
.Format(_T("%s\t %s -> %s"), str
, m_OldHash
.ToString().Left(g_Git
.GetShortHASHLength()), m_NewHash
.ToString().Left(g_Git
.GetShortHASHLength()));
60 virtual void GetContextMenu(CIconMenu
& popup
, CGitProgressList::ContextMenuActionList
& actions
)
62 actions
.push_back([&]()
64 CString cmd
= _T("/command:log");
65 cmd
+= _T(" /path:\"") + g_Git
.m_CurrentDir
+ _T("\"");
66 if (!m_OldHash
.IsEmpty())
67 cmd
+= _T(" /startrev:") + m_OldHash
.ToString();
68 if (!m_NewHash
.IsEmpty())
69 cmd
+= _T(" /endrev:") + m_NewHash
.ToString();
70 CAppUtils::RunTortoiseGitProc(cmd
);
72 popup
.AppendMenuIcon(actions
.size(), IDS_MENULOG
, IDI_LOG
);
80 void SetUrl(const CString
& url
) { m_url
.SetFromUnknown(url
); }
81 void SetRefSpec(CString spec
){ m_RefSpec
= spec
; }
82 void SetRemote(const CString
& remote
) { m_remote
= remote
; }
87 CAnimateCtrl
* m_pAnimate
;
90 CSmartAnimation(CAnimateCtrl
* pAnimate
)
92 m_pAnimate
= pAnimate
;
95 m_pAnimate
->ShowWindow(SW_SHOW
);
96 m_pAnimate
->Play(0, INT_MAX
, INT_MAX
);
104 m_pAnimate
->ShowWindow(SW_HIDE
);