summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * refs: use name "prefix" consistentlyMichael Haggerty2016-06-201-12/+12
| | | | | | | | | | | | | | | | | | | | In the context of the for_each_ref() functions, call the prefix that references must start with "prefix". (In some places it was called "base".) This is clearer, and also prevents confusion with another planned use of the word "base". Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * do_for_each_ref(): move docstring to the header fileMichael Haggerty2016-06-201-9/+0
| | | | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'mh/update-ref-errors'Junio C Hamano2016-07-251-32/+42
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Error handling in the codepaths that updates refs has been improved. * mh/update-ref-errors: lock_ref_for_update(): avoid a symref resolution lock_ref_for_update(): make error handling more uniform t1404: add more tests of update-ref error handling t1404: document function test_update_rejected t1404: remove "prefix" argument to test_update_rejected t1404: rename file to t1404-update-ref-errors.sh
| * | lock_ref_for_update(): avoid a symref resolutionmh/update-ref-errorsMichael Haggerty2016-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we're overwriting a symref with a SHA-1, we need to resolve the value of the symref (1) to check against update->old_sha1 and (2) to write to its reflog. However, we've already read the symref itself and know its referent. So there is no need to read the symref's value through the symref; we can read the referent directly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | lock_ref_for_update(): make error handling more uniformMichael Haggerty2016-06-201-32/+42
| |/ | | | | | | | | | | | | | | | | | | | | To aid the effort, extract a new function, check_old_oid(), and use it in the two places where the read value of the reference has to be checked against update->old_sha1. Update tests to reflect the improvements. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'mh/split-under-lock'Junio C Hamano2016-07-251-211/+719
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Further preparatory work on the refs API before the pluggable backend series can land. * mh/split-under-lock: (33 commits) lock_ref_sha1_basic(): only handle REF_NODEREF mode commit_ref_update(): remove the flags parameter lock_ref_for_update(): don't resolve symrefs lock_ref_for_update(): don't re-read non-symbolic references refs: resolve symbolic refs first ref_transaction_update(): check refname_is_safe() at a minimum unlock_ref(): move definition higher in the file lock_ref_for_update(): new function add_update(): initialize the whole ref_update verify_refname_available(): adjust constness in declaration refs: don't dereference on rename refs: allow log-only updates delete_branches(): use resolve_refdup() ref_transaction_commit(): correctly report close_ref() failure ref_transaction_create(): disallow recursive pruning refs: make error messages more consistent lock_ref_sha1_basic(): remove unneeded local variable read_raw_ref(): move docstring to header file read_raw_ref(): improve docstring read_raw_ref(): rename symref argument to referent ...
| * lock_ref_sha1_basic(): only handle REF_NODEREF modemh/split-under-lockMichael Haggerty2016-06-131-34/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now lock_ref_sha1_basic() is only called with flags==REF_NODEREF. So we don't have to handle other cases anymore. This enables several simplifications, the most interesting of which come from the fact that ref_lock::orig_ref_name is now always the same as ref_lock::ref_name: * Remove ref_lock::orig_ref_name * Remove local variable orig_refname from lock_ref_sha1_basic() * ref_name can be initialize once and its value reused * commit_ref_update() never has to write to the reflog for lock->orig_ref_name Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * commit_ref_update(): remove the flags parameterMichael Haggerty2016-06-131-7/+7
| | | | | | | | | | | | | | commit_ref_update() is now only called with flags=0. So remove the flags parameter entirely. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * lock_ref_for_update(): don't resolve symrefsMichael Haggerty2016-06-131-30/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a transaction includes a non-NODEREF update to a symbolic reference, we don't have to look it up in lock_ref_for_update(). The reference will be dereferenced anyway when the split-off update is processed. This change requires that we store a backpointer from the split-off update to its parent update, for two reasons: * We still want to report the original reference name in error messages. So if an error occurs when checking the split-off update's old_sha1, walk the parent_update pointers back to find the original reference name, and report that one. * We still need to write the old_sha1 of the symref to its reflog. So after we read the split-off update's reference value, walk the parent_update pointers back and fill in their old_sha1 fields. Aside from eliminating unnecessary reads, this change fixes a subtle (though not very serious) race condition: in the old code, the old_sha1 of the symref was resolved before the reference that it pointed at was locked. So it was possible that the old_sha1 value logged to the symref's reflog could be wrong if another process changed the downstream reference before it was locked. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * lock_ref_for_update(): don't re-read non-symbolic referencesMichael Haggerty2016-06-131-18/+30
| | | | | | | | | | | | | | | | | | | | | | Before the previous patch, our first read of the reference happened before the reference was locked, so we couldn't trust its value and had to read it again. But now that our first read of the reference happens after acquiring the lock, there is no need to read it a second time. So move the read_ref_full() call into the (update->type & REF_ISSYMREF) block. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * refs: resolve symbolic refs firstMichael Haggerty2016-06-131-38/+470
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before committing ref updates, split symbolic ref updates into two parts: an update to the underlying ref, and a log-only update to the symbolic ref. This ensures that both references are locked correctly during the transaction, including while their reflogs are updated. Similarly, if the reference pointed to by HEAD is modified directly, add a separate log-only update to HEAD, rather than leaving the job of updating HEAD's reflog to commit_ref_update(). This change ensures that HEAD is locked correctly while its reflog is being modified, as well as being cheaper (HEAD only needs to be resolved once). This makes use of a new function, lock_raw_ref(), which is analogous to read_raw_ref(), but acquires a lock on the reference before reading it. This change still has two problems: * There are redundant read_ref_full() reference lookups. * It is still possible to get incorrect reflogs for symbolic references if there is a concurrent update by another process, since the old_oid of a symref is determined before the lock on the pointed-to ref is held. Both problems will soon be fixed. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> WIP
| * unlock_ref(): move definition higher in the fileMichael Haggerty2016-06-131-10/+10
| | | | | | | | | | | | This avoids the need for a forward declaration in the next patch. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * lock_ref_for_update(): new functionMichael Haggerty2016-06-131-67/+85
| | | | | | | | | | | | | | Extract a new function, lock_ref_for_update(), from ref_transaction_commit(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * verify_refname_available(): adjust constness in declarationMichael Haggerty2016-06-131-2/+2
| | | | | | | | | | | | The two string_list arguments can be const. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * refs: don't dereference on renameDavid Turner2016-06-131-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When renaming refs, don't dereference either the origin or the destination before renaming. The origin does not need to be dereferenced because it is presently forbidden to rename symbolic refs. Not dereferencing the destination fixes a bug where renaming on top of a broken symref would use the pointed-to ref name for the moved reflog. Add a test for the reflog bug. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * refs: allow log-only updatesDavid Turner2016-06-131-6/+10
| | | | | | | | | | | | | | | | | | | | The refs infrastructure learns about log-only ref updates, which only update the reflog. Later, we will use this to separate symbolic reference resolution from ref updating. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * ref_transaction_commit(): correctly report close_ref() failureMichael Haggerty2016-06-131-0/+1
| | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * ref_transaction_create(): disallow recursive pruningMichael Haggerty2016-06-131-1/+1
| | | | | | | | | | | | | | | | It is nonsensical (and a little bit dangerous) to use REF_ISPRUNING without REF_NODEREF. Forbid it explicitly. Change the one REF_ISPRUNING caller to pass REF_NODEREF too. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * refs: make error messages more consistentMichael Haggerty2016-06-131-16/+16
| | | | | | | | | | | | | | | | * Always start error messages with a lower-case letter. * Always enclose reference names in single quotes. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * lock_ref_sha1_basic(): remove unneeded local variableMichael Haggerty2016-06-131-6/+3
| | | | | | | | | | | | | | | | resolve_ref_unsafe() can cope with being called with NULL passed to its flags argument. So lock_ref_sha1_basic() can just hand its own type parameter through. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): move docstring to header fileMichael Haggerty2016-06-131-38/+0
| | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): improve docstringMichael Haggerty2016-06-131-17/+24
| | | | | | | | | | | | | | Among other things, document the (important!) requirement that input refname be checked for safety before calling this function. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): rename symref argument to referentMichael Haggerty2016-06-131-10/+11
| | | | | | | | | | | | | | After all, it doesn't hold the symbolic reference, but rather the reference referred to. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): clear *type at start of functionMichael Haggerty2016-06-131-0/+1
| | | | | | | | | | | | This is more convenient and less error-prone for callers. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): rename flags argument to typeMichael Haggerty2016-06-131-9/+9
| | | | | | | | | | | | | | | | This will hopefully reduce confusion with the "flags" arguments that are used in many functions in this module as an input parameter to choose how the function should operate. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * ref_transaction_commit(): remove local variables n and updatesMichael Haggerty2016-06-131-22/+20
| | | | | | | | | | | | | | | | | | | | | | These microoptimizations don't make a significant difference in speed. And they cause problems if somebody ever wants to modify the function to add updates to a transaction as part of processing it, as will happen shortly. Make the same changes in initial_ref_transaction_commit(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * rename_ref(): remove unneeded local variableMichael Haggerty2016-05-051-6/+3
| | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * commit_ref_update(): write error message to *err, not stderrMichael Haggerty2016-05-051-1/+1
| | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * read_raw_ref(): don't get confused by an empty directoryMichael Haggerty2016-05-051-1/+10
| | | | | | | | | | | | | | | | Even if there is an empty directory where we look for the loose version of a reference, check for a packed reference before giving up. This fixes the failing test that was introduced two commits ago. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
| * commit_ref(): if there is an empty dir in the way, delete itMichael Haggerty2016-05-051-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part of the bug revealed in the last commit is that resolve_ref_unsafe() incorrectly returns EISDIR if it finds a directory in the place where it is looking for a loose reference, even if the corresponding packed reference exists. lock_ref_sha1_basic() notices the bogus EISDIR, and use it as an indication that it should call remove_empty_directories() and call resolve_ref_unsafe() again. But resolve_ref_unsafe() shouldn't report EISDIR in this case. If we would simply make that change, then remove_empty_directories() wouldn't get called anymore, and the empty directory would get in the way when commit_ref() calls commit_lock_file() to rename the lockfile into place. So instead of relying on lock_ref_sha1_basic() to delete empty directories, teach commit_ref(), just before calling commit_lock_file(), to check whether a directory is in the way, and if so, try to delete it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
* | coccinelle: apply object_id Coccinelle transformationsbrian m. carlson2016-06-281-2/+2
|/ | | | | | | | | Apply the set of semantic patches from contrib/coccinelle to convert some leftover places using struct object_id's hash member to instead use the wrapper functions that take struct object_id natively. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'dt/pre-refs-backend'Junio C Hamano2016-04-251-268/+138
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code restructuring around the "refs" area to prepare for pluggable refs backends. * dt/pre-refs-backend: (24 commits) refs: on symref reflog expire, lock symref not referrent refs: move resolve_ref_unsafe into common code show_head_ref(): check the result of resolve_ref_namespace() check_aliased_update(): check that dst_name is non-NULL checkout_paths(): remove unneeded flag variable cmd_merge(): remove unneeded flag variable fsck_head_link(): remove unneeded flag variable read_raw_ref(): change flags parameter to unsigned int files-backend: inline resolve_ref_1() into resolve_ref_unsafe() read_raw_ref(): manage own scratch space files-backend: break out ref reading resolve_ref_1(): eliminate local variable "bad_name" resolve_ref_1(): reorder code resolve_ref_1(): eliminate local variable resolve_ref_unsafe(): ensure flags is always set resolve_ref_unsafe(): use for loop to count up to MAXDEPTH resolve_missing_loose_ref(): simplify semantics t1430: improve test coverage of deletion of badly-named refs t1430: test for-each-ref in the presence of badly-named refs t1430: don't rely on symbolic-ref for creating broken symrefs ...
| * refs: on symref reflog expire, lock symref not referrentdt/pre-refs-backendDavid Turner2016-04-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | When locking a symbolic ref to expire a reflog, lock the symbolic ref (using REF_NODEREF) instead of its referent. Add a test for this. Signed-off-by: David Turner <dturner@twopensource.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: move resolve_ref_unsafe into common codeDavid Turner2016-04-101-79/+3
| | | | | | | | | | | | | | | | | | | | Now that resolve_ref_unsafe's only interaction with the backend is through read_raw_ref, we can move it into the common code. Later, we'll replace read_raw_ref with a backend function. Signed-off-by: David Turner <dturner@twopensource.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * read_raw_ref(): change flags parameter to unsigned intMichael Haggerty2016-04-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | read_raw_ref() is going to be part of the vtable for reference backends, so clean up its interface to use "unsigned int flags" rather than "int flags". Its caller still uses signed int for its flags arguments. But changing that would touch a lot of code, so leave it for now. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * files-backend: inline resolve_ref_1() into resolve_ref_unsafe()Michael Haggerty2016-04-101-22/+9
| | | | | | | | | | | | | | | | resolve_ref_unsafe() wasn't doing anything useful anymore. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * read_raw_ref(): manage own scratch spaceMichael Haggerty2016-04-101-35/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of creating scratch space in resolve_ref_unsafe() and passing it down through resolve_ref_1 to read_raw_ref(), teach read_raw_ref() to manage its own scratch space. This reduces coupling across the functions at the cost of some extra allocations. Also, when read_raw_ref() is implemented for different reference backends, the other implementations might have different scratch space requirements. Note that we now preserve errno across the calls to strbuf_release(), which calls free() and can thus theoretically overwrite errno. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * files-backend: break out ref readingDavid Turner2016-04-101-99/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | Refactor resolve_ref_1 in terms of a new function read_raw_ref, which is responsible for reading ref data from the ref storage. Later, we will make read_raw_ref a pluggable backend function, and make resolve_ref_unsafe common. Signed-off-by: David Turner <dturner@twopensource.com> Helped-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_ref_1(): eliminate local variable "bad_name"Michael Haggerty2016-04-101-8/+5
| | | | | | | | | | | | | | | | We can use (*flags & REF_BAD_NAME) for that purpose. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_ref_1(): reorder codeMichael Haggerty2016-04-101-2/+2
| | | | | | | | | | | | | | | | There is no need to adjust *flags if we're just about to fail. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_ref_1(): eliminate local variableMichael Haggerty2016-04-101-7/+6
| | | | | | | | | | | | | | | | | | In place of `buf`, use `refname`, which is anyway a better description of what is being pointed at. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_ref_unsafe(): ensure flags is always setMichael Haggerty2016-04-101-18/+13
| | | | | | | | | | | | | | | | | | | | If the caller passes flags==NULL, then set it to point at a local scratch variable. This removes the need for a lot of "if (flags)" guards in resolve_ref_1() and resolve_missing_loose_ref(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_ref_unsafe(): use for loop to count up to MAXDEPTHMichael Haggerty2016-04-101-7/+6
| | | | | | | | | | | | | | | | The loop's there anyway; we might as well use it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_missing_loose_ref(): simplify semanticsMichael Haggerty2016-04-101-14/+10
| | | | | | | | | | | | | | | | | | | | | | Make resolve_missing_loose_ref() only responsible for looking up a packed reference, without worrying about whether we want to read or write the reference and without setting errno on failure. Move the other logic to the caller. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: move for_each_*ref* functions into common codeDavid Turner2016-04-101-57/+5
| | | | | | | | | | | | | | | | | | | | | | | | Make do_for_each_ref take a submodule as an argument instead of a ref_cache. Since all for_each_*ref* functions are defined in terms of do_for_each_ref, we can then move them into the common code. Later, we can simply make do_for_each_ref into a backend function. Signed-off-by: David Turner <dturner@twopensource.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: move head_ref{,_submodule} to the common codeDavid Turner2016-04-101-28/+0
| | | | | | | | | | | | | | | | | | | | These don't use any backend-specific functions. These were previously defined in terms of the do_head_ref helper function, but since they are otherwise identical, we don't need that function. Signed-off-by: David Turner <dturner@twopensource.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | set_worktree_head_symref(): fix error messageky/branch-m-worktreeKazuki Yamaguchi2016-04-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit an informative error when failed to hold lock of HEAD. 2233066e (refs: add a new function set_worktree_head_symref, 2016-03-27) added set_worktree_head_symref(), but this is missing a call to unable_to_lock_message() after hold_lock_file_for_update() fails, so it emits an empty error message: % git branch -m oldname newname error: error: HEAD of working tree /path/to/wt is not updated fatal: Branch renamed to newname, but HEAD is not updated! Thanks to Eric Sunshine for pointing this out. Signed-off-by: Kazuki Yamaguchi <k@rhe.jp> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | refs: add a new function set_worktree_head_symrefKazuki Yamaguchi2016-04-041-0/+35
|/ | | | | | | | | | | | | | | | | | | Add a new function set_worktree_head_symref, to update HEAD symref for the specified worktree. To update HEAD of a linked working tree, create_symref("worktrees/$work_tree/HEAD", "refs/heads/$branch", msg) could be used. However when it comes to updating HEAD of the main working tree, it is unusable because it uses $GIT_DIR for worktree-specific symrefs (HEAD). The new function takes git_dir (real directory) as an argument, and updates HEAD of the working tree. This function will be used when renaming a branch. Signed-off-by: Kazuki Yamaguchi <k@rhe.jp> Acked-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jk/tighten-alloc'Junio C Hamano2016-02-261-14/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update various codepaths to avoid manually-counted malloc(). * jk/tighten-alloc: (22 commits) ewah: convert to REALLOC_ARRAY, etc convert ewah/bitmap code to use xmalloc diff_populate_gitlink: use a strbuf transport_anonymize_url: use xstrfmt git-compat-util: drop mempcpy compat code sequencer: simplify memory allocation of get_message test-path-utils: fix normalize_path_copy output buffer size fetch-pack: simplify add_sought_entry fast-import: simplify allocation in start_packfile write_untracked_extension: use FLEX_ALLOC helper prepare_{git,shell}_cmd: use argv_array use st_add and st_mult for allocation size computation convert trivial cases to FLEX_ARRAY macros use xmallocz to avoid size arithmetic convert trivial cases to ALLOC_ARRAY convert manual allocations to argv_array argv-array: add detach function add helpers for allocating flex-array structs harden REALLOC_ARRAY and xcalloc against size_t overflow tree-diff: catch integer overflow in combine_diff_path allocation ...
| * convert trivial cases to FLEX_ARRAY macrosJeff King2016-02-221-14/+5
| | | | | | | | | | | | | | | | | | | | Using FLEX_ARRAY macros reduces the amount of manual computation size we have to do. It also ensures we don't overflow size_t, and it makes sure we write the same number of bytes that we allocated. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>