Commit Graph

82 Commits

Author SHA1 Message Date
Carlos Martín Nieto
ac99d86ba5 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.
2014-05-07 11:34:32 +02:00
Carlos Martín Nieto
29c4cb0965 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.
2014-04-18 16:03:01 +02:00
Jacques Germishuys
3b4ba27870 Const correctness! 2014-04-03 16:06:31 +02:00
Carlos Martín Nieto
853b1407c0 branch: constness fixes 2014-03-17 17:47:46 +01:00
Carlos Martín Nieto
a07b169834 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.
2014-03-07 16:03:10 +01:00
Linquize
59b1dbcd7a Do not allow git_branch_create() to force update branch 2014-02-27 23:56:25 +08:00
Ben Straub
59bb1126e0 Provide good default reflog messages in branch api 2014-01-30 15:53:52 -08:00
Ben Straub
ccf6ce5c89 Ensure renaming a reference updates the reflog 2014-01-30 15:52:13 -08:00
Ben Straub
540c1809f4 Add reflog parameters to git_branch_move 2014-01-30 15:52:13 -08:00
Ben Straub
48110f67e4 Deleting a branch deletes its reflog 2014-01-30 15:52:13 -08:00
Ben Straub
b31ebfbc66 Add reflog params to git_branch_create 2014-01-30 15:52:13 -08:00
Russell Belfer
3cf11eef17 Misc cleanups 2014-01-30 09:59:59 -08:00
Carlos Martín Nieto
bf522e0811 refspec: move to git_buf for outputting strings 2014-01-27 04:44:06 +01:00
Carlos Martín Nieto
b25d87c9cd 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.
2014-01-27 04:44:05 +01:00
Carlos Martín Nieto
0b28217bda 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.
2014-01-15 13:32:43 +01:00
Brodie Rao
9eb45fc51a branch: handle NULL pointers passed to git_branch_iterator_free()
Signed-off-by: Brodie Rao <brodie@sf.io>
2014-01-12 23:33:52 -08:00
Russell Belfer
96869a4edb 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.
2013-12-11 10:57:49 -08:00
Arthur Schreiber
a667ca8298 Change the git_branch_iterator_new and git_branch_next definitions to use git_branch_t. 2013-11-05 20:51:07 +01:00
Carlos Martín Nieto
8ec889a45f 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.
2013-11-05 14:58:16 +01:00
Carlos Martín Nieto
605da51a2c 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.
2013-09-17 09:50:30 +02:00
Vicent Marti
09c2f91c15 branch: More obvious semantics in foreach 2013-06-17 18:48:02 +02:00
yorah
2ad7a4dc92 ref: free the last ref when cancelling git_branch_foreach()
Also fixed an assert typo on nulltoken's HEAD
2013-06-17 18:29:05 +02:00
Vicent Marti
4e6e2ff26f ...Aaaand this works 2013-05-30 03:47:10 +02:00
Vicent Marti
56960b8396 Liike this 2013-05-28 20:47:55 +02:00
Edward Thomson
b6cc559a78 Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
2013-05-11 02:42:49 -07:00
Carlos Martín Nieto
9bd89d9622 Move a couple more functions to use iterators 2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
2b562c3a1e 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.
2013-05-11 11:20:38 +02:00
Nikolai Vladimirov
3d42e9a31e 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
```
2013-05-06 20:33:11 +03:00
Russell Belfer
3e199f4285 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.
2013-05-01 04:18:46 -07:00
Carlos Martín Nieto
4330ab26b5 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.
2013-04-20 17:54:13 +02:00
Russell Belfer
38fd8121a2 Fix win64 warnings 2013-04-18 14:59:25 -07:00
Carlos Martín Nieto
d59942c2ab branch: add more upstream configuration management
Add functions to set and unset the upstream configuration to
complement the getter we already have.
2013-04-11 12:27:25 +02:00
Carlos Martín Nieto
97016f29ab 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.
2013-03-31 12:51:53 +02:00
Carlos Martín Nieto
a258d8e357 branch: rename 'tracking' to 'upstream'
The term 'tracking' is overloaded. Help distinguish what we mean by
using 'upstream' for this part of the library.
2013-03-30 15:45:57 +01:00
Arkadiy Shapkin
10c06114cb 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
2013-03-18 03:30:26 +04:00
Edward Thomson
d00d54645d immutable references and a pluggable ref database 2013-03-07 11:01:52 -06:00
nulltoken
c1b5e8c42b branch: Make git_branch_remote_name() cope with orphaned heads 2013-02-22 17:04:23 +01:00
Russell Belfer
390a3c8141 Merge pull request #1190 from nulltoken/topic/reset-paths
reset: Allow the selective reset of pathspecs
2013-02-11 11:44:00 -08:00
Jameson Miller
2e3e8c889b Teach remote branch to return its remote 2013-02-11 11:36:22 -05:00
nulltoken
3ad052218c Fix MSVC compilation warnings
Fix #1308
2013-02-05 20:33:27 +01:00
Sebastian Bauer
c253056d24 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.
2013-01-25 05:24:21 +01:00
nulltoken
bf031581d3 branch: Introduce git_branch_tracking_name() 2013-01-16 22:56:13 +01:00
nulltoken
28cbd2e2a8 Fix indentations 2013-01-16 22:53:59 +01:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
nulltoken
37849a8ec3 tracking: fix retrieval of the tracking ref of branch with empty merge and/or remote entry 2012-11-28 20:00:07 +01:00
Vicent Marti
cfbe4be3fb More external API cleanup
Conflicts:
	src/branch.c
	tests-clar/refs/branches/create.c
2012-11-27 13:18:27 -08:00
Ben Straub
2508cc66eb Rename ref and reflog apis for consistency 2012-11-27 13:17:45 -08:00
nulltoken
b1a3a70ed1 repository: Refine repository_head() error report 2012-11-12 00:14:51 +01:00
Edward Thomson
b0f6e45d14 create FETCH_HEAD specially instead of as a ref file 2012-11-11 11:56:33 -06:00
nulltoken
aba7078177 config: introduce git_config_rename_section() 2012-10-25 17:42:32 +02:00