update delete_ref(), update_ref() and ref_exists() to take a struct repository
cover update delete_ref(), update_ref() and ref_exists() to take a struct repository
The code handling pseudo refs such as BISECT_HEAD or CHERRY_PICK_HEAD assumes that they are files and uses unlink() and file_exists() on the corresponding paths rather than using the ref api. In repositories using reftable to store references this will not work. This patch series is a preparatory step that updates some reference functions to take a struct repository in preparation for converting code that handles pseudo refs to the ref api. The conversion will be handled by a separate series
These patches could each be split in two (thereby making the individual patches smaller) by changing the callers to pass the_repository first and then changing the call chain to pass a struct repository around if desired.
This series is based on master - 101b3204f3 ("The third batch", 2020-06-17). When merging into pu there are non-trivial conflicts with jx/proc-receive-hook, dr/push-remoteref-fix and mr/bisect-in-c-2. I have prepared a conflict resolution [1] I'm happy to rebase on top of a merge of master and those three branches if that is helpful.
[1] tag merge-repo-refs-into-pu/v1 at https://github.com/phillipwood/git.git
Phillip Wood (3):
refs: update delete_ref() to take a struct repository
refs: update update_ref() to take a struct repository
refs: update ref_exists() to take a struct repository
bisect.c | 18 ++++++---- branch.c | 14 ++++---- branch.h | 6 ++-- builtin/am.c | 19 +++++----- builtin/bisect--helper.c | 8 ++--- builtin/branch.c | 23 ++++++------ builtin/checkout.c | 17 +++++---- builtin/clone.c | 16 ++++----- builtin/commit.c | 4 +-- builtin/for-each-ref.c | 4 +-- builtin/log.c | 6 ++-- builtin/ls-remote.c | 2 +- builtin/merge.c | 12 +++---- builtin/notes.c | 15 ++++---- builtin/pull.c | 5 +-- builtin/rebase.c | 10 +++--- builtin/receive-pack.c | 2 +- builtin/remote.c | 11 +++--- builtin/replace.c | 2 +- builtin/reset.c | 10 +++--- builtin/revert.c | 2 +- builtin/send-pack.c | 3 +- builtin/stash.c | 8 ++--- builtin/symbolic-ref.c | 3 +- builtin/tag.c | 8 ++--- builtin/update-ref.c | 5 +-- builtin/verify-tag.c | 2 +- builtin/worktree.c | 8 ++--- diff.c | 2 +- fast-import.c | 2 +- notes-cache.c | 4 +-- notes-cache.h | 2 +- notes-utils.c | 2 +- ref-filter.c | 76 +++++++++++++++++++++++++--------------- ref-filter.h | 11 +++--- refs.c | 14 ++++---- refs.h | 6 ++-- remote.c | 30 +++++++++------- remote.h | 13 ++++--- reset.c | 8 ++--- sequencer.c | 41 +++++++++++----------- sequencer.h | 2 +- sha1-name.c | 5 +-- transport-helper.c | 32 +++++++++-------- transport-internal.h | 4 ++- transport.c | 15 ++++---- transport.h | 3 +- wt-status.c | 41 ++++++++++++---------- wt-status.h | 2 +- 49 files changed, 314 insertions(+), 244 deletions(-)
base-commit: 101b3204f37606972b40fc17dec84560c22f69f6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-665%2Fphillipwood%2Fwip%2Frepo-refs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-665/phillipwood/wip/repo-refs-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/665
Signature · 1 line
gitgitgadget
PATCH 3/3 refs: update ref_exists() to take a struct repository
From: Phillip Wood <[email protected]>
There are a number of places where we check for the existance of a pseudo ref by looking for a file rather than using the refs api. The assumption that these refs are always files will not valid once repositories start storing their refs in a reftable. As the current code is already aware of which repository the ref is in update ref_exists() to take a struct repository* so that we can safely change the file_exists() calls to ref_exists() later. It would be possible to change the file_exists() to use refs_ref_exists(get_main_ref_store(r), ...) but that gets quite cumbersome.
--- branch.c | 14 ++++---- branch.h | 6 ++-- builtin/bisect--helper.c | 2 +- builtin/branch.c | 19 +++++----- builtin/checkout.c | 14 +++++--- builtin/commit.c | 4 +-- builtin/for-each-ref.c | 4 +-- builtin/log.c | 6 ++-- builtin/ls-remote.c | 2 +- builtin/merge.c | 2 +- builtin/pull.c | 2 +- builtin/rebase.c | 4 +-- builtin/receive-pack.c | 2 +- builtin/remote.c | 5 +-- builtin/stash.c | 4 +-- builtin/tag.c | 6 ++-- builtin/verify-tag.c | 2 +- builtin/worktree.c | 8 ++--- ref-filter.c | 76 +++++++++++++++++++++++++--------------- ref-filter.h | 11 +++--- refs.c | 4 +-- refs.h | 2 +- remote.c | 30 +++++++++------- remote.h | 13 ++++--- sha1-name.c | 5 +-- wt-status.c | 41 ++++++++++++---------- wt-status.h | 2 +- 27 files changed, 168 insertions(+), 122 deletions(-)
branch.c +8 -6
@@ -183,12 +183,13 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -int validate_branchname (const char *name,struct strbuf *ref) +int validate_branchname (struct repository *r,const char *name, +struct strbuf *ref) {if (strbuf_check_branch_ref (ref, name))die (_ ("'%s' is not a valid branch name." ), name); -return ref_exists (ref->buf); +return ref_exists (r, ref->buf); }/*
@@ -197,11 +198,12 @@ int validate_branchname(const char *name, struct strbuf *ref)* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -int validate_new_branchname (const char *name,struct strbuf *ref,int force) +int validate_new_branchname (struct repository *r,const char *name, +struct strbuf *ref,int force) {const char *head; -if (!validate_branchname (name, ref)) +if (!validate_branchname (r, name, ref))return 0 ;if (!force)
@@ -260,8 +262,8 @@ void create_branch(struct repository *r, explicit_tracking =1 ;if ((track ==BRANCH_TRACK_OVERRIDE || clobber_head_ok) - ?validate_branchname (name, &ref) - :validate_new_branchname (name, &ref, force)) { + ?validate_branchname (r, name, &ref) + :validate_new_branchname (r, name, &ref, force)) {if (!force) dont_change_ref =1 ;else
branch.h +4 -2
@@ -50,7 +50,8 @@ void create_branch(struct repository *r,* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -int validate_branchname (const char *name,struct strbuf *ref); +int validate_branchname (struct repository *r,const char *name, +struct strbuf *ref);/* * Check if a branch 'name' can be created as a new branch; die otherwise.
@@ -58,7 +59,8 @@ int validate_branchname(const char *name, struct strbuf *ref);* Return 1 if the named branch already exists; return 0 otherwise. * Fill ref with the full refname for the branch. */ -int validate_new_branchname (const char *name,struct strbuf *ref,int force); +int validate_new_branchname (struct repository *r,const char *name, +struct strbuf *ref,int force);/* * Remove information about the merge state on the current
builtin/bisect--helper.c +1 -1
@@ -336,7 +336,7 @@ static int bisect_next_check(const struct bisect_terms *terms,char *bad_ref =xstrfmt ("refs/bisect/%s" , terms->term_bad);char *good_glob =xstrfmt ("%s-*" , terms->term_good); -if (ref_exists (bad_ref)) +if (ref_exists (the_repository, bad_ref)) missing_bad =0 ; for_each_glob_ref_in(mark_good, good_glob, "refs/bisect/",
builtin/branch.c +11 -8
@@ -126,7 +126,8 @@ static int branch_merged(int kind, const char *name,if (kind ==FILTER_REFS_BRANCHES ) {struct branch *branch =branch_get (name); -const char *upstream =branch_get_upstream (branch,NULL ); +const char *upstream = +branch_get_upstream (the_repository, branch,NULL );struct object_id oid; if (upstream &&
@@ -428,12 +429,13 @@ static void print_ref_list(struct ref_filter *filter, struct ref_sorting *sortinif (verify_ref_format (format))die (_ ("unable to parse format string" )); -ref_array_sort (sorting, &array); +ref_array_sort (the_repository, sorting, &array);for (i =0 ; i < array.nr; i++) {struct strbuf out =STRBUF_INIT ;struct strbuf err =STRBUF_INIT ; -if (format_ref_array_item (array.items[i], format, &out, &err)) +if (format_ref_array_item (the_repository, array.items[i], + format, &out, &err))die ("%s" , err.buf);if (column_active (colopts)) {assert (!filter->verbose &&"--column and --verbose are incompatible" );
@@ -509,7 +511,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int* Bad name --- this could be an attempt to rename a * ref that we used to allow to be created by accident. */ -if (ref_exists (oldref.buf)) +if (ref_exists (the_repository, oldref.buf)) recovery =1 ;else die (_ ("Invalid branch name: '%s'" ), oldname);
@@ -520,9 +522,10 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int* cause the worktree to become inconsistent with HEAD, so allow it. */ if (!strcmp (oldname, newname)) -validate_branchname (newname, &newref); +validate_branchname (the_repository, newname, &newref);else -validate_new_branchname (newname, &newref, force); +validate_new_branchname (the_repository, newname, &newref, + force);reject_rebase_or_bisect_branch (oldref.buf);
@@ -756,7 +759,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)die (_ ("cannot edit description of more than one branch" ));strbuf_addf (&branch_ref,"refs/heads/%s" , branch_name); -if (!ref_exists (branch_ref.buf)) { +if (!ref_exists (the_repository, branch_ref.buf)) {strbuf_release (&branch_ref);if (!argc)
@@ -802,7 +805,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)die (_ ("no such branch '%s'" ), argv[0 ]); } -if (!ref_exists (branch->refname)) +if (!ref_exists (the_repository, branch->refname))die (_ ("branch '%s' does not exist" ), branch->name);/*
builtin/checkout.c +9 -5
@@ -832,7 +832,8 @@ static void report_tracking(struct branch_info *new_branch_info)struct strbuf sb =STRBUF_INIT ;struct branch *branch =branch_get (new_branch_info->name); -if (!format_tracking_info (branch, &sb,AHEAD_BEHIND_FULL )) +if (!format_tracking_info (the_repository, branch, &sb, +AHEAD_BEHIND_FULL ))return ;fputs (sb.buf, stdout);strbuf_release (&sb);
@@ -923,7 +924,9 @@ static void update_refs_for_switch(const struct checkout_opts *opts, } }if (old_branch_info->path && old_branch_info->name) { -if (!ref_exists (old_branch_info->path) &&reflog_exists (old_branch_info->path)) +if (!ref_exists (the_repository, + old_branch_info->path) && +reflog_exists (old_branch_info->path))delete_reflog (old_branch_info->path); } }
@@ -1728,10 +1731,11 @@ static int checkout_main(int argc, const char **argv, const char *prefix,struct strbuf buf =STRBUF_INIT ;if (opts->new_branch_force) - opts->branch_exists =validate_branchname (opts->new_branch, &buf); + opts->branch_exists =validate_branchname ( + the_repository, opts->new_branch, &buf);else - opts->branch_exists = -validate_new_branchname (opts->new_branch, &buf,0 ); + opts->branch_exists =validate_new_branchname ( + the_repository, opts->new_branch, &buf,0 );strbuf_release (&buf); }
builtin/commit.c +2 -2
@@ -538,7 +538,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int s->ignore_submodule_arg = ignore_submodule_arg;wt_status_collect (s); -wt_status_print (s); +wt_status_print (the_repository, s);wt_status_collect_free_buffers (s);return s->committable;
@@ -1457,7 +1457,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)if (s.relative_paths) s.prefix = prefix; -wt_status_print (&s); +wt_status_print (the_repository, &s);wt_status_collect_free_buffers (&s);return 0 ;
builtin/for-each-ref.c +2 -2
@@ -76,12 +76,12 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) filter.name_patterns = argv; filter.match_as_path =1 ;filter_refs (&array, &filter,FILTER_REFS_ALL |FILTER_REFS_INCLUDE_BROKEN ); -ref_array_sort (sorting, &array); +ref_array_sort (the_repository, sorting, &array);if (!maxcount || array.nr < maxcount) maxcount = array.nr;for (i =0 ; i < maxcount; i++) -show_ref_array_item (array.items[i], &format); +show_ref_array_item (the_repository, array.items[i], &format);ref_array_clear (&array);return 0 ; }
builtin/log.c +4 -2
@@ -1445,7 +1445,8 @@ static struct commit *get_base_commit(const char *base_commit,die (_ ("unknown commit %s" ), base_commit); }else if ((base_commit && !strcmp (base_commit,"auto" ))) {struct branch *curr_branch =branch_get (NULL ); -const char *upstream =branch_get_upstream (curr_branch,NULL ); +const char *upstream = +branch_get_upstream (the_repository, curr_branch,NULL );if (upstream) {struct commit_list *base_list;struct commit *commit;
@@ -2201,7 +2202,8 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)break ;default : current_branch =branch_get (NULL ); - upstream =branch_get_upstream (current_branch,NULL ); + upstream =branch_get_upstream (the_repository, current_branch, +NULL );if (!upstream) { fprintf(stderr, _("Could not find a tracked" " remote branch, please"
builtin/ls-remote.c +1 -1
@@ -136,7 +136,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) }if (sorting) -ref_array_sort (sorting, &ref_array); +ref_array_sort (the_repository, sorting, &ref_array);for (i =0 ; i < ref_array.nr; i++) {const struct ref_array_item *ref = ref_array.items[i];
builtin/merge.c +1 -1
@@ -549,7 +549,7 @@ static void merge_name(const char *remote, struct strbuf *msg)struct strbuf truname =STRBUF_INIT ;strbuf_addf (&truname,"refs/heads/%s" , remote);strbuf_setlen (&truname, truname.len - len); -if (ref_exists (truname.buf)) { +if (ref_exists (the_repository, truname.buf)) { strbuf_addf(msg, "%s\t\tbranch '%s'%s of .\n", oid_to_hex(&remote_head->object.oid),
builtin/pull.c +1 -1
@@ -736,7 +736,7 @@ static const char *get_upstream_branch(const char *remote)if (strcmp (curr_branch_remote, rm->name))return NULL ; -return branch_get_upstream (curr_branch,NULL ); +return branch_get_upstream (the_repository, curr_branch,NULL ); }/**
builtin/rebase.c +2 -2
@@ -1800,8 +1800,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)struct branch *branch; branch =branch_get (NULL ); - options.upstream_name =branch_get_upstream (branch, -NULL ); + options.upstream_name =branch_get_upstream ( + the_repository, branch,NULL );if (!options.upstream_name)error_on_missing_default_upstream ();if (fork_point <0 )
builtin/receive-pack.c +1 -1
@@ -1151,7 +1151,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)struct strbuf err =STRBUF_INIT ;if (!parse_object (the_repository, old_oid)) { old_oid =NULL ; -if (ref_exists (name)) { +if (ref_exists (the_repository, name)) {rp_warning ("Allowing deletion of corrupt ref." ); }else {rp_warning ("Deleting a non-existent ref." );
builtin/remote.c +3 -2
@@ -358,7 +358,8 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat states->tracked.strdup_strings =1 ; states->stale.strdup_strings =1 ;for (ref = fetch_map; ref; ref = ref->next) { -if (!ref->peer_ref || !ref_exists (ref->peer_ref->name)) +if (!ref->peer_ref || + !ref_exists (the_repository, ref->peer_ref->name))string_list_append (&states->new_refs,abbrev_branch (ref->name));else string_list_append (&states->tracked,abbrev_branch (ref->name));
@@ -1353,7 +1354,7 @@ static int set_head(int argc, const char **argv)if (head_name) {strbuf_addf (&buf2,"refs/remotes/%s/%s" , argv[0 ], head_name);/* make sure it's valid */ -if (!ref_exists (buf2.buf)) +if (!ref_exists (the_repository, buf2.buf)) result |=error (_ ("Not a valid ref: %s" ), buf2.buf);else if (create_symref (buf.buf, buf2.buf,"remote set-head" )) result |=error (_ ("Could not setup %s" ), buf.buf);
builtin/stash.c +2 -2
@@ -157,7 +157,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)strbuf_init (&info->revision,0 );if (!commit) { -if (!ref_exists (ref_stash)) { +if (!ref_exists (the_repository, ref_stash)) {free_stash_info (info);fprintf_ln (stderr,_ ("No stash entries found." ));return -1 ;
@@ -688,7 +688,7 @@ static int list_stash(int argc, const char **argv, const char *prefix) git_stash_list_usage, PARSE_OPT_KEEP_UNKNOWN); -if (!ref_exists (ref_stash)) +if (!ref_exists (the_repository, ref_stash))return 0 ; cp.git_cmd =1 ;
builtin/tag.c +3 -3
@@ -61,10 +61,10 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting,die (_ ("unable to parse format string" )); filter->with_commit_tag_algo =1 ;filter_refs (&array, filter,FILTER_REFS_TAGS ); -ref_array_sort (sorting, &array); +ref_array_sort (the_repository, sorting, &array);for (i =0 ; i < array.nr; i++) -show_ref_array_item (array.items[i], format); +show_ref_array_item (the_repository, array.items[i], format);ref_array_clear (&array);free (to_free);
@@ -121,7 +121,7 @@ static int verify_tag(const char *name, const char *ref,return -1 ;if (format->format) -pretty_print_ref (name, oid, format); +pretty_print_ref (the_repository, name, oid, format);return 0 ; }
builtin/verify-tag.c +1 -1
@@ -71,7 +71,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix) }if (format.format) -pretty_print_ref (name, &oid, &format); +pretty_print_ref (the_repository, name, &oid, &format); }return had_error; }
builtin/worktree.c +4 -4
@@ -273,7 +273,7 @@ static int add_worktree(const char *path, const char *refname,/* is 'refname' a branch or commit? */ if (!opts->detach && !strbuf_check_branch_ref (&symref, refname) && -ref_exists (symref.buf)) { +ref_exists (the_repository, symref.buf)) { is_branch =1 ;if (!opts->force)die_if_checked_out (symref.buf,0 );
@@ -442,7 +442,7 @@ static void print_preparing_worktree_line(int detach, }else {struct strbuf s =STRBUF_INIT ;if (!detach && !strbuf_check_branch_ref (&s, branch) && -ref_exists (s.buf)) +ref_exists (the_repository, s.buf))printf_ln (_ ("Preparing worktree (checking out '%s')" ), branch);else {
@@ -465,7 +465,7 @@ static const char *dwim_branch(const char *path, const char **new_branch)UNLEAK (branchname);if (!strbuf_check_branch_ref (&ref, branchname) && -ref_exists (ref.buf)) { +ref_exists (the_repository, ref.buf)) {strbuf_release (&ref);return branchname; }
@@ -529,7 +529,7 @@ static int add(int ac, const char **av, const char *prefix)if (!opts.force && !strbuf_check_branch_ref (&symref, new_branch) && -ref_exists (symref.buf)) +ref_exists (the_repository, symref.buf))die_if_checked_out (symref.buf,0 );strbuf_release (&symref); }
ref-filter.c +47 -29
194 lines not on this page · raw message
ref-filter.h +7 -4
@@ -113,16 +113,18 @@ void ref_array_clear(struct ref_array *array);/* Used to verify if the given format is correct and to parse out the used atoms */ int verify_ref_format (struct ref_format *format);/* Sort the given ref_array as per the ref_sorting provided */ -void ref_array_sort (struct ref_sorting *sort,struct ref_array *array); +void ref_array_sort (struct repository *r,struct ref_sorting *sort, +struct ref_array *array);/* Set the ignore_case flag for all elements of a sorting list */ void ref_sorting_icase_all (struct ref_sorting *sorting,int flag);/* Based on the given format and quote_style, fill the strbuf */ -int format_ref_array_item (struct ref_array_item *info, +int format_ref_array_item (struct repository *r,struct ref_array_item *info,const struct ref_format *format,struct strbuf *final_buf,struct strbuf *error_buf);/* Print the ref using the given format and quote_style */ -void show_ref_array_item (struct ref_array_item *info,const struct ref_format *format); +void show_ref_array_item (struct repository *r,struct ref_array_item *info, +const struct ref_format *format);/* Parse a single sort specifier and add it to the list */ void parse_ref_sorting (struct ref_sorting **sorting_tail,const char *atom);/* Callback function for parsing the sort option */
@@ -140,7 +142,8 @@ void setup_ref_filter_porcelain_msg(void);* Print a single ref, outside of any ref-filter. Note that the * name must be a fully qualified refname. */ -void pretty_print_ref (const char *name,const struct object_id *oid, +void pretty_print_ref (struct repository *r,const char *name, +const struct object_id *oid,const struct ref_format *format);/*
refs.c +2 -2
@@ -316,9 +316,9 @@ static int refs_ref_exists(struct ref_store *refs, const char *refname)return !!refs_resolve_ref_unsafe (refs, refname,RESOLVE_REF_READING ,NULL ,NULL ); } -int ref_exists (const char *refname) +int ref_exists (struct repository *r,const char *refname) { -return refs_ref_exists (get_main_ref_store (the_repository), refname); +return refs_ref_exists (get_main_ref_store (r), refname); } static int filter_refs(const char *refname, const struct object_id *oid,
refs.h +1 -1
@@ -105,7 +105,7 @@ int refs_verify_refname_available(struct ref_store *refs,const struct string_list *skip, struct strbuf *err); -int ref_exists (const char *refname); +int ref_exists (struct repository *r,const char *refname);int should_autocreate_reflog (const char *refname);
remote.c +17 -13
@@ -1604,7 +1604,8 @@ static const char *error_buf(struct strbuf *err, const char *fmt, ...)return NULL ; } -const char *branch_get_upstream (struct branch *branch,struct strbuf *err) +const char *branch_get_upstream (struct repository *r,struct branch *branch, +struct strbuf *err) {if (!branch)return error_buf (err,_ ("HEAD does not point to a branch" ));
@@ -1615,7 +1616,7 @@ const char *branch_get_upstream(struct branch *branch, struct strbuf *err)* or because it is not a real branch, and get_branch * auto-vivified it? */ -if (!ref_exists (branch->refname)) +if (!ref_exists (r, branch->refname))return error_buf (err,_ ("no such branch: '%s'" ), branch->name); return error_buf(err,
@@ -1645,7 +1646,8 @@ static const char *tracking_for_push_dest(struct remote *remote,return ret; } -static const char *branch_get_push_1 (struct branch *branch,struct strbuf *err) +static const char *branch_get_push_1 (struct repository *r, +struct branch *branch,struct strbuf *err) {struct remote *remote;
@@ -1682,14 +1684,14 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err)return tracking_for_push_dest (remote, branch->refname, err);case PUSH_DEFAULT_UPSTREAM : -return branch_get_upstream (branch, err); +return branch_get_upstream (r, branch, err);case PUSH_DEFAULT_UNSPECIFIED :case PUSH_DEFAULT_SIMPLE : {const char *up, *cur; - up =branch_get_upstream (branch, err); + up =branch_get_upstream (r, branch, err);if (!up)return NULL ; cur =tracking_for_push_dest (remote, branch->refname, err);
@@ -1705,13 +1707,14 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err)BUG ("unhandled push situation" ); } -const char *branch_get_push (struct branch *branch,struct strbuf *err) +const char *branch_get_push (struct repository *r,struct branch *branch, +struct strbuf *err) {if (!branch)return error_buf (err,_ ("HEAD does not point to a branch" ));if (!branch->push_tracking_ref) - branch->push_tracking_ref =branch_get_push_1 (branch, err); + branch->push_tracking_ref =branch_get_push_1 (r, branch, err);return branch->push_tracking_ref; }
@@ -1961,15 +1964,16 @@ static int stat_branch_pair(const char *branch_name, const char *base,* upstream defined, or ref does not exist). Returns 0 if the commits are * identical. Returns 1 if commits are different. */ -int stat_tracking_info (struct branch *branch,int *num_ours,int *num_theirs, +int stat_tracking_info (struct repository *r,struct branch *branch, +int *num_ours,int *num_theirs,const char **tracking_name,int for_push,enum ahead_behind_flags abf) {const char *base;/* Cannot stat unless we are marked to build on top of somebody else. */ - base = for_push ?branch_get_push (branch,NULL ) : -branch_get_upstream (branch,NULL ); + base = for_push ?branch_get_push (r, branch,NULL ) : +branch_get_upstream (r, branch,NULL );if (tracking_name) *tracking_name = base;if (!base)
@@ -1981,15 +1985,15 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,/* * Return true when there is anything to report, otherwise false. */ -int format_tracking_info (struct branch *branch,struct strbuf *sb, -enum ahead_behind_flags abf) +int format_tracking_info (struct repository *r,struct branch *branch, +struct strbuf *sb,enum ahead_behind_flags abf) {int ours, theirs, sti;const char *full_base;char *base;int upstream_is_gone =0 ; - sti =stat_tracking_info (branch, &ours, &theirs, &full_base,0 , abf); + sti =stat_tracking_info (r, branch, &ours, &theirs, &full_base,0 , abf);if (sti <0 ) {if (!full_base)return 0 ;
remote.h +8 -5
@@ -278,7 +278,8 @@ int branch_merge_matches(struct branch *, int n, const char *);* message is recorded there (if the function does not return NULL, then * `err` is not touched). */ -const char *branch_get_upstream (struct branch *branch,struct strbuf *err); +const char *branch_get_upstream (struct repository *r,struct branch *branch, +struct strbuf *err);/** * Return the tracking branch that corresponds to the ref we would push to
@@ -286,7 +287,8 @@ const char *branch_get_upstream(struct branch *branch, struct strbuf *err);* * The return value and `err` conventions match those of `branch_get_upstream`. */ -const char *branch_get_push (struct branch *branch,struct strbuf *err); +const char *branch_get_push (struct repository *r,struct branch *branch, +struct strbuf *err);/* Flags to match_refs. */ enum match_refs_flags {
@@ -305,11 +307,12 @@ enum ahead_behind_flags { };/* Reporting of tracking info */ -int stat_tracking_info (struct branch *branch,int *num_ours,int *num_theirs, +int stat_tracking_info (struct repository *r,struct branch *branch, +int *num_ours,int *num_theirs,const char **upstream_name,int for_push,enum ahead_behind_flags abf); -int format_tracking_info (struct branch *branch,struct strbuf *sb, -enum ahead_behind_flags abf); +int format_tracking_info (struct repository *r,struct branch *branch, +struct strbuf *sb,enum ahead_behind_flags abf);struct ref *get_local_heads (void );/*
sha1-name.c +3 -2
@@ -1469,7 +1469,8 @@ static int interpret_branch_mark(struct repository *r, const char *name, int namelen, int at, struct strbuf *buf, int (*get_mark)(const char *, int), - const char *(*get_data)(struct branch *, + const char *(*get_data)(struct repository *, +struct branch *,struct strbuf *), unsigned allowed) {
@@ -1492,7 +1493,7 @@ static int interpret_branch_mark(struct repository *r, }else branch =branch_get (NULL ); - value =get_data (branch, &err); + value =get_data (r, branch, &err);if (!value)die ("%s" , err.buf);
wt-status.c +22 -19
144 lines not on this page · raw message
wt-status.h +1 -1
@@ -147,7 +147,7 @@ size_t wt_status_locate_end(const char *s, size_t len);void wt_status_append_cut_line (struct strbuf *buf);void wt_status_add_cut_line (FILE *fp);void wt_status_prepare (struct repository *r,struct wt_status *s); -void wt_status_print (struct wt_status *s); +void wt_status_print (struct repository *r,struct wt_status *s);void wt_status_collect (struct wt_status *s);void wt_status_collect_free_buffers (struct wt_status *s); void wt_status_get_state(struct repository *repo,
Signature · 1 line
gitgitgadget
PATCH 1/3 refs: update delete_ref() to take a struct repository
In reply to Phillip Wood via GitGitGadgetFrom: Phillip Wood <[email protected]>
There are a number of places where we delete pseudo refs by calling unlink() on the pseduo ref path rather than using the refs api. The assumption that these refs are always files will not valid once repositories start storing their refs in a reftable. As the current code is already aware of which repository the ref is in update delete_ref() to take a struct repository* so that we can safely change the unlink() calls to delete_ref() later. It would be possible to change the unlink() to use refs_delete_ref(get_main_ref_store(r), ...) but that gets quite cumbersome.
--- builtin/am.c | 9 +++++---- builtin/branch.c | 4 ++-- builtin/notes.c | 5 +++-- builtin/rebase.c | 6 +++--- builtin/remote.c | 6 ++++-- builtin/replace.c | 2 +- builtin/reset.c | 2 +- builtin/revert.c | 2 +- builtin/send-pack.c | 3 ++- builtin/stash.c | 2 +- builtin/symbolic-ref.c | 3 ++- builtin/tag.c | 2 +- builtin/update-ref.c | 2 +- fast-import.c | 2 +- refs.c | 6 +++--- refs.h | 2 +- reset.c | 2 +- sequencer.c | 20 ++++++++++---------- sequencer.h | 2 +- transport.c | 7 ++++--- transport.h | 3 ++- 21 files changed, 50 insertions(+), 42 deletions(-)
builtin/am.c +5 -4
@@ -951,7 +951,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,if (mkdir (state->dir,0777 ) <0 && errno !=EEXIST )die_errno (_ ("failed to create directory '%s'" ), state->dir); -delete_ref (NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF ); +delete_ref (the_repository,NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF );if (split_mail (state, patch_format, paths, keep_cr) <0 ) {am_destroy (state);
@@ -1018,7 +1018,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format, }else {write_state_text (state,"abort-safety" ,"" );if (!state->rebasing) -delete_ref (NULL ,"ORIG_HEAD" ,NULL ,0 ); +delete_ref (the_repository,NULL ,"ORIG_HEAD" ,NULL ,0 ); }/*
@@ -1051,7 +1051,7 @@ static void am_next(struct am_state *state)oidclr (&state->orig_commit);unlink (am_path (state,"original-commit" )); -delete_ref (NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF ); +delete_ref (the_repository,NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF );if (!get_oid ("HEAD" , &head))write_state_text (state,"abort-safety" ,oid_to_hex (&head));
@@ -2059,7 +2059,8 @@ static void am_abort(struct am_state *state) has_curr_head ? &curr_head :NULL ,0 , UPDATE_REFS_DIE_ON_ERR); else if (curr_branch) - delete_ref(NULL, curr_branch, NULL, REF_NO_DEREF); + delete_ref(the_repository, NULL, curr_branch, NULL, + REF_NO_DEREF);free (curr_branch );am_destroy (state);
builtin/branch.c +2 -2
@@ -265,8 +265,8 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, goto next; } -if (delete_ref (NULL , name,is_null_oid (&oid) ?NULL : &oid, -REF_NO_DEREF )) { +if (delete_ref (the_repository,NULL , name, +is_null_oid (&oid) ?NULL : &oid,REF_NO_DEREF )) { error(remote_branch ? _("Error deleting remote-tracking branch '%s'") : _("Error deleting branch '%s'"),
builtin/notes.c +3 -2
@@ -694,9 +694,10 @@ static int merge_abort(struct notes_merge_options *o)* notes_merge_abort() to remove .git/NOTES_MERGE_WORKTREE. */ -if (delete_ref (NULL ,"NOTES_MERGE_PARTIAL" ,NULL ,0 )) +if (delete_ref (the_repository,NULL ,"NOTES_MERGE_PARTIAL" ,NULL ,0 )) ret +=error (_ ("failed to delete ref NOTES_MERGE_PARTIAL" )); -if (delete_ref (NULL ,"NOTES_MERGE_REF" ,NULL ,REF_NO_DEREF )) +if (delete_ref (the_repository,NULL ,"NOTES_MERGE_REF" ,NULL , +REF_NO_DEREF )) ret +=error (_ ("failed to delete ref NOTES_MERGE_REF" ));if (notes_merge_abort (o)) ret +=error (_ ("failed to remove 'git notes merge' worktree" ));
builtin/rebase.c +3 -3
@@ -724,7 +724,7 @@ static int finish_rebase(struct rebase_options *opts)struct strbuf dir =STRBUF_INIT ;int ret =0 ; -delete_ref (NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF ); +delete_ref (the_repository,NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF );apply_autostash (state_dir_path ("autostash" , opts));close_object_store (the_repository->objects);/*
@@ -736,7 +736,7 @@ static int finish_rebase(struct rebase_options *opts)struct replay_opts replay =REPLAY_OPTS_INIT ; replay.action =REPLAY_INTERACTIVE_REBASE ; - ret =sequencer_remove_state (&replay); + ret =sequencer_remove_state (the_repository, &replay); }else {strbuf_addstr (&dir, opts->state_dir);if (remove_dir_recursively (&dir,0 ))
@@ -1573,7 +1573,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)struct replay_opts replay =REPLAY_OPTS_INIT ; replay.action =REPLAY_INTERACTIVE_REBASE ; - ret = !!sequencer_remove_state (&replay); + ret = !!sequencer_remove_state (the_repository, &replay); }else {strbuf_reset (&buf);strbuf_addstr (&buf, options.state_dir);
builtin/remote.c +4 -2
@@ -762,7 +762,8 @@ static int mv(int argc, const char **argv)read_ref_full (item->string,RESOLVE_REF_READING ,NULL , &flag);if (!(flag &REF_ISSYMREF ))continue ; -if (delete_ref (NULL , item->string,NULL ,REF_NO_DEREF )) +if (delete_ref (the_repository,NULL , item->string,NULL , +REF_NO_DEREF ))die (_ ("deleting '%s' failed" ), item->string); }for (i =0 ; i < remote_branches.nr; i++) {
@@ -1343,7 +1344,8 @@ static int set_head(int argc, const char **argv) head_name =xstrdup (states.heads.items[0 ].string);free_remote_ref_states (&states); }else if (opt_d && !opt_a && argc ==1 ) { -if (delete_ref (NULL , buf.buf,NULL ,REF_NO_DEREF )) +if (delete_ref (the_repository,NULL , buf.buf,NULL , +REF_NO_DEREF )) result |=error (_ ("Could not delete %s" ), buf.buf); }else usage_with_options (builtin_remote_sethead_usage, options);
builtin/replace.c +1 -1
@@ -136,7 +136,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)static int delete_replace_ref (const char *name,const char *ref,const struct object_id *oid) { -if (delete_ref (NULL , ref, oid,0 )) +if (delete_ref (the_repository,NULL , ref, oid,0 ))return 1 ;printf_ln (_ ("Deleted replace ref '%s'" ), name);return 0 ;
builtin/reset.c +1 -1
@@ -267,7 +267,7 @@ static int reset_refs(const char *rev, const struct object_id *oid)update_ref (msg.buf,"ORIG_HEAD" , orig, old_orig,0 ,UPDATE_REFS_MSG_ON_ERR ); }else if (old_orig) -delete_ref (NULL ,"ORIG_HEAD" , old_orig,0 ); +delete_ref (the_repository,NULL ,"ORIG_HEAD" , old_orig,0 );set_reflog_message (&msg,"updating HEAD" , rev); update_ref_status =update_ref (msg.buf,"HEAD" , oid, orig,0 ,UPDATE_REFS_MSG_ON_ERR );
builtin/revert.c +1 -1
@@ -204,7 +204,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts) opts->strategy =xstrdup_or_null (opts->strategy);if (cmd =='q' ) { -int ret =sequencer_remove_state (opts); +int ret =sequencer_remove_state (the_repository, opts);if (!ret)remove_branch_state (the_repository,0 );return ret;
builtin/send-pack.c +2 -1
@@ -299,7 +299,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)if (!args.dry_run && remote) {struct ref *ref;for (ref = remote_refs; ref; ref = ref->next) -transport_update_tracking_ref (remote, ref, args.verbose); +transport_update_tracking_ref (the_repository, remote, + ref, args.verbose); }if (!ret && !transport_refs_pushed (remote_refs))
builtin/stash.c +1 -1
@@ -208,7 +208,7 @@ static int do_clear_stash(void)if (get_oid (ref_stash, &obj))return 0 ; -return delete_ref (NULL , ref_stash, &obj,0 ); +return delete_ref (the_repository,NULL , ref_stash, &obj,0 ); }static int clear_stash (int argc,const char **argv,const char *prefix)
builtin/symbolic-ref.c +2 -1
@@ -58,7 +58,8 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)die ("Cannot delete %s, not a symbolic ref" , argv[0 ]);if (!strcmp (argv[0 ],"HEAD" ))die ("deleting '%s' is not allowed" , argv[0 ]); -return delete_ref (NULL , argv[0 ],NULL ,REF_NO_DEREF ); +return delete_ref (the_repository,NULL , argv[0 ],NULL , +REF_NO_DEREF ); }switch (argc) {
builtin/tag.c +1 -1
@@ -100,7 +100,7 @@ static int for_each_tag_name(const char **argv, each_tag_name_fn fn,static int delete_tag (const char *name,const char *ref,const struct object_id *oid,const void *cb_data) { -if (delete_ref (NULL , ref, oid,0 )) +if (delete_ref (the_repository,NULL , ref, oid,0 ))return 1 ;printf (_ ("Deleted tag '%s' (was %s)\n" ), name,find_unique_abbrev (oid,DEFAULT_ABBREV ));
builtin/update-ref.c +1 -1
@@ -550,7 +550,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)* For purposes of backwards compatibility, we treat * NULL_SHA1 as "don't care" here: */ -return delete_ref (msg, refname, +return delete_ref (the_repository, msg, refname, (oldval && !is_null_oid (&oldoid)) ? &oldoid :NULL , default_flags); else
fast-import.c +1 -1
@@ -1613,7 +1613,7 @@ static int update_branch(struct branch *b)if (is_null_oid (&b->oid)) {if (b->delete) -delete_ref (NULL , b->name,NULL ,0 ); +delete_ref (the_repository,NULL , b->name,NULL ,0 );return 0 ; }if (read_ref (b->name, &old_oid))
refs.c +3 -3
@@ -863,11 +863,11 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,return 0 ; } -int delete_ref (const char *msg,const char *refname, +int delete_ref (struct repository *r,const char *msg,const char *refname,const struct object_id *old_oid,unsigned int flags) { -return refs_delete_ref (get_main_ref_store (the_repository), msg, refname, - old_oid, flags); +return refs_delete_ref (get_main_ref_store (r), msg, refname, old_oid, + flags); }void copy_reflog_msg (struct strbuf *sb,const char *msg)
refs.h +1 -1
@@ -414,7 +414,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,const char *refname, const struct object_id *old_oid, unsigned int flags); -int delete_ref (const char *msg,const char *refname, +int delete_ref (struct repository *r,const char *msg,const char *refname,const struct object_id *old_oid,unsigned int flags);/*
reset.c +1 -1
@@ -107,7 +107,7 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action,update_ref (reflog_orig_head,"ORIG_HEAD" , orig, old_orig,0 ,UPDATE_REFS_MSG_ON_ERR ); }else if (old_orig) -delete_ref (NULL ,"ORIG_HEAD" , old_orig,0 ); +delete_ref (r,NULL ,"ORIG_HEAD" , old_orig,0 ); }if (!reflog_head) {
sequencer.c +10 -10
@@ -281,7 +281,7 @@ static const char *gpg_sign_opt_quoted(struct replay_opts *opts)return buf.buf; } -int sequencer_remove_state (struct replay_opts *opts) +int sequencer_remove_state (struct repository *r,struct replay_opts *opts) {struct strbuf buf =STRBUF_INIT ;int i, ret =0 ;
@@ -293,7 +293,7 @@ int sequencer_remove_state(struct replay_opts *opts)char *eol =strchr (p,'\n' );if (eol) *eol ='\0' ; -if (delete_ref ("(rebase) cleanup" , p,NULL ,0 ) <0 ) { +if (delete_ref (r,"(rebase) cleanup" , p,NULL ,0 ) <0 ) {warning (_ ("could not delete '%s'" ), p); ret =-1 ; }
@@ -2325,7 +2325,7 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)if (!have_finished_the_last_pick ())return ; -sequencer_remove_state (&opts); +sequencer_remove_state (r, &opts); }static void todo_list_write_total_nr (struct todo_list *todo_list)
@@ -2833,7 +2833,7 @@ int sequencer_rollback(struct repository *r, struct replay_opts *opts)if (reset_merge (&oid)) goto fail;strbuf_release (&buf); -return sequencer_remove_state (opts); +return sequencer_remove_state (r, opts); fail:strbuf_release (&buf);return -1 ;
@@ -3858,7 +3858,7 @@ static int checkout_onto(struct repository *r, struct replay_opts *opts,if (run_git_checkout (r, opts,oid_to_hex (onto), action)) {apply_autostash (rebase_path_autostash ()); -sequencer_remove_state (opts); +sequencer_remove_state (r, opts);return error (_ ("could not detach HEAD" )); }
@@ -3938,7 +3938,7 @@ static int pick_commits(struct repository *r,unlink (rebase_path_stopped_sha ());unlink (rebase_path_amend ());unlink (git_path_merge_head (r)); -delete_ref (NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF ); +delete_ref (r,NULL ,"REBASE_HEAD" ,NULL ,REF_NO_DEREF );if (item->command ==TODO_BREAK ) {if (!opts->verbose)
@@ -4194,7 +4194,7 @@ static int pick_commits(struct repository *r,* Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory */ -return sequencer_remove_state (opts); +return sequencer_remove_state (r, opts); }static int continue_single_pick (struct repository *r)
@@ -5201,7 +5201,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned flaif (count_commands (todo_list) ==0 ) {apply_autostash (rebase_path_autostash ()); -sequencer_remove_state (opts); +sequencer_remove_state (r, opts);return error (_ ("nothing to do" )); }
@@ -5212,12 +5212,12 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned flareturn -1 ; else if (res == -2) {apply_autostash (rebase_path_autostash ()); -sequencer_remove_state (opts); +sequencer_remove_state (r, opts);return -1 ; } else if (res == -3) {apply_autostash (rebase_path_autostash ()); -sequencer_remove_state (opts); +sequencer_remove_state (r, opts);todo_list_release (&new_todo);return error (_ ("nothing to do" ));
sequencer.h +1 -1
@@ -132,7 +132,7 @@ int sequencer_pick_revisions(struct repository *repo,int sequencer_continue (struct repository *repo,struct replay_opts *opts);int sequencer_rollback (struct repository *repo,struct replay_opts *opts);int sequencer_skip (struct repository *repo,struct replay_opts *opts); -int sequencer_remove_state (struct replay_opts *opts); +int sequencer_remove_state (struct repository *repo,struct replay_opts *opts);#define TODO_LIST_KEEP_EMPTY (1U << 0)#define TODO_LIST_SHORTEN_IDS (1U << 1)
transport.c +4 -3
@@ -429,7 +429,8 @@ int transport_refs_pushed(struct ref *ref)return 0 ; } -void transport_update_tracking_ref (struct remote *remote,struct ref *ref,int verbose) +void transport_update_tracking_ref (struct repository *r,struct remote *remote, +struct ref *ref,int verbose) {struct refspec_item rs;
@@ -443,7 +444,7 @@ void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int vif (verbose)fprintf (stderr,"updating local tracking ref '%s'\n" , rs.dst);if (ref->deletion) { -delete_ref (NULL , rs.dst,NULL ,0 ); +delete_ref (r,NULL , rs.dst,NULL ,0 ); }else update_ref ("update by push" , rs.dst, &ref->new_oid,NULL ,0 ,0 );
@@ -1252,7 +1253,7 @@ int transport_push(struct repository *r, TRANSPORT_RECURSE_SUBMODULES_ONLY))) {struct ref *ref;for (ref = remote_refs; ref; ref = ref->next) -transport_update_tracking_ref (transport->remote, ref, verbose); +transport_update_tracking_ref (r, transport->remote, ref, verbose); }if (porcelain && !push_ret)
transport.h +2 -1
@@ -258,7 +258,8 @@ int transport_helper_init(struct transport *transport, const char *name);int bidirectional_transfer_loop (int input,int output);/* common methods used by transport.c and builtin/send-pack.c */ -void transport_update_tracking_ref (struct remote *remote,struct ref *ref,int verbose); +void transport_update_tracking_ref (struct repository *r,struct remote *remote, +struct ref *ref,int verbose);int transport_refs_pushed (struct ref *ref);
Signature · 1 line
gitgitgadget
PATCH 2/3 refs: update update_ref() to take a struct repository
In reply to Phillip Wood via GitGitGadgetFrom: Phillip Wood <[email protected]>
There are a number of places where we create pseudo refs such as CHERRY_PICK head where the deletion takes a struct repository* but the creation of the ref does not. Change update_ref() so that creation and deletion match.
--- bisect.c | 18 +++++++++++------- builtin/am.c | 10 +++++----- builtin/bisect--helper.c | 6 +++--- builtin/checkout.c | 3 ++- builtin/clone.c | 16 ++++++++-------- builtin/merge.c | 10 +++++----- builtin/notes.c | 10 +++++----- builtin/pull.c | 3 ++- builtin/reset.c | 8 ++++---- builtin/stash.c | 2 +- builtin/update-ref.c | 3 ++- diff.c | 2 +- notes-cache.c | 4 ++-- notes-cache.h | 2 +- notes-utils.c | 2 +- refs.c | 4 ++-- refs.h | 2 +- reset.c | 6 +++--- sequencer.c | 21 +++++++++++---------- transport-helper.c | 32 ++++++++++++++++++-------------- transport-internal.h | 4 +++- transport.c | 8 +++++--- 22 files changed, 96 insertions(+), 80 deletions(-)
bisect.c +11 -7
@@ -704,17 +704,20 @@ static int is_expected_rev(const struct object_id *oid)return res; } -static enum bisect_error bisect_checkout (const struct object_id *bisect_rev,int no_checkout) +static enum bisect_error bisect_checkout (struct repository *r, +const struct object_id *bisect_rev, +int no_checkout) {char bisect_rev_hex[GIT_MAX_HEXSZ +1 ];enum bisect_error res =BISECT_OK ;memcpy (bisect_rev_hex,oid_to_hex (bisect_rev), the_hash_algo->hexsz +1 ); -update_ref (NULL ,"BISECT_EXPECTED_REV" , bisect_rev,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR ); +update_ref (r,NULL ,"BISECT_EXPECTED_REV" , bisect_rev,NULL ,0 , +UPDATE_REFS_DIE_ON_ERR ); argv_checkout[2 ] = bisect_rev_hex;if (no_checkout) { -update_ref (NULL ,"BISECT_HEAD" , bisect_rev,NULL ,0 , +update_ref (r,NULL ,"BISECT_HEAD" , bisect_rev,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR ); }else { res =run_command_v_opt (argv_checkout,RUN_GIT_CMD );
@@ -820,7 +823,8 @@ static void handle_skipped_merge_base(const struct object_id *mb)* for early success, this will be converted back to 0 in * check_good_are_ancestors_of_bad(). */ -static enum bisect_error check_merge_bases (int rev_nr,struct commit **rev,int no_checkout) +static enum bisect_error check_merge_bases (struct repository *r,int rev_nr, +struct commit **rev,int no_checkout) {enum bisect_error res =BISECT_OK ;struct commit_list *result;
@@ -838,7 +842,7 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, inthandle_skipped_merge_base (mb); }else {printf (_ ("Bisecting: a merge base must be tested\n" )); - res =bisect_checkout (mb, no_checkout); + res =bisect_checkout (r, mb, no_checkout);if (!res)/* indicate early success */ res =BISECT_INTERNAL_SUCCESS_MERGE_BASE ;
@@ -903,7 +907,7 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r, rev =get_bad_and_good_commits (r, &rev_nr);if (check_ancestors (r, rev_nr, rev, prefix)) - res =check_merge_bases (rev_nr, rev, no_checkout); + res =check_merge_bases (r, rev_nr, rev, no_checkout);free (rev);if (!res) {
@@ -1065,7 +1069,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int nr), nr, steps_msg);free (steps_msg); -return bisect_checkout (bisect_rev, no_checkout); +return bisect_checkout (r, bisect_rev, no_checkout); }static inline int log2i (int n)
builtin/am.c +5 -5
@@ -1013,8 +1013,8 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,if (!get_oid ("HEAD" , &curr_head)) {write_state_text (state,"abort-safety" ,oid_to_hex (&curr_head));if (!state->rebasing) -update_ref ("am" ,"ORIG_HEAD" , &curr_head,NULL ,0 , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository,"am" ,"ORIG_HEAD" , + &curr_head,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR ); }else {write_state_text (state,"abort-safety" ,"" );if (!state->rebasing)
@@ -1378,7 +1378,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)oidcpy (&state->orig_commit, &commit_oid);write_state_text (state,"original-commit" ,oid_to_hex (&commit_oid)); -update_ref ("am" ,"REBASE_HEAD" , &commit_oid, +update_ref (the_repository,"am" ,"REBASE_HEAD" , &commit_oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR );return 0 ;
@@ -1594,7 +1594,7 @@ static void do_commit(const struct am_state *state)strbuf_addf (&sb,"%s: %.*s" , reflog_msg,linelen (state->msg), state->msg); -update_ref (sb.buf,"HEAD" , &commit, old_oid,0 , +update_ref (the_repository, sb.buf,"HEAD" , &commit, old_oid,0 ,UPDATE_REFS_DIE_ON_ERR );if (state->rebasing) {
@@ -2055,7 +2055,7 @@ static void am_abort(struct am_state *state)clean_index (&curr_head, &orig_head);if (has_orig_head) -update_ref ("am --abort" ,"HEAD" , &orig_head, +update_ref (the_repository,"am --abort" ,"HEAD" , &orig_head, has_curr_head ? &curr_head :NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );else if (curr_branch)
builtin/bisect--helper.c +3 -3
@@ -222,7 +222,7 @@ static int bisect_write(const char *state, const char *rev, goto finish; } -if (update_ref (NULL , tag.buf, &oid,NULL ,0 , +if (update_ref (the_repository,NULL , tag.buf, &oid,NULL ,0 ,UPDATE_REFS_MSG_ON_ERR )) { res =-1 ; goto finish;
@@ -582,8 +582,8 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout, res =error (_ ("invalid ref: '%s'" ), start_head.buf); goto finish; } -if (update_ref (NULL ,"BISECT_HEAD" , &oid,NULL ,0 , -UPDATE_REFS_MSG_ON_ERR )) { +if (update_ref (the_repository,NULL ,"BISECT_HEAD" , &oid,NULL , +0 ,UPDATE_REFS_MSG_ON_ERR )) { res =-1 ; goto finish; }
builtin/checkout.c +2 -1
@@ -892,7 +892,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,if (!strcmp (new_branch_info->name,"HEAD" ) && !new_branch_info->path && !opts->force_detach) {/* Nothing to do. */ }else if (opts->force_detach || !new_branch_info->path) {/* No longer on any branch. */ -update_ref (msg.buf,"HEAD" , &new_branch_info->commit->object.oid,NULL , +update_ref (the_repository, msg.buf,"HEAD" , + &new_branch_info->commit->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR );if (!opts->quiet) { if (old_branch_info->path &&
builtin/clone.c +8 -8
@@ -647,8 +647,8 @@ static void write_followtags(const struct ref *refs, const char *msg)OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) continue; -update_ref (msg, ref->name, &ref->old_oid,NULL ,0 , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg, ref->name, &ref->old_oid,NULL , +0 ,UPDATE_REFS_DIE_ON_ERR ); } }
@@ -719,24 +719,24 @@ static void update_head(const struct ref *our, const struct ref *remote,if (create_symref ("HEAD" , our->name,NULL ) <0 )die (_ ("unable to update HEAD" ));if (!option_bare) { -update_ref (msg,"HEAD" , &our->old_oid,NULL ,0 , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg,"HEAD" , &our->old_oid, +NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );install_branch_config (0 , head, option_origin, our->name); } }else if (our) {struct commit *c =lookup_commit_reference (the_repository, &our->old_oid);/* --branch specifies a non-branch (i.e. tags), detach HEAD */ -update_ref (msg,"HEAD" , &c->object.oid,NULL ,REF_NO_DEREF , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg,"HEAD" , &c->object.oid,NULL , +REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR ); }else if (remote) {/* * We know remote HEAD points to a non-branch, or * HEAD points to a branch but we don't know which one. * Detach HEAD in all these cases. */ -update_ref (msg,"HEAD" , &remote->old_oid,NULL ,REF_NO_DEREF , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg,"HEAD" , &remote->old_oid,NULL , +REF_NO_DEREF ,UPDATE_REFS_DIE_ON_ERR ); } }
builtin/merge.c +5 -5
@@ -450,8 +450,8 @@ static void finish(struct commit *head_commit,if (verbosity >=0 && !merge_msg.len)printf (_ ("No merge message -- not updating HEAD\n" ));else { -update_ref (reflog_message.buf,"HEAD" , new_head, head, -0 ,UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, reflog_message.buf,"HEAD" , + new_head, head,0 ,UPDATE_REFS_DIE_ON_ERR );/* * We ignore errors in 'gc --auto', since the * user should see them.
@@ -1423,8 +1423,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) remote_head_oid = &remoteheads->item->object.oid;read_empty (remote_head_oid,0 ); -update_ref ("initial pull" ,"HEAD" , remote_head_oid,NULL ,0 , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository,"initial pull" ,"HEAD" , + remote_head_oid,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR ); goto done; }
@@ -1490,7 +1490,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)free (list); } -update_ref ("updating ORIG_HEAD" ,"ORIG_HEAD" , +update_ref (the_repository,"updating ORIG_HEAD" ,"ORIG_HEAD" , &head_commit->object.oid,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );if (remoteheads && !common) {
builtin/notes.c +5 -5
@@ -747,7 +747,7 @@ static int merge_commit(struct notes_merge_options *o)format_commit_message (partial,"%s" , &msg, &pretty_ctx);strbuf_trim (&msg);strbuf_insertstr (&msg,0 ,"notes: " ); -update_ref (msg.buf, o->local_ref, &oid, +update_ref (the_repository, msg.buf, o->local_ref, &oid,is_null_oid (&parent_oid) ?NULL : &parent_oid,0 ,UPDATE_REFS_DIE_ON_ERR );
@@ -861,13 +861,13 @@ static int merge(int argc, const char **argv, const char *prefix)if (result >=0 )/* Merge resulted (trivially) in result_oid */ /* Update default notes ref with new commit */ -update_ref (msg.buf,default_notes_ref (), &result_oid,NULL ,0 , -UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg.buf,default_notes_ref (), + &result_oid,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );else {/* Merge has unresolved conflicts */ const struct worktree *wt;/* Update .git/NOTES_MERGE_PARTIAL with partial merge result */ -update_ref (msg.buf,"NOTES_MERGE_PARTIAL" , &result_oid,NULL , -0 ,UPDATE_REFS_DIE_ON_ERR ); +update_ref (the_repository, msg.buf,"NOTES_MERGE_PARTIAL" , + &result_oid,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */ wt =find_shared_symref ("NOTES_MERGE_REF" ,default_notes_ref ());if (wt)
builtin/pull.c +2 -1
@@ -625,7 +625,8 @@ static int pull_into_void(const struct object_id *merge_head, merge_head, 0))return 1 ; -if (update_ref ("initial pull" ,"HEAD" , merge_head, curr_head,0 ,UPDATE_REFS_DIE_ON_ERR )) +if (update_ref (the_repository,"initial pull" ,"HEAD" , merge_head, + curr_head,0 ,UPDATE_REFS_DIE_ON_ERR ))return 1 ;return 0 ;
builtin/reset.c +4 -4
@@ -264,13 +264,13 @@ static int reset_refs(const char *rev, const struct object_id *oid)if (!get_oid ("HEAD" , &oid_orig)) { orig = &oid_orig;set_reflog_message (&msg,"updating ORIG_HEAD" ,NULL ); -update_ref (msg.buf,"ORIG_HEAD" , orig, old_orig,0 , -UPDATE_REFS_MSG_ON_ERR ); +update_ref (the_repository, msg.buf,"ORIG_HEAD" , orig, old_orig, +0 ,UPDATE_REFS_MSG_ON_ERR ); }else if (old_orig)delete_ref (the_repository,NULL ,"ORIG_HEAD" , old_orig,0 );set_reflog_message (&msg,"updating HEAD" , rev); - update_ref_status =update_ref (msg.buf,"HEAD" , oid, orig,0 , -UPDATE_REFS_MSG_ON_ERR ); + update_ref_status =update_ref (the_repository, msg.buf,"HEAD" , oid, + orig,0 ,UPDATE_REFS_MSG_ON_ERR );strbuf_release (&msg);return update_ref_status; }
builtin/stash.c +1 -1
@@ -792,7 +792,7 @@ static int do_store_stash(const struct object_id *w_commit, const char *stash_msif (!stash_msg) stash_msg ="Created via \"git stash store\"." ; -if (update_ref (stash_msg, ref_stash, w_commit,NULL , +if (update_ref (the_repository, stash_msg, ref_stash, w_commit,NULL ,REF_FORCE_CREATE_REFLOG , quiet ?UPDATE_REFS_QUIET_ON_ERR :UPDATE_REFS_MSG_ON_ERR )) {
builtin/update-ref.c +2 -1
@@ -554,7 +554,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) (oldval && !is_null_oid (&oldoid)) ? &oldoid :NULL , default_flags); else - return update_ref(msg, refname, &oid, oldval ? &oldoid : NULL, + return update_ref(the_repository, msg, refname, &oid, + oldval ? &oldoid :NULL , default_flags | create_reflog_flag,UPDATE_REFS_DIE_ON_ERR ); }
diff.c +1 -1
@@ -6870,7 +6870,7 @@ size_t fill_textconv(struct repository *r,* Since generating a cache entry is the slow path anyway, * this extra overhead probably isn't a big deal. */ -notes_cache_write (driver->textconv_cache); +notes_cache_write (r, driver->textconv_cache); }return size;
notes-cache.c +2 -2
@@ -48,7 +48,7 @@ void notes_cache_init(struct repository *r, struct notes_cache *c,strbuf_release (&ref); } -int notes_cache_write (struct notes_cache *c) +int notes_cache_write (struct repository *r,struct notes_cache *c) {struct object_id tree_oid, commit_oid;
@@ -63,7 +63,7 @@ int notes_cache_write(struct notes_cache *c)if (commit_tree (c->validity,strlen (c->validity), &tree_oid,NULL , &commit_oid,NULL ,NULL ) <0 )return -1 ; -if (update_ref ("update notes cache" , c->tree.update_ref, &commit_oid, +if (update_ref (r,"update notes cache" , c->tree.update_ref, &commit_oid,NULL ,0 ,UPDATE_REFS_QUIET_ON_ERR ) <0 )return -1 ;
notes-cache.h +1 -1
@@ -12,7 +12,7 @@ struct notes_cache {void notes_cache_init (struct repository *r,struct notes_cache *c,const char *name,const char *validity); -int notes_cache_write (struct notes_cache *c); +int notes_cache_write (struct repository *r,struct notes_cache *c);char *notes_cache_get (struct notes_cache *c,struct object_id *oid,size_t *outsize);
notes-utils.c +1 -1
@@ -53,7 +53,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)create_notes_commit (r, t,NULL , buf.buf, buf.len, &commit_oid);strbuf_insertstr (&buf,0 ,"notes: " ); -update_ref (buf.buf, t->update_ref, &commit_oid,NULL ,0 , +update_ref (r, buf.buf, t->update_ref, &commit_oid,NULL ,0 ,UPDATE_REFS_DIE_ON_ERR );strbuf_release (&buf);
refs.c +2 -2
@@ -1205,12 +1205,12 @@ int refs_update_ref(struct ref_store *refs, const char *msg,return 0 ; } -int update_ref (const char *msg,const char *refname, +int update_ref (struct repository *r,const char *msg,const char *refname,const struct object_id *new_oid,const struct object_id *old_oid,unsigned int flags,enum action_on_err onerr) { -return refs_update_ref (get_main_ref_store (the_repository), msg, refname, new_oid, +return refs_update_ref (get_main_ref_store (r), msg, refname, new_oid, old_oid, flags, onerr); }
refs.h +1 -1
@@ -728,7 +728,7 @@ void ref_transaction_free(struct ref_transaction *transaction);int refs_update_ref (struct ref_store *refs,const char *msg,const char *refname,const struct object_id *new_oid,const struct object_id *old_oid,unsigned int flags,enum action_on_err onerr); -int update_ref (const char *msg,const char *refname, +int update_ref (struct repository *r,const char *msg,const char *refname,const struct object_id *new_oid,const struct object_id *old_oid,unsigned int flags,enum action_on_err onerr);
reset.c +3 -3
@@ -104,7 +104,7 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action,strbuf_addstr (&msg,"updating ORIG_HEAD" ); reflog_orig_head = msg.buf; } -update_ref (reflog_orig_head,"ORIG_HEAD" , orig, +update_ref (r, reflog_orig_head,"ORIG_HEAD" , orig, old_orig,0 ,UPDATE_REFS_MSG_ON_ERR ); }else if (old_orig)delete_ref (r,NULL ,"ORIG_HEAD" , old_orig,0 );
@@ -116,11 +116,11 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action, reflog_head = msg.buf; }if (!switch_to_branch) - ret =update_ref (reflog_head,"HEAD" , oid, orig, + ret =update_ref (r, reflog_head,"HEAD" , oid, orig, detach_head ?REF_NO_DEREF :0 ,UPDATE_REFS_MSG_ON_ERR );else { - ret =update_ref (reflog_head, switch_to_branch, oid, + ret =update_ref (r, reflog_head, switch_to_branch, oid,NULL ,0 ,UPDATE_REFS_MSG_ON_ERR );if (!ret) ret = create_symref("HEAD", switch_to_branch,
sequencer.c +11 -10
@@ -1426,9 +1426,9 @@ static int try_to_commit(struct repository *r,return res; } -static int write_rebase_head (struct object_id *oid) +static int write_rebase_head (struct repository *r,struct object_id *oid) { -if (update_ref ("rebase" ,"REBASE_HEAD" , oid, +if (update_ref (r,"rebase" ,"REBASE_HEAD" , oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_MSG_ON_ERR ))return error (_ ("could not update %s" ),"REBASE_HEAD" );
@@ -1465,7 +1465,7 @@ static int do_commit(struct repository *r, }if (res ==1 ) {if (is_rebase_i (opts) && oid) -if (write_rebase_head (oid)) +if (write_rebase_head (r, oid))return -1 ;return run_git_commit (r, msg_file, opts, flags); }
@@ -1939,11 +1939,11 @@ static int do_pick_commit(struct repository *r,if ((command ==TODO_PICK || command ==TODO_REWORD || command ==TODO_EDIT ) && !opts->no_commit && (res ==0 || res ==1 ) && -update_ref (NULL ,"CHERRY_PICK_HEAD" , &commit->object.oid,NULL , +update_ref (r,NULL ,"CHERRY_PICK_HEAD" , &commit->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_MSG_ON_ERR )) res =-1 ;if (command ==TODO_REVERT && ((opts->no_commit && res ==0 ) || res ==1 ) && -update_ref (NULL ,"REVERT_HEAD" , &commit->object.oid,NULL , +update_ref (r,NULL ,"REVERT_HEAD" , &commit->object.oid,NULL ,REF_NO_DEREF ,UPDATE_REFS_MSG_ON_ERR )) res =-1 ;
@@ -3018,7 +3018,7 @@ static int make_patch(struct repository *r, p =short_commit_name (commit);if (write_message (p,strlen (p),rebase_path_stopped_sha (),1 ) <0 )return -1 ; - res |=write_rebase_head (&commit->object.oid); + res |=write_rebase_head (r, &commit->object.oid);strbuf_addf (&buf,"%s/patch" ,get_dir (opts));memset (&log_tree_opt,0 ,sizeof (log_tree_opt));
@@ -3337,8 +3337,8 @@ static int do_reset(struct repository *r,free ((void *)desc.buffer);if (!ret) - ret =update_ref (reflog_message (opts,"reset" ,"'%.*s'" , - len, name),"HEAD" , &oid, + ret =update_ref (r,reflog_message (opts,"reset" ,"'%.*s'" , + len, name),"HEAD" , &oid,NULL ,0 ,UPDATE_REFS_MSG_ON_ERR );strbuf_release (&ref_name);
@@ -3862,7 +3862,8 @@ static int checkout_onto(struct repository *r, struct replay_opts *opts,return error (_ ("could not detach HEAD" )); } -return update_ref (NULL ,"ORIG_HEAD" , &oid,NULL ,0 ,UPDATE_REFS_MSG_ON_ERR ); +return update_ref (r,NULL ,"ORIG_HEAD" , &oid,NULL ,0 , +UPDATE_REFS_MSG_ON_ERR ); }static int stopped_at_head (struct repository *r)
@@ -4113,7 +4114,7 @@ static int pick_commits(struct repository *r, } msg =reflog_message (opts,"finish" ,"%s onto %s" , head_ref.buf, buf.buf); -if (update_ref (msg, head_ref.buf, &head, &orig, +if (update_ref (r, msg, head_ref.buf, &head, &orig,REF_NO_DEREF ,UPDATE_REFS_MSG_ON_ERR )) { res =error (_ ("could not update %s" ), head_ref.buf);
transport-helper.c +18 -14
@@ -805,9 +805,10 @@ static int push_update_ref_status(struct strbuf *buf,return !(status ==REF_STATUS_OK ); } -static int push_update_refs_status (struct helper_data *data, -struct ref *remote_refs, -int flags) +static int push_update_refs_status (struct repository *r, +struct helper_data *data, +struct ref *remote_refs, +int flags) {struct strbuf buf =STRBUF_INIT ;struct ref *ref = remote_refs;
@@ -834,7 +835,7 @@ static int push_update_refs_status(struct helper_data *data, private =apply_refspecs (&data->rs, ref->name);if (!private)continue ; -update_ref ("update by helper" , private, &ref->new_oid,NULL , +update_ref (r,"update by helper" , private, &ref->new_oid,NULL ,0 ,0 );free (private); }
@@ -868,7 +869,8 @@ static void set_common_push_options(struct transport *transport, } } -static int push_refs_with_push (struct transport *transport, +static int push_refs_with_push (struct repository *r, +struct transport *transport,struct ref *remote_refs,int flags) {int force_all = flags &TRANSPORT_PUSH_FORCE ;
@@ -950,11 +952,12 @@ static int push_refs_with_push(struct transport *transport,strbuf_release (&buf);string_list_clear (&cas_options,0 ); -return push_update_refs_status (data, remote_refs, flags); +return push_update_refs_status (r, data, remote_refs, flags); } -static int push_refs_with_export (struct transport *transport, -struct ref *remote_refs,int flags) +static int push_refs_with_export (struct repository *r, +struct transport *transport, +struct ref *remote_refs,int flags) {struct ref *ref;struct child_process *helper, exporter;
@@ -1021,7 +1024,7 @@ static int push_refs_with_export(struct transport *transport,if (finish_command (&exporter))die (_ ("error while running fast-export" )); -if (push_update_refs_status (data, remote_refs, flags)) +if (push_update_refs_status (r, data, remote_refs, flags))return 1 ;if (data->export_marks) {
@@ -1033,14 +1036,15 @@ static int push_refs_with_export(struct transport *transport,return 0 ; } -static int push_refs (struct transport *transport, -struct ref *remote_refs,int flags) +static int push_refs (struct repository *r,struct transport *transport, +struct ref *remote_refs,int flags) {struct helper_data *data = transport->data;if (process_connect (transport,1 )) {do_take_over (transport); -return transport->vtable->push_refs (transport, remote_refs, flags); +return transport->vtable->push_refs (r, transport, remote_refs, + flags); }if (!remote_refs) {
@@ -1051,10 +1055,10 @@ static int push_refs(struct transport *transport, }if (data->push) -return push_refs_with_push (transport, remote_refs, flags); +return push_refs_with_push (r, transport, remote_refs, flags);if (data->export) -return push_refs_with_export (transport, remote_refs, flags); +return push_refs_with_export (r, transport, remote_refs, flags);return -1 ; }
transport-internal.h +3 -1
@@ -2,6 +2,7 @@#define TRANSPORT_INTERNAL_H struct ref ; +struct repository ;struct transport ;struct argv_array ;
@@ -56,7 +57,8 @@ struct transport_vtable {* could be a different value from peer_ref->new_oid if the * process involved generating new commits. **/ -int (*push_refs)(struct transport *transport,struct ref *refs,int flags); +int (*push_refs)(struct repository *r,struct transport *transport, +struct ref *refs,int flags);int (*connect)(struct transport *connection,const char *name,const char *executable,int fd[2 ]);
transport.c +5 -3
@@ -446,7 +446,7 @@ void transport_update_tracking_ref(struct repository *r, struct remote *remote,if (ref->deletion) {delete_ref (r,NULL , rs.dst,NULL ,0 ); }else -update_ref ("update by push" , rs.dst, &ref->new_oid, +update_ref (r,"update by push" , rs.dst, &ref->new_oid,NULL ,0 ,0 );free (rs.dst); }
@@ -661,7 +661,8 @@ void transport_print_push_status(const char *dest, struct ref *refs,free (head); } -static int git_transport_push (struct transport *transport,struct ref *remote_refs,int flags) +static int git_transport_push (struct repository *r,struct transport *transport, +struct ref *remote_refs,int flags) {struct git_transport_data *data = transport->data;struct send_pack_args args;
@@ -1234,7 +1235,8 @@ int transport_push(struct repository *r,if (!(flags &TRANSPORT_RECURSE_SUBMODULES_ONLY )) {trace2_region_enter ("transport_push" ,"push_refs" , r); - push_ret = transport->vtable->push_refs (transport, remote_refs, flags); + push_ret = transport->vtable->push_refs ( + r, transport, remote_refs, flags);trace2_region_leave ("transport_push" ,"push_refs" , r); }else push_ret =0 ;
Signature · 1 line
gitgitgadget