mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Prevent NPE if trying to restore an already restored deleted branch (#21940)
If a deleted-branch has already been restored, a request to restore it again will cause a NPE. This PR adds detection for this case, but also disables buttons when they're clicked in order to help prevent accidental repeat requests. Fix #21930 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		@@ -126,6 +126,10 @@ func RestoreBranchPost(ctx *context.Context) {
 | 
			
		||||
		log.Error("GetDeletedBranchByID: %v", err)
 | 
			
		||||
		ctx.Flash.Error(ctx.Tr("repo.branch.restore_failed", branchName))
 | 
			
		||||
		return
 | 
			
		||||
	} else if deletedBranch == nil {
 | 
			
		||||
		log.Debug("RestoreBranch: Can't restore branch[%d] '%s', as it does not exist", branchID, branchName)
 | 
			
		||||
		ctx.Flash.Error(ctx.Tr("repo.branch.restore_failed", branchName))
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := git.Push(ctx, ctx.Repo.Repository.RepoPath(), git.PushOptions{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user