From: Junio C Hamano Date: Thu, 5 Mar 2015 20:45:39 +0000 (-0800) Subject: Merge branch 'mh/refs-have-new' X-Git-Tag: v2.4.0-rc0~73 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/fd9de868c359a1bbd214e354aefdb0f1eaa898bd?ds=inline;hp=-c Merge branch 'mh/refs-have-new' Simplify the ref transaction API around how "the ref should be pointing at this object" is specified. * mh/refs-have-new: refs.h: remove duplication in function docstrings update_ref(): improve documentation ref_transaction_verify(): new function to check a reference's value ref_transaction_delete(): check that old_sha1 is not null_sha1 ref_transaction_create(): check that new_sha1 is valid commit: avoid race when creating orphan commits commit: add tests of commit races ref_transaction_delete(): remove "have_old" parameter ref_transaction_update(): remove "have_old" parameter struct ref_update: move "have_old" into "flags" refs.c: change some "flags" to "unsigned int" refs: remove the gap in the REF_* constant values refs: move REF_DELETING to refs.c --- fd9de868c359a1bbd214e354aefdb0f1eaa898bd diff --combined builtin/commit.c index 6055c760f0,682f922c73..961e467242 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -1050,7 -1050,7 +1050,7 @@@ static const char *find_author_by_nickn clear_mailmap(&mailmap); return strbuf_detach(&buf, NULL); } - die(_("No existing author found with '%s'"), name); + die(_("--author '%s' is not 'Name ' and matches no existing author"), name); } @@@ -1766,8 -1766,8 +1766,8 @@@ int cmd_commit(int argc, const char **a if (!transaction || ref_transaction_update(transaction, "HEAD", sha1, current_head - ? current_head->object.sha1 : NULL, - 0, !!current_head, sb.buf, &err) || + ? current_head->object.sha1 : null_sha1, + 0, sb.buf, &err) || ref_transaction_commit(transaction, &err)) { rollback_index_files(); die("%s", err.buf); diff --combined builtin/fetch.c index 75a55e590b,719bf4f244..f9512652cf --- a/builtin/fetch.c +++ b/builtin/fetch.c @@@ -11,6 -11,7 +11,6 @@@ #include "run-command.h" #include "parse-options.h" #include "sigchain.h" -#include "transport.h" #include "submodule.h" #include "connected.h" #include "argv-array.h" @@@ -415,8 -416,10 +415,10 @@@ static int s_update_ref(const char *act transaction = ref_transaction_begin(&err); if (!transaction || - ref_transaction_update(transaction, ref->name, ref->new_sha1, - ref->old_sha1, 0, check_old, msg, &err)) + ref_transaction_update(transaction, ref->name, + ref->new_sha1, + check_old ? ref->old_sha1 : NULL, + 0, msg, &err)) goto fail; ret = ref_transaction_commit(transaction, &err); diff --combined cache.h index 4d02efc905,ab265be1cd..761c5704b2 --- a/cache.h +++ b/cache.h @@@ -568,7 -568,7 +568,7 @@@ extern void update_index_if_able(struc extern int hold_locked_index(struct lock_file *, int); extern void set_alternate_index_output(const char *); - extern int delete_ref(const char *, const unsigned char *sha1, int delopt); + extern int delete_ref(const char *, const unsigned char *sha1, unsigned int flags); /* Environment bits from configuration mechanism */ extern int trust_executable_bit; @@@ -1254,10 -1254,6 +1254,10 @@@ extern int unpack_object_header(struct * * Any callback that is NULL will be ignored. Callbacks returning non-zero * will end the iteration. + * + * In the "buf" variant, "path" is a strbuf which will also be used as a + * scratch buffer, but restored to its original contents before + * the function returns. */ typedef int each_loose_object_fn(const unsigned char *sha1, const char *path, @@@ -1273,11 -1269,6 +1273,11 @@@ int for_each_loose_file_in_objdir(cons each_loose_cruft_fn cruft_cb, each_loose_subdir_fn subdir_cb, void *data); +int for_each_loose_file_in_objdir_buf(struct strbuf *path, + each_loose_object_fn obj_cb, + each_loose_cruft_fn cruft_cb, + each_loose_subdir_fn subdir_cb, + void *data); /* * Iterate over loose and packed objects in both the local @@@ -1507,7 -1498,7 +1507,7 @@@ extern const char *pager_program extern int pager_in_use(void); extern int pager_use_color; extern int term_columns(void); -extern int decimal_width(int); +extern int decimal_width(uintmax_t); extern int check_pager_config(const char *cmd); extern const char *editor_program; diff --combined fast-import.c index aac2c24f74,1e72bfbd4c..b82fcdd24e --- a/fast-import.c +++ b/fast-import.c @@@ -947,12 -947,9 +947,12 @@@ static void unkeep_all_packs(void static void end_packfile(void) { - if (!pack_data) + static int running; + + if (running || !pack_data) return; + running = 1; clear_delta_base_cache(); if (object_count) { struct packed_git *new_p; @@@ -1002,7 -999,6 +1002,7 @@@ } free(pack_data); pack_data = NULL; + running = 0; /* We can't carry a delta across packfiles. */ strbuf_release(&last_blob.data); @@@ -1720,7 -1716,7 +1720,7 @@@ static int update_branch(struct branch transaction = ref_transaction_begin(&err); if (!transaction || ref_transaction_update(transaction, b->name, b->sha1, old_sha1, - 0, 1, msg, &err) || + 0, msg, &err) || ref_transaction_commit(transaction, &err)) { ref_transaction_free(transaction); error("%s", err.buf); @@@ -1760,8 -1756,8 +1760,8 @@@ static void dump_tags(void strbuf_reset(&ref_name); strbuf_addf(&ref_name, "refs/tags/%s", t->name); - if (ref_transaction_update(transaction, ref_name.buf, t->sha1, - NULL, 0, 0, msg, &err)) { + if (ref_transaction_update(transaction, ref_name.buf, + t->sha1, NULL, 0, msg, &err)) { failure |= error("%s", err.buf); goto cleanup; }