Make git_repository use shared update attr function.

RELNOTES: None
PiperOrigin-RevId: 226469670
diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl
index 4e9abda..daace56 100644
--- a/tools/build_defs/repo/git.bzl
+++ b/tools/build_defs/repo/git.bzl
@@ -13,7 +13,7 @@
 # limitations under the License.
 """Rules for cloning external git repositories."""
 
-load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "workspace_and_buildfile")
+load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "update_attrs", "workspace_and_buildfile")
 
 def _clone_or_update(ctx):
     if ((not ctx.attr.tag and not ctx.attr.commit and not ctx.attr.branch) or
@@ -117,15 +117,8 @@
         "rm -rf '{directory}'".format(directory = ctx.path(".git")),
     ])
 
-def _update_commit(orig, keys, override):
-    # Merge the override information into the dict, resulting by taking the
-    # given keys, as well as the name, from orig (if present there).
-    result = {}
-    for key in keys:
-        if getattr(orig, key) != None:
-            result[key] = getattr(orig, key)
-    result["name"] = orig.name
-    result.update(override)
+def _update_git_attrs(orig, keys, override):
+    result = update_attrs(orig, keys, override)
 
     # if we found the actual commit, remove all other means of specifying it,
     # like tag or branch.
@@ -164,13 +157,13 @@
     workspace_and_buildfile(ctx)
     patch(ctx)
     _remove_dot_git(ctx)
-    return _update_commit(ctx.attr, _new_git_repository_attrs.keys(), update)
+    return _update_git_attrs(ctx.attr, _new_git_repository_attrs.keys(), update)
 
 def _git_repository_implementation(ctx):
     update = _clone_or_update(ctx)
     patch(ctx)
     _remove_dot_git(ctx)
-    return _update_commit(ctx.attr, _common_attrs.keys(), update)
+    return _update_git_attrs(ctx.attr, _common_attrs.keys(), update)
 
 new_git_repository = repository_rule(
     implementation = _new_git_repository_implementation,