]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1_file.c
alternates: provide helper for adding to alternates list
[thirdparty/git.git] / sha1_file.c
index 3d8c1e88a53e23d8c6b93f1b8b915adf15b43ecd..7a3b74544803fb151b44fe76eab4b95b2ccaaa2c 100644 (file)
@@ -440,6 +440,17 @@ void add_to_alternates_file(const char *reference)
        free(alts);
 }
 
+void add_to_alternates_memory(const char *reference)
+{
+       /*
+        * Make sure alternates are initialized, or else our entry may be
+        * overwritten when they are.
+        */
+       prepare_alt_odb();
+
+       link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0);
+}
+
 /*
  * Compute the exact path an alternate is at and returns it. In case of
  * error NULL is returned and the human readable error is added to `err`