summaryrefslogtreecommitdiff
path: root/src/refs.h
Commit message (Collapse)AuthorAgeFilesLines
* references: use new names in internal usageethomson/git_refEdward Thomson2019-01-171-3/+3
| | | | Update internal usage to use the `git_reference` names for constants.
* merge: make analysis possible against a non-HEAD referenceEtienne Samson2018-10-191-0/+2
| | | | | | | This moves the current merge analysis code into a more generic version that can work against any reference. Also change the tests to check returned analysis values exactly.
* refs: preserve the owning refdb when duping referenceEtienne Samson2018-04-101-0/+4
| | | This fixes a segfault in git_reference_owner on references returned from git_reference__read_head and git_reference_dup ones.
* refs: include " sorted " in our packed-refs headercmn/packed-refs-sortedCarlos Martín Nieto2018-01-121-1/+1
| | | | | | | This lets git know that we do in fact have written our packed-refs file sorted (which is apparently not necessarily the case) and it can then use the new-ish mmaped access which lets it avoid significant amounts of effort parsing potentially large files to get to a single piece of data.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* refs: implement function to read references from filePatrick Steinhardt2017-04-051-0/+14
| | | | | | | | | Currently, we only provide functions to read references directly from a repository's reference store via e.g. `git_reference_lookup`. But in some cases, we may want to read files not connected to the current repository, e.g. when looking up HEAD of connected work trees. This commit implements `git_reference__read_head`, which will read out and allocate a reference at an arbitrary path.
* symbolic ref target validation: fixupsEdward Thomson2017-01-211-1/+1
| | | | Fixups requested in #3912.
* Make symbolic ref target validation optionalRichard Ipsum2016-08-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | Introduce GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION option. Setting this option to 0 allows validation of a symbolic ref's target to be bypassed. This option is enabled by default. This mechanism is added primarily to address a discrepancy between git behaviour and libgit2 behaviour, whereby the former allows the symbolic ref target to carry an arbitrary string and the latter does not, so: $ git symbolic-ref refs/heads/foo bar $ cat .git/refs/heads/foo ref: bar where as attempting the same via libgit2 raises an error: The given reference name 'bar' is not valid this mechanism also allows those that might want to make use of git's more lenient treatment of symbolic ref targets to do so.
* repository: distinguish sequencer cherry-pick and revertcmn/repository-state-sequencerCarlos Martín Nieto2015-11-201-0/+5
| | | | These are not quite like their plain counterparts and require special handling.
* repository: remove log message override for switching the active branchCarlos Martín Nieto2015-03-031-0/+1
| | | | | | We want to use the "checkout: moving from ..." message in order to let git know when a change of branch has happened. Make the convenience functions for this goal write this message.
* Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-031-2/+1
| | | | | | | | | | The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
* git_rebase_commit: write HEAD's reflog appropriatelyEdward Thomson2014-10-261-0/+9
|
* Introduce reference transactionsCarlos Martín Nieto2014-09-301-0/+2
| | | | | | | | | A transaction allows you to lock multiple references and set up changes for them before applying the changes all at once (or as close as the backend supports). This can be used for replication purposes, or for making sure some operations run when the reference is locked and thus cannot be changed.
* git_cherry_pick -> git_cherrypickEdward Thomson2014-07-221-1/+1
|
* Fixes #2443 Zero size arrays are an extensionphkelley/flexarrayPhilip Kelley2014-06-261-1/+1
|
* Refs: Introduce `git_refname_t`.Arthur Schreiber2014-05-301-0/+2
|
* Refs: Fix some issue when core.precomposeunicode = true.Arthur Schreiber2014-05-301-1/+0
| | | | | | | | | | | This fixes two issues I found when core.precomposeunicode is enabled: * When creating a reference with a NFD string, the returned git_reference would return this NFD string as the reference’s name. But when looking up the reference later, the name would then be returned as NFC string. * Renaming a reference would not honor the core.precomposeunicode and apply no normalization to the new reference name.
* refs: remove the _with_log differentiationCarlos Martín Nieto2014-01-151-1/+1
| | | | | | Any well-behaved program should write a descriptive message to the reflog whenever it updates a reference. Let's make this more prominent by removing the version without the reflog parameters.
* reflog: write to the reflog following git's rulesCarlos Martín Nieto2013-12-091-0/+1
| | | | | | git-core only writes to the reflogs of HEAD, refs/heads/ and, refs/notes/ or if there is already a reflog in place. Adjust our code to follow these semantics.
* Make reference lookups apply precomposeunicodeRussell Belfer2013-10-081-0/+2
| | | | | | | | | | | | | | | | | | | | | Before these changes, looking up a reference would return the same precomposed or decomposed form of the reference name that was used to look it up, so on MacOS which ignores the difference between the two, a single reference could be looked up either way and git_reference_name would return the form of the name that was used to look it up! This change makes lookup always return the precomposed name if core.precomposeunicode is set regardless of which version was used to look it up. The reference iterator was already returning the precomposed form from earlier work. This also updates the CMakeLists.txt rules for enabling iconv usage because the clar tests for this code were actually not being activated properly with the old version. Finally, this moves git_repository_reset_filesystem from include/ git2/repository.h to include/git2/sys/repository.h since it is not really a function that normal library users should have to think about very often.
* Merge pull request #1805 from libgit2/threading-packed-loadVicent Martí2013-08-281-0/+2
|\ | | | | Thread safety for the refdb_fs
| * Add internal ref set_name fn instead of reallocRussell Belfer2013-08-211-0/+2
| | | | | | | | | | | | | | | | The refdb_fs implementation calls realloc directly on a reference object when it wants to rename it. It is not a public object, so this doesn't mess with the immutability of references, but it does assume certain constraints on the reference representation. This commit wraps that assumption in an isolated API to isolate it.
* | refs: add git_reference_is_tagNikolai Vladimirov2013-08-261-0/+1
|/
* refdb_fs: Traits are always surrounded by spacesVicent Marti2013-05-021-1/+1
| | | | This makes parsing easier! :p
* refdb_fs: implement the fully-peeled traitVicent Marti2013-05-021-1/+1
|
* Make git_oid_cmp public and add git_oid__cmpRussell Belfer2013-04-291-0/+1
|
* refs: Do not union the peelvmg/refs-peelVicent Marti2013-04-171-6/+3
|
* refs: Add `git_referene_target_peel`Vicent Marti2013-04-171-2/+5
|
* immutable references and a pluggable ref databaseEdward Thomson2013-03-071-12/+7
|
* branch: Make git_branch_remote_name() cope with orphaned headsnulltoken2013-02-221-0/+1
|
* branch: Introduce git_branch_tracking_name()nulltoken2013-01-161-0/+1
|
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Merge pull request #1026 from nulltoken/repo/stateVicent Martí2012-10-301-0/+6
|\ | | | | repo: enhance git_repository_state() detection
| * repo: enhance git_repository_state() detectionnulltoken2012-10-271-0/+6
| |
* | refs: add GIT_REFS_STASH_FILE definenulltoken2012-10-261-0/+3
|/
* reset changes for mergeEdward Thomson2012-10-241-0/+3
|
* refspec: introduce git_refspec__parse()nulltoken2012-09-251-0/+1
|
* refs: introduce git_reference_is_valid_name()nulltoken2012-09-251-1/+0
|
* refs: make git_reference_normalize_name() accept refspec patternnulltoken2012-09-251-1/+3
|
* Add git_reset()nulltoken2012-06-071-0/+1
| | | | Currently supports Soft and Mixed modes.
* Rename git_khash_str to git_strmap, etc.Russell Belfer2012-04-251-2/+2
| | | | | | This renamed `git_khash_str` to `git_strmap`, `git_hash_oid` to `git_oidmap`, and deletes `git_hashtable` from the tree, plus adds unit tests for `git_strmap`.
* Convert hashtable usage over to khashRussell Belfer2012-04-251-2/+2
| | | | | | | | | | | | | | | This updates khash.h with some extra features (like error checking on allocations, ability to use wrapped malloc, foreach calls, etc), creates two high-level wrappers around khash: `git_khash_str` and `git_khash_oid` for string-to-void-ptr and oid-to-void-ptr tables, then converts all of the old usage of `git_hashtable` over to use these new hashtables. For `git_khash_str`, I've tried to create a set of macros that yield an API not too unlike the old `git_hashtable` API. Since the oid hashtable is only used in one file, I haven't bother to set up all those macros and just use the khash APIs directly for now.
* Add git_reference_lookup_oid and lookup_resolvedRussell Belfer2012-04-171-0/+23
| | | | | | | | | | | | | | Adds a new public reference function `git_reference_lookup_oid` that directly resolved a reference name to an OID without returning the intermediate `git_reference` object (hence, no free needed). Internally, this adds a `git_reference_lookup_resolved` function that combines looking up and resolving a reference. This allows us to be more efficient with memory reallocation. The existing `git_reference_lookup` and `git_reference_resolve` are reimplmented on top of the new utility and a few places in the code are changed to use one of the two new functions.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* refs: move GIT_PACKED_REFS_FILE_MODE to refs.h as GIT_PACKEDREFS_FILE_MODEBrodie Rao2011-11-161-0/+1
| | | | | This groups the #define with the other ref-related file modes, and it makes the name consistent with the other packed-refs definitions.
* refs: Partial rewrite for read-only refsVicent Marti2011-11-061-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | This new version of the references code is significantly faster and hopefully easier to read. External API stays the same. A new method `git_reference_reload()` has been added to force updating a memory reference from disk. In-memory references are no longer updated automagically -- this was killing us. If a reference is deleted externally and the user doesn't reload the memory object, nothing critical happens: any functions using that reference should fail gracefully (e.g. deletion, renaming, and so on). All generated references from the API are read only and must be free'd by the user. There is no reference counting and no traces of generated references are kept in the library. There is no longer an internal representation for references. There is only one reference struct `git_reference`, and symbolic/oid targets are stored inside an union. Packfile references are stored using an optimized struct with flex array for reference names. This should significantly reduce the memory cost of loading the packfile from disk.
* refs: split internal and external referencesschu2011-11-061-2/+0
| | | | | | | | | | | | | | | | | Currently libgit2 shares pointers to its internal reference cache with the user. This leads to several problems like invalidation of reference pointers when reordering the cache or manipulation of the cache from user side. Give each user its own git_reference instead of leaking the internal representation (struct reference). Add the following new API functions: * git_reference_free * git_reference_is_packed Signed-off-by: schu <schu-github@schulog.org>
* *: correct and codify various file permissionsBrodie Rao2011-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
* fileops/repository: create (most) directories with 0777 permissionsBrodie Rao2011-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To further match how Git behaves, this change makes most of the directories libgit2 creates in a git repo have a file mode of 0777. Specifically: - Intermediate directories created with git_futils_mkpath2file() have 0777 permissions. This affects odb_loose, reflog, and refs. - The top level folder for bare repos is created with 0777 permissions. - The top level folder for non-bare repos is created with 0755 permissions. - /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are created with 0777 permissions. Additionally, the following changes have been made: - fileops functions that create intermediate directories have grown a new dirmode parameter. The only exception to this is filebuf's lock_file(), which unconditionally creates intermediate directories with 0777 permissions when GIT_FILEBUF_FORCE is set. - The test runner now sets the umask to 0 before running any tests. This ensurses all file mode checks are consistent across systems. - t09-tree.c now does a directory permissions check. I've avoided adding this check to other tests that might reuse existing directories from the prefabricated test repos. Because they're checked into the repo, they have 0755 permissions. - Other assorted directories created by tests have 0777 permissions.
* fetch: store FETCH_HEADCarlos Martín Nieto2011-10-081-0/+1
| | | | | | We should always save the remote's HEAD as FETCH_HEAD locally. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>