|
90df4302
|
2022-01-05T12:18:05
|
|
Fix typos
|
|
f0e693b1
|
2021-09-07T17:53:49
|
|
str: introduce `git_str` for internal, `git_buf` is external
libgit2 has two distinct requirements that were previously solved by
`git_buf`. We require:
1. A general purpose string class that provides a number of utility APIs
for manipulating data (eg, concatenating, truncating, etc).
2. A structure that we can use to return strings to callers that they
can take ownership of.
By using a single class (`git_buf`) for both of these purposes, we have
confused the API to the point that refactorings are difficult and
reasoning about correctness is also difficult.
Move the utility class `git_buf` to be called `git_str`: this represents
its general purpose, as an internal string buffer class. The name also
is an homage to Junio Hamano ("gitstr").
The public API remains `git_buf`, and has a much smaller footprint. It
is generally only used as an "out" param with strict requirements that
follow the documentation. (Exceptions exist for some legacy APIs to
avoid breaking callers unnecessarily.)
Utility functions exist to convert a user-specified `git_buf` to a
`git_str` so that we can call internal functions, then converting it
back again.
|
|
94571908
|
2021-05-18T16:07:04
|
|
branch: git branch upstream with format format name parameter has been added.
|
|
9836ca91
|
2021-05-16T18:02:23
|
|
branch: git branch upstream functions layouts have been fixed.
|
|
ea889b3e
|
2021-05-16T17:58:15
|
|
branch: git branch upstream format enum has been added.
|
|
f7c3d622
|
2021-05-16T13:58:51
|
|
branch: git branch upstream functions layouts have been fixed.
|
|
7d9599bd
|
2021-05-12T10:30:12
|
|
branch: git branch upstream merge has been exposed.
|
|
a2d953e5
|
2021-05-12T10:29:45
|
|
branch: git branch upstream with format has been added.
|
|
cb4bfbc9
|
2020-04-05T11:07:54
|
|
buffer: git_buf_sanitize should return a value
`git_buf_sanitize` is called with user-input, and wants to sanity-check
that input. Allow it to return a value if the input was malformed in a
way that we cannot cope.
|
|
7d24070d
|
2020-04-05T10:14:28
|
|
branch: use GIT_ASSERT
|
|
fe11160c
|
2020-09-08T21:05:18
|
|
Add git_branch_name_is_valid
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
|
ac5fbe31
|
2020-06-17T14:43:27
|
|
branch: determine whether a branch is checked out via refdb
We currently determine whether a branch is checked out via
`git_repository_foreach_head`. As this function reads references
directly from the disk, it breaks our refdb abstraction in case the
repository uses a different reference backend implementation than the
filesystem-based one. So let's use `git_repository_foreach_worktree`
instead -- while it's less efficient, it is at least correct in all
corner cases.
|
|
51eff5a5
|
2020-05-29T13:13:19
|
|
strarray: we should `dispose` instead of `free`
We _dispose_ the contents of objects; we _free_ objects (and their
contents). Update `git_strarray_free` to be `git_strarray_dispose`.
`git_strarray_free` remains as a deprecated proxy function.
|
|
39f78b0c
|
2019-12-07T10:31:27
|
|
branch: clarify documentation around branches
|
|
c5d8e300
|
2019-02-21T21:46:39
|
|
branch: have git_branch_lookup accept GIT_BRANCH_ALL
|
|
bf013fc0
|
2019-02-14T13:30:33
|
|
branch: fix `branch_is_checked_out` with bare repos
In a bare repository, HEAD usually points to the branch that is
considered the "default" branch. As the current implementation for
`git_branch_is_checked_out` only does a comparison of HEAD with the
branch that is to be checked, it will say that the branch pointed to by
HEAD in such a bare repo is checked out.
Fix this by skipping the main repo's HEAD when it is bare.
|
|
efb20825
|
2019-02-14T13:05:49
|
|
branches: introduce flag to skip enumeration of certain HEADs
Right now, the function `git_repository_foreach_head` will always
iterate over all HEADs of the main repository and its worktrees. In some
cases, it might be required to skip either of those, though. Add a flag
in preparation for the following commit that enables this behaviour.
|
|
788cd2d5
|
2019-02-14T13:49:35
|
|
branches: do not assert that the given ref is a branch
Libraries should use assert(3P) only very scarcely. First, we usually
shouldn't cause the caller of our library to abort in case where the
assert fails. Second, if code is compiled with -DNDEBUG, then the assert
will not be included at all.
In our `git_branch_is_checked_out` function, we have an assert that
verifies that the given reference parameter is non-NULL and in fact a
branch. While the first check is fine, the second is not. E.g. when
compiled with -DNDEBUG, we'd proceed and treat the given reference as a
branch in all cases.
Fix the issue by instead treating a non-branch reference as not being
checked out. This is the obvious solution, as references other than
branches cannot be directly checked out.
|
|
f673e232
|
2018-12-27T13:47:34
|
|
git_error: use new names in internal APIs and usage
Move to the `git_error` name in the internal API for error-related
functions.
|
|
ed8cfbf0
|
2019-01-17T00:32:31
|
|
references: use new names in internal usage
Update internal usage to use the `git_reference` names for constants.
|
|
ecf4f33a
|
2018-02-08T11:14:48
|
|
Convert usage of `git_buf_free` to new `git_buf_dispose`
|
|
a9677e01
|
2018-01-19T09:20:59
|
|
branch: refuse creating branches named 'HEAD'
Since a625b092c (branch: correctly reject refs/heads/{-dash,HEAD},
2017-11-14), which is included in v2.16.0, upstream git refuses to
create branches which are named HEAD to avoid ambiguity with the
symbolic HEAD reference. Adjust our own code to match that behaviour and
reject creating branches names HEAD.
|
|
0c7f49dd
|
2017-06-30T13:39:01
|
|
Make sure to always include "common.h" first
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.
|
|
be343b88
|
2017-05-01T18:56:55
|
|
worktrees: cleanup some memory leaks
Be sure to clean up looked up references. Free buffers instead of
merely clearing them. Use `git__free` instead of `free`.
|
|
38fc5ab0
|
2017-04-04T18:44:43
|
|
branch: use `foreach_head` to see if a branch is checked out
Previously, we have extracted the logic to find and iterate over all
HEADs of a repository. Use this function in `git_branch_is_checked_out`.
|
|
143e539f
|
2015-11-06T12:33:59
|
|
branch: restrict branch deletion for worktrees
Restrict the ability to delete branches that are checked out in
any linked repository.
|
|
e3acd37b
|
2015-11-06T12:08:15
|
|
branch: implement `git_branch_is_checked_out`
Implement a new function that is able to determine if a branch is
checked out in any repository connected to the current
repository. In particular, this is required to check if for a
given repository and branch, there exists any working tree
connected to that repository that is referencing this branch.
|
|
909d5494
|
2016-12-29T12:25:15
|
|
giterr_set: consistent error messages
Error messages should be sentence fragments, and therefore:
1. Should not begin with a capital letter,
2. Should not conclude with punctuation, and
3. Should not end a sentence and begin a new one
|
|
f9793884
|
2016-10-28T14:32:01
|
|
branch: fix forced branch creation on HEAD of a bare repo
The code correctly detects that forced creation of a branch on a
nonbare repo should not be able to overwrite a branch which is
the HEAD reference. But there's no reason to prevent this on
a bare repo, and in fact, git allows this. I.e.,
git branch -f master new_sha
works on a bare repo with HEAD set to master. This change fixes
that problem, and updates tests so that, for this case, both the
bare and nonbare cases are checked for correct behavior.
|
|
d5592378
|
2016-04-26T11:39:53
|
|
annotated_commit: provide refs and description
Differentiate between the ref_name used to create an annotated_commit
(that can subsequently be used to look up the reference) and the
description that we resolved this with (which _cannot_ be looked up).
The description is used for things like reflogs (and may be a ref name,
and ID something that we revparsed to get here), while the ref name must
actually be a reference name, and is used for things like rebase to
return to the initial branch.
|
|
01d0c02d
|
2015-07-12T19:08:06
|
|
refdb: delete a ref's reflog upon deletion
Removing a reflog upon ref deletion is something which only some
backends might wish to do. Backends which are database-backed may wish
to archive a reflog, log-based ones may not need to do anything.
|
|
5014fe95
|
2015-05-22T12:24:09
|
|
branch: error out if we cannot find the remote
When we look for which remote corresponds to a remote-tracking branch,
we look in the refspecs to see which ones matches. If none do, we should
abort. We currently ignore the error message from this operation, so
let's not do that anymore.
As part of the test we're writing, let's test for the expected behaviour
if we cannot find a refspec which tells us what the remote-tracking
branch for a remote would look like.
|
|
62d38a1d
|
2015-03-06T23:51:40
|
|
Add annotated commit versions of reflog-modifying functions
We do not always want to put the id directly into the reflog, but we
want to speicfy what a user typed. For this use-case we provide
annotated version of a few functions which let the caller specify what
user-friendly name was used when asking for the operation.
|
|
05e644dd
|
2015-03-04T22:01:39
|
|
Drop trailing whitespaces
|
|
7eb76734
|
2015-03-04T22:01:20
|
|
branch: fix generated reflog message upon renaming
|
|
015d4b7b
|
2015-03-04T21:48:54
|
|
branch: fix generated reflog message upon creation
|
|
9a97f49e
|
2014-12-21T15:31:03
|
|
config: borrow refcounted references
This changes the get_entry() method to return a refcounted version of
the config entry, which you have to free when you're done.
This allows us to avoid freeing the memory in which the entry is stored
on a refresh, which may happen at any time for a live config.
For this reason, get_string() has been forbidden on live configs and a
new function get_string_buf() has been added, which stores the string in
a git_buf which the user then owns.
The functions which parse the string value takea advantage of the
borrowing to parse safely and then release the entry.
|
|
6bfb990d
|
2015-01-07T14:47:02
|
|
branch: don't accept a reflog message override
This namespace is about behaving like git's branch command, so let's do
exactly that instead of taking a reflog message.
This override is still available via the reference namespace.
|
|
659cf202
|
2015-01-07T12:23:05
|
|
Remove the signature from ref-modifying functions
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.
|
|
31bc6c04
|
2015-03-03T13:25:40
|
|
branch: do capture the error code
We want to ignore GIT_ENOTFOUND, but for that we need to capture the
error code from the reflog deletion.
|
|
79863917
|
2015-03-02T10:24:54
|
|
git_branch_delete() should ignore errors from non-existing reflogs
|
|
5915d700
|
2014-11-17T14:28:22
|
|
branch: consider an empty upstream remote config as not found
|
|
02bc5233
|
2014-11-08T17:05:13
|
|
Merge pull request #2698 from libgit2/cmn/fetchhead-refactor
Refactor fetchhead
|
|
82374d98
|
2014-11-08T20:00:17
|
|
branch: add getter for the upstream remote name
This gets the value from branch.<foo>.remote.
|
|
209425ce
|
2014-11-08T13:25:51
|
|
remote: rename _load() to _lookup()
This brings it in line with the rest of the lookup functions.
|
|
ac99d86b
|
2014-05-07T11:34:32
|
|
repository: introduce a convenience config snapshot method
Accessing the repository's config and immediately taking a snapshot of
it is a common operation, so let's provide a convenience function for
it.
|
|
29c4cb09
|
2014-03-15T03:53:36
|
|
Use config snapshotting
This way we can assume we have a consistent view of the config situation
when we're looking up remote, branch, pack-objects, etc.
|
|
3b4ba278
|
2014-04-03T15:50:21
|
|
Const correctness!
|
|
853b1407
|
2014-03-17T16:10:33
|
|
branch: constness fixes
|
|
a07b1698
|
2014-03-07T15:40:53
|
|
branch: fix leak when checking against HEAD
We look up a reference in order to figure out if it's the current
branch, which we need to free once we're done with the check.
As a bonus, only perform the check when we're passed the force flag, as
it's a useless check otherwise.
|
|
59b1dbcd
|
2014-02-27T23:56:25
|
|
Do not allow git_branch_create() to force update branch
|
|
59bb1126
|
2014-01-28T11:45:30
|
|
Provide good default reflog messages in branch api
|
|
ccf6ce5c
|
2014-01-28T11:30:36
|
|
Ensure renaming a reference updates the reflog
|
|
48110f67
|
2014-01-28T10:31:54
|
|
Deleting a branch deletes its reflog
|
|
b31ebfbc
|
2014-01-27T14:12:29
|
|
Add reflog params to git_branch_create
|
|
540c1809
|
2014-01-28T10:44:33
|
|
Add reflog parameters to git_branch_move
|
|
3cf11eef
|
2014-01-28T11:47:33
|
|
Misc cleanups
|
|
bf522e08
|
2014-01-26T16:59:36
|
|
refspec: move to git_buf for outputting strings
|
|
b25d87c9
|
2014-01-26T16:03:37
|
|
branch: move to git_buf when outputting newly-allocated strings
Internally we already did everything with git_bufs, so this is just
exposing those functions with public names.
|
|
0b28217b
|
2014-01-15T12:51:31
|
|
refs: remove the _with_log differentiation
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.
|
|
9eb45fc5
|
2014-01-12T23:29:44
|
|
branch: handle NULL pointers passed to git_branch_iterator_free()
Signed-off-by: Brodie Rao <brodie@sf.io>
|
|
96869a4e
|
2013-12-03T16:45:39
|
|
Improve GIT_EUSER handling
This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around. As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally. To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
|
|
a667ca82
|
2013-11-05T20:51:07
|
|
Change the git_branch_iterator_new and git_branch_next definitions to use git_branch_t.
|
|
8ec889a4
|
2013-11-02T14:07:02
|
|
branch: move from foreach to an iterator
Create a git_branch_iterator type which is equivalent to the foreach but
lets us write loops instead of callbacks.
Since the introduction of git_reference_shorthand(), the added value of
passing the name is reduced.
|
|
605da51a
|
2013-09-17T09:50:30
|
|
No such thing as an orphan branch
Unfortunately git-core uses the term "unborn branch" and "orphan
branch" interchangeably. However, "orphan" is only really there for
the checkout command, which has the `--orphan` option so it doesn't
actually create the branch.
Branches never have parents, so the distinction of a branch with no
parents is odd to begin with. Crucially, the error messages deal with
unborn branches, so let's use that.
|
|
09c2f91c
|
2013-06-17T18:48:02
|
|
branch: More obvious semantics in `foreach`
|
|
2ad7a4dc
|
2013-06-17T18:25:30
|
|
ref: free the last ref when cancelling git_branch_foreach()
Also fixed an assert typo on nulltoken's HEAD
|
|
4e6e2ff2
|
2013-05-30T03:47:10
|
|
...Aaaand this works
|
|
56960b83
|
2013-05-28T20:47:55
|
|
Liike this
|
|
b6cc559a
|
2013-05-11T02:42:49
|
|
Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
|
|
9bd89d96
|
2013-05-04T16:49:39
|
|
Move a couple more functions to use iterators
|
|
2b562c3a
|
2013-05-04T16:32:58
|
|
refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.
As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
|
|
3d42e9a3
|
2013-05-06T20:32:20
|
|
git_branch_set_upstream with local branches
Currently git_branch_set_upstream when passed a local branch
creates invalid configuration, for ex. if we setup branch
'tracking_master' to track local 'master' libgit2 generates
the following config
```
[branch "track_master"]
remote = .
merge = .refs/heads/track_master
```
The merge value is invalid and calling git_branch_upstream on
'tracking_master' results in invalid reference error.
It should do:
```
[branch "track_master"]
remote = .
merge = refs/heads/master
```
|
|
3e199f42
|
2013-05-01T04:18:46
|
|
Set error message for branch functions
There were a couple of places where an error was being returned
from branch related code but no error message was being set.
|
|
4330ab26
|
2013-04-20T04:43:28
|
|
remote: handle multiple refspecs
A remote can have a multitude of refspecs. Up to now our git_remote's
have supported a single one for each fetch and push out of simplicity
to get something working.
Let the remotes and internal code know about multiple remotes and get
the tests passing with them.
Instead of setting a refspec, the external users can clear all and add
refspecs. This should be enough for most uses, though we're still
missing a querying function.
|
|
38fd8121
|
2013-04-18T14:48:20
|
|
Fix win64 warnings
|
|
d59942c2
|
2013-03-30T04:27:42
|
|
branch: add more upstream configuration management
Add functions to set and unset the upstream configuration to
complement the getter we already have.
|
|
97016f29
|
2013-03-30T09:30:29
|
|
branch: refactor git_branch_remote_name
Return the size we'd need to write to instead of simply an
error. Split the function into two to be used later by the upstream
configuration functions.
|
|
a258d8e3
|
2013-03-30T03:39:19
|
|
branch: rename 'tracking' to 'upstream'
The term 'tracking' is overloaded. Help distinguish what we mean by
using 'upstream' for this part of the library.
|
|
10c06114
|
2013-03-17T04:46:46
|
|
Several warnings detected by static code analyzer fixed
Implicit type conversion argument of function to size_t type
Suspicious sequence of types castings: size_t -> int -> size_t
Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)'
Unsigned type is never < 0
|
|
d00d5464
|
2013-03-01T15:37:33
|
|
immutable references and a pluggable ref database
|
|
c1b5e8c4
|
2013-02-15T11:35:33
|
|
branch: Make git_branch_remote_name() cope with orphaned heads
|
|
390a3c81
|
2013-02-11T11:44:00
|
|
Merge pull request #1190 from nulltoken/topic/reset-paths
reset: Allow the selective reset of pathspecs
|
|
2e3e8c88
|
2013-02-08T11:05:47
|
|
Teach remote branch to return its remote
|
|
3ad05221
|
2013-02-05T16:52:56
|
|
Fix MSVC compilation warnings
Fix #1308
|
|
c253056d
|
2013-01-24T20:44:17
|
|
Added git_branch_name().
This is a convenience function to get the branch name of a given
ref. The returned branch name is compatible with the name that can
be supplied e.g. to git_branch_lookup(). That is, the prefixes
"refs/heads" or "refs/remotes" are omitted.
Also added a new test for testing the new function.
|
|
bf031581
|
2013-01-14T14:22:11
|
|
branch: Introduce git_branch_tracking_name()
|
|
28cbd2e2
|
2013-01-14T12:09:10
|
|
Fix indentations
|
|
359fc2d2
|
2013-01-08T17:07:25
|
|
update copyrights
|
|
37849a8e
|
2012-11-17T22:09:55
|
|
tracking: fix retrieval of the tracking ref of branch with empty merge and/or remote entry
|
|
cfbe4be3
|
2012-11-17T19:54:47
|
|
More external API cleanup
Conflicts:
src/branch.c
tests-clar/refs/branches/create.c
|
|
2508cc66
|
2012-11-18T21:38:08
|
|
Rename ref and reflog apis for consistency
|
|
b1a3a70e
|
2012-11-12T00:14:51
|
|
repository: Refine repository_head() error report
|
|
b0f6e45d
|
2012-11-01T15:47:18
|
|
create FETCH_HEAD specially instead of as a ref file
|
|
aba70781
|
2012-09-11T18:11:26
|
|
config: introduce git_config_rename_section()
|
|
383f164a
|
2012-09-07T17:55:30
|
|
branch: rename config section upon moving
|
|
0b98a8a4
|
2012-09-07T15:13:11
|
|
branch: remove config section upon deletion
|
|
8b05bea8
|
2012-10-19T17:07:39
|
|
errors: deploy GIT_EORPHANEDHEAD usage
|
|
0532e7bb
|
2012-10-19T20:34:33
|
|
branch: allow deletion of branch when HEAD's missing
|
|
62993b61
|
2012-10-11T14:08:32
|
|
branches: propagate EEXISTS upon creation
|