@@ -512,7 +512,10 @@ func CreateOrUpdateFile(ctx context.Context, t *TemporaryUploadRepository, file
512512 case "create" , "update" :
513513 objectHash , lfsPointer , err = createOrUpdateFile (ctx , t , file , hasOldBranch )
514514 case "rename" :
515- objectHash , lfsPointer , err = renameFile (ctx , t , oldEntry , file , hasOldBranch )
515+ objectHash , lfsPointer , err = renameFile (ctx , t , oldEntry , file )
516+ }
517+ if err != nil {
518+ return err
516519 }
517520
518521 // Add the object to the index
@@ -595,8 +598,8 @@ func createOrUpdateFile(ctx context.Context, t *TemporaryUploadRepository, file
595598 return objectHash , lfsPointer , nil
596599}
597600
598- func renameFile (ctx context.Context , t * TemporaryUploadRepository , oldEntry * git.TreeEntry , file * ChangeRepoFile , hasOldBranch bool ) (string , * lfs.Pointer , error ) {
599- if setting .LFS .StartServer && hasOldBranch {
601+ func renameFile (ctx context.Context , t * TemporaryUploadRepository , oldEntry * git.TreeEntry , file * ChangeRepoFile ) (string , * lfs.Pointer , error ) {
602+ if setting .LFS .StartServer {
600603 attributesMap , err := attribute .CheckAttributes (ctx , t .gitRepo , "" /* use temp repo's working dir */ , attribute.CheckAttributeOpts {
601604 Attributes : []string {attribute .Filter },
602605 Filenames : []string {file .Options .treePath , file .Options .fromTreePath },
@@ -608,7 +611,7 @@ func renameFile(ctx context.Context, t *TemporaryUploadRepository, oldEntry *git
608611 oldIsLfs := attributesMap [file .Options .fromTreePath ] != nil && attributesMap [file .Options .fromTreePath ].Get (attribute .Filter ).ToString ().Value () == "lfs"
609612 newIsLfs := attributesMap [file .Options .treePath ] != nil && attributesMap [file .Options .treePath ].Get (attribute .Filter ).ToString ().Value () == "lfs"
610613
611- // If the old and new path are both in lfs or both not in lfs, the object hash of the old file can be used directly
614+ // If the old and new paths are both in lfs or both not in lfs, the object hash of the old file can be used directly
612615 // as the object doesn't change
613616 if oldIsLfs == newIsLfs {
614617 return oldEntry .ID .String (), nil , nil
@@ -650,9 +653,9 @@ func renameFile(ctx context.Context, t *TemporaryUploadRepository, oldEntry *git
650653 return "" , nil , err
651654 }
652655 return objectID , lfsPointer , nil
653- } else {
654- return oldEntry .ID .String (), nil , nil
655656 }
657+
658+ return oldEntry .ID .String (), nil , nil
656659}
657660
658661// VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch
0 commit comments