shithub: furgit

Download patch

ref: 31f6ea6809c04599e2016565eee0e8ae255331c3
parent: 7d819fea3d26714261f06314f41159ad76bf991a
author: Runxi Yu <runxiyu@umich.edu>
date: Mon Mar 30 16:01:38 EDT 2026

network/receivepack/service: Some cleanups

--- a/network/receivepack/service/apply.go
+++ b/network/receivepack/service/apply.go
@@ -127,7 +127,7 @@
 	return CommandResult{
 		Name:    command.Name,
 		RefName: command.Name,
-		OldID:   objectIDPointer(command.OldID),
-		NewID:   objectIDPointer(command.NewID),
+		OldID:   new(command.OldID),
+		NewID:   new(command.NewID),
 	}
 }
--- a/network/receivepack/service/command.go
+++ b/network/receivepack/service/command.go
@@ -15,8 +15,8 @@
 			Name:    command.Name,
 			Error:   errText,
 			RefName: command.Name,
-			OldID:   objectIDPointer(command.OldID),
-			NewID:   objectIDPointer(command.NewID),
+			OldID:   new(command.OldID),
+			NewID:   new(command.NewID),
 		})
 	}
 }
@@ -23,10 +23,4 @@
 
 func isDelete(command Command) bool {
 	return command.NewID == command.NewID.Algorithm().Zero()
-}
-
-func objectIDPointer(id objectid.ObjectID) *objectid.ObjectID {
-	out := id
-
-	return &out
 }
--- a/network/receivepack/service/hook_apply.go
+++ b/network/receivepack/service/hook_apply.go
@@ -1,18 +1,5 @@
 package service
 
-func buildHookUpdates(commands []Command) []RefUpdate {
-	updates := make([]RefUpdate, 0, len(commands))
-	for _, command := range commands {
-		updates = append(updates, RefUpdate{
-			Name:  command.Name,
-			OldID: command.OldID,
-			NewID: command.NewID,
-		})
-	}
-
-	return updates
-}
-
 func resultForHookRejection(command Command, message string) CommandResult {
 	result := successCommandResult(command)
 	result.Error = message
--- a/network/receivepack/service/run_hook.go
+++ b/network/receivepack/service/run_hook.go
@@ -33,12 +33,21 @@
 
 	utils.BestEffortFprintf(service.opts.Progress, "running hooks...\r")
 
+	updates := make([]RefUpdate, 0, len(commands))
+	for _, command := range commands {
+		updates = append(updates, RefUpdate{
+			Name:  command.Name,
+			OldID: command.OldID,
+			NewID: command.NewID,
+		})
+	}
+
 	decisions, err := service.opts.Hook(ctx, HookRequest{
 		Refs:               service.opts.Refs,
 		ExistingObjects:    service.opts.ExistingObjects,
 		QuarantinedObjects: quarantinedObjects,
 		CommitGraph:        service.opts.CommitGraph,
-		Updates:            buildHookUpdates(commands),
+		Updates:            updates,
 		PushOptions:        append([]string(nil), req.PushOptions...),
 		IO:                 service.opts.HookIO,
 	})
--