]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refs.c
Merge branch 'os/vcbuild'
[thirdparty/git.git] / refs.c
diff --git a/refs.c b/refs.c
index 6aa4893996076a4c104055e884df2f4720c85dbf..8374dfefa617a4a6c82acc4b2418ccae479c2b06 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -598,10 +598,14 @@ const char *git_default_branch_name(void)
  * to name a branch.
  */
 static char *substitute_branch_name(struct repository *r,
-                                   const char **string, int *len)
+                                   const char **string, int *len,
+                                   int nonfatal_dangling_mark)
 {
        struct strbuf buf = STRBUF_INIT;
-       int ret = repo_interpret_branch_name(r, *string, *len, &buf, 0);
+       struct interpret_branch_name_options options = {
+               .nonfatal_dangling_mark = nonfatal_dangling_mark
+       };
+       int ret = repo_interpret_branch_name(r, *string, *len, &buf, &options);
 
        if (ret == *len) {
                size_t size;
@@ -614,19 +618,15 @@ static char *substitute_branch_name(struct repository *r,
 }
 
 int repo_dwim_ref(struct repository *r, const char *str, int len,
-                 struct object_id *oid, char **ref)
+                 struct object_id *oid, char **ref, int nonfatal_dangling_mark)
 {
-       char *last_branch = substitute_branch_name(r, &str, &len);
+       char *last_branch = substitute_branch_name(r, &str, &len,
+                                                  nonfatal_dangling_mark);
        int   refs_found  = expand_ref(r, str, len, oid, ref);
        free(last_branch);
        return refs_found;
 }
 
-int dwim_ref(const char *str, int len, struct object_id *oid, char **ref)
-{
-       return repo_dwim_ref(the_repository, str, len, oid, ref);
-}
-
 int expand_ref(struct repository *repo, const char *str, int len,
               struct object_id *oid, char **ref)
 {
@@ -665,7 +665,7 @@ int repo_dwim_log(struct repository *r, const char *str, int len,
                  struct object_id *oid, char **log)
 {
        struct ref_store *refs = get_main_ref_store(r);
-       char *last_branch = substitute_branch_name(r, &str, &len);
+       char *last_branch = substitute_branch_name(r, &str, &len, 0);
        const char **p;
        int logs_found = 0;
        struct strbuf path = STRBUF_INIT;
@@ -1950,24 +1950,17 @@ int ref_update_reject_duplicates(struct string_list *refnames,
        return 0;
 }
 
-static const char hook_not_found;
-static const char *hook;
-
 static int run_transaction_hook(struct ref_transaction *transaction,
                                const char *state)
 {
        struct child_process proc = CHILD_PROCESS_INIT;
        struct strbuf buf = STRBUF_INIT;
+       const char *hook;
        int ret = 0, i;
 
-       if (hook == &hook_not_found)
-               return ret;
+       hook = find_hook("reference-transaction");
        if (!hook)
-               hook = xstrdup_or_null(find_hook("reference-transaction"));
-       if (!hook) {
-               hook = &hook_not_found;
                return ret;
-       }
 
        strvec_pushl(&proc.args, hook, state, NULL);
        proc.in = -1;