• R/O
  • HTTP
  • SSH
  • HTTPS

TortoiseGitJp: Commit

TortoiseGit日本語言語ファイル作成


Commit MetaInfo

Revision1d27d14c46acd7d513538929c6ce58c722807077 (tree)
Time2009-06-10 06:10:34
AuthorJohan 't Hart <johanthart@gmai...>
CommiterJohan 't Hart

Log Message

BrowseRefs: Added option to delete remote branch

Change Summary

Incremental Difference

--- a/src/TortoiseProc/BrowseRefsDlg.cpp
+++ b/src/TortoiseProc/BrowseRefsDlg.cpp
@@ -391,14 +391,24 @@ bool CBrowseRefsDlg::ConfirmDeleteRef(CString completeRefName)
391391 CString csTitle;
392392
393393 UINT mbIcon=MB_ICONQUESTION;
394- csMessage=L"Are you sure you want to delete the ";
395- if(wcsncmp(completeRefName,L"refs/heads",10)==0)
396- {
397- CString branchToDelete = completeRefName.Mid(11);
398- csTitle.Format(L"Confirm deletion of branch %s", branchToDelete);
399- csMessage += "branch:\r\n\r\n<b>";
394+ csMessage = L"Are you sure you want to delete the ";
395+
396+ bool bIsRemoteBranch = false;
397+ bool bIsBranch = false;
398+ if (wcsncmp(completeRefName, L"refs/remotes",12)==0) {bIsBranch = true; bIsRemoteBranch = true;}
399+ else if (wcsncmp(completeRefName, L"refs/heads",10)==0) {bIsBranch = true;}
400+
401+ if(bIsBranch)
402+ {
403+ CString branchToDelete = completeRefName.Mid(bIsRemoteBranch ? 13 : 11);
404+ csTitle.Format(L"Confirm deletion of %sbranch %s",
405+ bIsRemoteBranch? L"remote ": L"",
406+ branchToDelete);
407+ if(bIsRemoteBranch)
408+ csMessage += L"<ct=0x0000FF><i>remote</i></ct> ";
409+ csMessage += L"branch:\r\n\r\n<b>";
400410 csMessage += branchToDelete;
401- csMessage += "</b>";
411+ csMessage += L"</b>";
402412
403413 //Check if branch is fully merged in HEAD
404414 CString branchHash = g_Git.GetHash(completeRefName);
@@ -413,7 +423,12 @@ bool CBrowseRefsDlg::ConfirmDeleteRef(CString completeRefName)
413423 if(commonAncestor != branchHash)
414424 {
415425 csMessage += L"\r\n\r\n<b>Warning:\r\nThis branch is not fully merged into HEAD.</b>";
416- mbIcon=MB_ICONWARNING;
426+ mbIcon = MB_ICONWARNING;
427+ }
428+ if(bIsRemoteBranch)
429+ {
430+ csMessage += L"\r\n\r\n<b>Warning:\r\nThis action will remove the branch on the remote.</b>";
431+ mbIcon = MB_ICONWARNING;
417432 }
418433 }
419434 else if(wcsncmp(completeRefName,L"refs/tags",9)==0)
@@ -432,11 +447,26 @@ bool CBrowseRefsDlg::ConfirmDeleteRef(CString completeRefName)
432447
433448 bool CBrowseRefsDlg::DoDeleteRef(CString completeRefName, bool bForce)
434449 {
435- if(wcsncmp(completeRefName,L"refs/heads",10)==0)
450+ bool bIsRemoteBranch = false;
451+ bool bIsBranch = false;
452+ if (wcsncmp(completeRefName, L"refs/remotes",12)==0) {bIsBranch = true; bIsRemoteBranch = true;}
453+ else if (wcsncmp(completeRefName, L"refs/heads",10)==0) {bIsBranch = true;}
454+
455+ if(bIsBranch)
436456 {
437- CString branchToDelete = completeRefName.Mid(11);
457+ CString branchToDelete = completeRefName.Mid(bIsRemoteBranch ? 13 : 11);
438458 CString cmd;
439- cmd.Format(L"git.exe branch -%c %s",bForce?L'D':L'd',branchToDelete);
459+ if(bIsRemoteBranch)
460+ {
461+ int slash = branchToDelete.Find(L'/');
462+ if(slash < 0)
463+ return false;
464+ CString remoteName = branchToDelete.Left(slash);
465+ CString remoteBranchToDelete = branchToDelete.Mid(slash + 1);
466+ cmd.Format(L"git.exe push \"%s\" :%s", remoteName, remoteBranchToDelete);
467+ }
468+ else
469+ cmd.Format(L"git.exe branch -%c %s",bForce?L'D':L'd',branchToDelete);
440470 CString resultDummy;
441471 if(g_Git.Run(cmd,&resultDummy,CP_UTF8)!=0)
442472 {
@@ -519,6 +549,7 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh
519549 bool bShowReflogOption = false;
520550 bool bShowDeleteBranchOption = false;
521551 bool bShowDeleteTagOption = false;
552+ bool bShowDeleteRemoteBranchOption = false;
522553
523554 if(selectedLeafs[0]->IsFrom(L"refs/heads"))
524555 {
@@ -528,16 +559,18 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh
528559 else if(selectedLeafs[0]->IsFrom(L"refs/remotes"))
529560 {
530561 bShowReflogOption = true;
562+ bShowDeleteRemoteBranchOption = true;
531563 }
532564 else if(selectedLeafs[0]->IsFrom(L"refs/tags"))
533565 {
534566 bShowDeleteTagOption = true;
535567 }
536568
537- popupMenu.AppendMenuIcon(eCmd_ViewLog, L"Show Log", IDI_LOG);
538- if(bShowReflogOption) popupMenu.AppendMenuIcon(eCmd_ShowReflog, L"Show Reflog", IDI_LOG);
539- if(bShowDeleteTagOption) popupMenu.AppendMenuIcon(eCmd_DeleteTag, L"Delete Tag", IDI_DELETE);
540- if(bShowDeleteBranchOption) popupMenu.AppendMenuIcon(eCmd_DeleteBranch, L"Delete Branch", IDI_DELETE);
569+ popupMenu.AppendMenuIcon(eCmd_ViewLog, L"Show Log", IDI_LOG);
570+ if(bShowReflogOption) popupMenu.AppendMenuIcon(eCmd_ShowReflog, L"Show Reflog", IDI_LOG);
571+ if(bShowDeleteTagOption) popupMenu.AppendMenuIcon(eCmd_DeleteTag, L"Delete Tag", IDI_DELETE);
572+ if(bShowDeleteBranchOption) popupMenu.AppendMenuIcon(eCmd_DeleteBranch, L"Delete Branch", IDI_DELETE);
573+ if(bShowDeleteRemoteBranchOption) popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, L"Delete Remote Branch", IDI_DELETE);
541574
542575
543576
@@ -574,6 +607,7 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh
574607 }
575608 break;
576609 case eCmd_DeleteBranch:
610+ case eCmd_DeleteRemoteBranch:
577611 {
578612 if(ConfirmDeleteRef(selectedLeafs[0]->GetRefName()))
579613 DoDeleteRef(selectedLeafs[0]->GetRefName(), true);
--- a/src/TortoiseProc/BrowseRefsDlg.h
+++ b/src/TortoiseProc/BrowseRefsDlg.h
@@ -65,6 +65,7 @@ public:
6565 eCmd_CreateBranch,
6666 eCmd_CreateTag,
6767 eCmd_DeleteBranch,
68+ eCmd_DeleteRemoteBranch,
6869 eCmd_DeleteTag,
6970 eCmd_ShowReflog
7071 };
Show on old repository browser