aboutsummaryrefslogtreecommitdiff
path: root/refs.c
Commit message (Collapse)AuthorAge
* Merge branch 'mh/ref-api'Junio C Hamano2011-12-20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * mh/ref-api: add_ref(): take a (struct ref_entry *) parameter create_ref_entry(): extract function from add_ref() repack_without_ref(): remove temporary resolve_gitlink_ref_recursive(): change to work with struct ref_cache Pass a (ref_cache *) to the resolve_gitlink_*() helper functions resolve_gitlink_ref(): improve docstring get_ref_dir(): change signature refs: change signatures of get_packed_refs() and get_loose_refs() is_dup_ref(): extract function from sort_ref_array() add_ref(): add docstring parse_ref_line(): add docstring is_refname_available(): remove the "quiet" argument clear_ref_array(): rename from free_ref_array() refs: rename parameters result -> sha1 refs: rename "refname" variables struct ref_entry: document name member Conflicts: cache.h refs.c
| * add_ref(): take a (struct ref_entry *) parameterMichael Haggerty2011-12-12
| | | | | | | | | | | | | | | | | | Take a pointer to the ref_entry to add to the array, rather than creating the ref_entry within the function. This opens the way to having multiple kinds of ref_entries. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * create_ref_entry(): extract function from add_ref()Michael Haggerty2011-12-12
| | | | | | | | | | | | | | Separate the creation of the ref_entry from its addition to a ref_array. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * repack_without_ref(): remove temporaryMichael Haggerty2011-12-12
| | | | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * resolve_gitlink_ref_recursive(): change to work with struct ref_cacheMichael Haggerty2011-12-12
| | | | | | | | | | | | | | | | | | resolve_gitlink_ref() and resolve_gitlink_ref_recursive(), together, basically duplicated the code in git_path_submodule(). So use that function instead. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * Pass a (ref_cache *) to the resolve_gitlink_*() helper functionsMichael Haggerty2011-12-12
| | | | | | | | | | | | | | And remove some redundant arguments from resolve_gitlink_packed_ref(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * get_ref_dir(): change signatureMichael Haggerty2011-12-12
| | | | | | | | | | | | | | | | Change get_ref_dir() to take a (struct ref_cache *) in place of the submodule name. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: change signatures of get_packed_refs() and get_loose_refs()Michael Haggerty2011-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change get_packed_refs() and get_loose_refs() to take a (struct ref_cache *) instead of the name of the submodule. Change get_ref_dir() to take a submodule name (i.e., "" for the main module) rather than a submodule pointer (i.e., NULL for the main module) so that refs->name can be used as its argument. (In a moment this function will also be changed to take a (struct ref_cache *), too.) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * is_dup_ref(): extract function from sort_ref_array()Michael Haggerty2011-12-12
| | | | | | | | | | | | | | Giving the function a name makes the code easier to understand. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * add_ref(): add docstringMichael Haggerty2011-12-12
| | | | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * parse_ref_line(): add docstringMichael Haggerty2011-12-12
| | | | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * is_refname_available(): remove the "quiet" argumentMichael Haggerty2011-12-12
| | | | | | | | | | | | | | | | quiet was always set to 0, so get rid of it. Add a function docstring for good measure. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * clear_ref_array(): rename from free_ref_array()Michael Haggerty2011-12-12
| | | | | | | | | | | | | | | | Rename the function since it doesn't actually free the array object that is passed to it. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: rename parameters result -> sha1Michael Haggerty2011-12-12
| | | | | | | | | | | | | | | | Try consistently to use the name "sha1" for parameters to which a SHA1 will be stored. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * refs: rename "refname" variablesMichael Haggerty2011-12-12
| | | | | | | | | | | | | | | | Try to consistently use the variable name "refname" when referring to a string that names a reference. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * struct ref_entry: document name memberMichael Haggerty2011-12-12
| | | | | | | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Rename resolve_ref() to resolve_ref_unsafe()Nguyễn Thái Ngọc Duy2011-12-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | resolve_ref() may return a pointer to a shared buffer and can be overwritten by the next resolve_ref() calls. Callers need to pay attention, not to keep the pointer when the next call happens. Rename with "_unsafe" suffix to warn developers (or reviewers) before introducing new call sites. This patch is generated using the following command git grep -l 'resolve_ref(' -- '*.[ch]'|xargs sed -i 's/resolve_ref(/resolve_ref_unsafe(/g' Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Convert resolve_ref+xstrdup to new resolve_refdup functionNguyễn Thái Ngọc Duy2011-12-13
|/ | | | | Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'nd/resolve-ref'Junio C Hamano2011-12-09
|\ | | | | | | | | | | | | | | | | | | | | * nd/resolve-ref: Copy resolve_ref() return value for longer use Convert many resolve_ref() calls to read_ref*() and ref_exists() Conflicts: builtin/fmt-merge-msg.c builtin/merge.c refs.c
| * Convert many resolve_ref() calls to read_ref*() and ref_exists()Nguyễn Thái Ngọc Duy2011-11-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | resolve_ref() may return a pointer to a static buffer, which is not safe for long-term use because if another resolve_ref() call happens, the buffer may be changed. Many call sites though do not care about this buffer. They simply check if the return value is NULL or not. Convert all these call sites to new wrappers to reduce resolve_ref() calls from 57 to 34. If we change resolve_ref() prototype later on to avoid passing static buffer out, this helps reduce changes. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/pull-signed-tag'Junio C Hamano2011-12-09
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * jc/pull-signed-tag: commit-tree: teach -m/-F options to read logs from elsewhere commit-tree: update the command line parsing commit: teach --amend to carry forward extra headers merge: force edit and no-ff mode when merging a tag object commit: copy merged signed tags to headers of merge commit merge: record tag objects without peeling in MERGE_HEAD merge: make usage of commit->util more extensible fmt-merge-msg: Add contents of merged tag in the merge message fmt-merge-msg: package options into a structure fmt-merge-msg: avoid early returns refs DWIMmery: use the same rule for both "git fetch" and others fetch: allow "git fetch $there v1.0" to fetch a tag merge: notice local merging of tags and keep it unwrapped fetch: do not store peeled tag object names in FETCH_HEAD Split GPG interface into its own helper library Conflicts: builtin/fmt-merge-msg.c builtin/merge.c
| * | refs DWIMmery: use the same rule for both "git fetch" and othersJunio C Hamano2011-11-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "git log frotz" can DWIM to "refs/remotes/frotz/HEAD", but in the remote access context, "git fetch frotz" to fetch what the other side happened to have fetched from what it calls 'frotz' (which may not have any relation to what we consider is 'frotz') the last time would not make much sense, so the fetch rules table did not include "refs/remotes/%.*s/HEAD". When the user really wants to, "git fetch $there remotes/frotz/HEAD" would let her do so anyway, so this is not about safety or security; it merely is about confusion avoidance and discouraging meaningless usage. Specifically, it is _not_ about ambiguity avoidance. A name that would become ambiguous if we use the same rules table for both fetch and local rev-parse would be ambiguous locally at the remote side. So for the same reason as we added rule to allow "git fetch $there v1.0" instead of "git fetch $there tags/v1.0" in the previous commit, here is a bit longer rope for the users, which incidentally simplifies our code. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | fetch: allow "git fetch $there v1.0" to fetch a tagJunio C Hamano2011-11-07
| | | | | | | | | | | | | | | | | | | | | You can already do so with "git fetch $there tags/v1.0" but if it is not ambiguous there is no reason to force users to type more. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | refs: loosen over-strict "format" checkJunio C Hamano2011-11-16
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The add_extra_ref() interface is used to add an extra-ref that is _not_ our ref for the purpose of helping auto-following of tags and reducing object transfer from remote repository, and they are typically formatted as a tagname followed by ^{} to make sure no valid refs match that pattern. In other words, these entries are deliberately formatted not to pass check-refname-format test. A recent series however added a test unconditionally to the add_ref() function that is called from add_extra_ref(). The check may be sensible for other two callsites of the add_ref() interface, but definitely is a wrong thing to do in add_extra_ref(). Disable it. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
* | Merge branch 'jc/broken-ref-dwim-fix'Junio C Hamano2011-10-21
|\ \ | | | | | | | | | | | | | | | | | | * jc/broken-ref-dwim-fix: resolve_ref(): report breakage to the caller without warning resolve_ref(): expose REF_ISBROKEN flag refs.c: move dwim_ref()/dwim_log() from sha1_name.c
| * | resolve_ref(): report breakage to the caller without warningJunio C Hamano2011-10-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 629cd3a (resolve_ref(): emit warnings for improperly-formatted references, 2011-09-15) made resolve_ref() warn against files that are found in the directories the ref dwimmery looks at. The intent may be good, but these messages come from a wrong level of the API hierarchy. Instead record the breakage in "flags" whose purpose is to explain the result of the function to the caller, who is in a much better position to make intelligent decision based on the information. This updates sha1_name.c::dwim_ref() to warn against such a broken candidate only when it does not appear directly below $GIT_DIR to restore the traditional behaviour, as we know many files directly underneath $GIT_DIR/ are not refs. Warning against "git show config --" with "$GIT_DIR/config does not look like a well-formed ref" does not make sense, and we may later tweak the dwimmery not to even consider them as candidates, but that is a longer term topic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | resolve_ref(): expose REF_ISBROKEN flagJunio C Hamano2011-10-19
| | | | | | | | | | | | | | | | | | | | | | | | Instead of keeping this as an internal API, let the callers find out the reason why resolve_ref() returned NULL is not because there was no such file in $GIT_DIR but because a file was corrupt. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | refs.c: move dwim_ref()/dwim_log() from sha1_name.cJunio C Hamano2011-10-12
| | | | | | | | | | | | | | | | | | | | | | | | Both dwim_ref()/dwim_log() functions are intimately related to the ref parsing rules defined in refs.c and better fits there. Move them together with substitute_branch_name(), a file scope static helper function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'mh/ref-api'Junio C Hamano2011-10-21
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * mh/ref-api: clear_ref_cache(): inline function write_ref_sha1(): only invalidate the loose ref cache clear_ref_cache(): extract two new functions clear_ref_cache(): rename parameter invalidate_ref_cache(): expose this function in the refs API invalidate_ref_cache(): take the submodule as parameter invalidate_ref_cache(): rename function from invalidate_cached_refs()
| * | | clear_ref_cache(): inline functionMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clear_ref_cache() was only called from one place, so inline it there. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | write_ref_sha1(): only invalidate the loose ref cacheMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since write_ref_sha1() can only write loose refs and cannot write symbolic refs, there is no need for it to invalidate the packed ref cache. Suggested by: Martin Fick <mfick@codeaurora.org> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | clear_ref_cache(): extract two new functionsMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extract two new functions from clear_cached_refs(): clear_loose_ref_cache() and clear_packed_ref_cache(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | clear_ref_cache(): rename parameterMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ...for consistency with the rest of this module. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | invalidate_ref_cache(): expose this function in the refs APIMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make invalidate_ref_cache() an official part of the refs API. It is currently a fact of life that code outside of refs.c mucks about with references. This change gives such code a way of informing the refs module that it should no longer trust its cache. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | invalidate_ref_cache(): take the submodule as parameterMichael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of invalidating the ref cache on an all-or-nothing basis, invalidate the cache for a specific submodule. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | invalidate_ref_cache(): rename function from invalidate_cached_refs()Michael Haggerty2011-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is the cache that is being invalidated, not the references, and the new name makes this unambiguous. Rename other items analogously: * struct cached_refs -> struct ref_cache * cached_refs (the variable) -> ref_cache * clear_cached_refs() -> clear_ref_cache() * create_cached_refs() -> create_ref_cache() * get_cached_refs() -> get_ref_cache() Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'jc/maint-remove-renamed-ref'Junio C Hamano2011-10-21
|\ \ \ \ | |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | * jc/maint-remove-renamed-ref: branch -m/-M: remove undocumented RENAMED-REF Conflicts: refs.c
| * | | branch -m/-M: remove undocumented RENAMED-REFJunio C Hamano2011-10-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit message for c976d41 (git-branch: add options and tests for branch renaming, 2006-11-28) mentions RENAME_REF but otherwise this is not documented anywhere, and it does not appear in any of the tests. Worse yet, the name of the actual file is "RENAMED-REF". This was supposed to hold the commit object name at the tip of the branch the most recent "branch -m/-M" renamed, but that is not necessary in order to be able to recover from a mistake. Even when "branch -M A B" overwrites an existing branch B, what is kept in RENAMED-REF is the commit at the tip of the original branch A, not the commit B from the now-lost branch. Just remove this unused "feature". Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | resolve_gitlink_packed_ref(): fix mismergeJunio C Hamano2011-10-17
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2c5c66b (Merge branch 'jp/get-ref-dir-unsorted', 2011-10-10) merged a topic that forked from the mainline before a new helper function get_packed_refs() refactored code to read packed-refs file. The merge made the call to the helper function with an incorrect argument. The parameter to the function has to be a path to the submodule. Fix the mismerge. Helped-by: Mark Levedahl <mlevedahl@gmail.com> Helped-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'jp/get-ref-dir-unsorted'Junio C Hamano2011-10-10
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * jp/get-ref-dir-unsorted: refs.c: free duplicate entries in the ref array instead of leaking them refs.c: abort ref search if ref array is empty refs.c: ensure struct whose member may be passed to realloc is initialized refs: Use binary search to lookup refs faster Don't sort ref_list too early Conflicts: refs.c
| * | | refs.c: free duplicate entries in the ref array instead of leaking themBrandon Casey2011-10-10
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | refs.c: abort ref search if ref array is emptyBrandon Casey2011-10-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bsearch() implementation on IRIX 6.5 segfaults if it is passed NULL for the base array argument even if number-of-elements is zero. So, let's work around it by detecting an empty array and aborting early. This is a useful optimization in its own right anyway, since we avoid a useless allocation and initialization of the ref_entry when the ref array is empty. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | refs.c: ensure struct whose member may be passed to realloc is initializedBrandon Casey2011-10-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The variable "refs" is allocated on the stack but is not initialized. It is passed to read_packed_refs(), and its struct members may eventually be passed to add_ref() and ALLOC_GROW(). Since the structure has not been initialized, its members may contain random non-zero values. So let's initialize it. The call sequence looks something like this: resolve_gitlink_packed_ref(...) { struct cached_refs refs; ... read_packed_refs(f, &refs); ... } read_packed_refs(FILE*, struct cached_refs *cached_refs) { ... add_ref(name, sha1, flag, &cached_refs->packed, &last); ... } add_ref(..., struct ref_array *refs, struct ref_entry **) { ... ALLOC_GROW(refs->refs, refs->nr + 1, refs->alloc); } Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | refs: Use binary search to lookup refs fasterJulian Phillips2011-09-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we linearly search through lists of refs when we need to find a specific ref. This can be very slow if we need to lookup a large number of refs. By changing to a binary search we can make this faster. In order to be able to use a binary search we need to change from using linked lists to arrays, which we can manage using ALLOC_GROW. We can now also use the standard library qsort function to sort the refs arrays. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Don't sort ref_list too earlyJulian Phillips2011-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_ref_dir is called recursively for subdirectories, which means that we were calling sort_ref_list for each directory of refs instead of once for all the refs. This is a massive wast of processing, so now just call sort_ref_list on the result of the top-level get_ref_dir, so that the sort is only done once. In the common case of only a few different directories of refs the difference isn't very noticable, but it becomes very noticeable when you have a large number of direcotries containing refs (e.g. as created by Gerrit). Reported by Martin Fick. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'mh/check-ref-format-3'Junio C Hamano2011-10-10
|\ \ \ \ | | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * mh/check-ref-format-3: (23 commits) add_ref(): verify that the refname is formatted correctly resolve_ref(): expand documentation resolve_ref(): also treat a too-long SHA1 as invalid resolve_ref(): emit warnings for improperly-formatted references resolve_ref(): verify that the input refname has the right format remote: avoid passing NULL to read_ref() remote: use xstrdup() instead of strdup() resolve_ref(): do not follow incorrectly-formatted symbolic refs resolve_ref(): extract a function get_packed_ref() resolve_ref(): turn buffer into a proper string as soon as possible resolve_ref(): only follow a symlink that contains a valid, normalized refname resolve_ref(): use prefixcmp() resolve_ref(): explicitly fail if a symlink is not readable Change check_refname_format() to reject unnormalized refnames Inline function refname_format_print() Make collapse_slashes() allocate memory for its result Do not allow ".lock" at the end of any refname component Refactor check_refname_format() Change check_ref_format() to take a flags argument Change bad_ref_char() to return a boolean value ...
| * | | add_ref(): verify that the refname is formatted correctlyMichael Haggerty2011-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In add_ref(), verify that the refname is formatted correctly before adding it to the ref_list. Here we have to allow refname components that start with ".", since (for example) the remote protocol uses synthetic reference name ".have". So add a new REFNAME_DOT_COMPONENT flag that can be passed to check_refname_format() to allow leading dots. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | resolve_ref(): expand documentationMichael Haggerty2011-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Record information about resolve_ref(), hard-won via reverse engineering, in a comment for future spelunkers. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | resolve_ref(): also treat a too-long SHA1 as invalidMichael Haggerty2011-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the SHA1 in a reference file is not terminated by a space or end-of-file, consider it malformed and emit a warning. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | resolve_ref(): emit warnings for improperly-formatted referencesMichael Haggerty2011-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While resolving references, if a reference is found that is in an unrecognized format, emit a warning (and then fail, as before). Wouldn't *you* want to know? Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>