Commit Graph

21 Commits

Author SHA1 Message Date
Edward Thomson
e86d02f92d git_repository_set_head: use remote name in reflog
When `git_repository_set_head` is provided a remote reference, update
the reflog with the tag name, like we do with a branch.  This helps
consumers match the semantics of `git checkout remote`.
2017-04-03 00:10:47 +01:00
Edward Thomson
ea3bb5c0bb git_repository_set_head: use tag name in reflog
When `git_repository_set_head` is provided a tag reference, update the
reflog with the tag name, like we do with a branch.  This helps
consumers match the semantics of `git checkout tag`.
2017-03-21 18:12:02 +00:00
Carlos Martín Nieto
a5815a2afb Add tests for the annotated versions of ref-modifying functions
This also brings the soft-reset tests back to life. The function name
was missing an underscore, meaning they had not been running.
2015-03-16 16:57:30 +01:00
Carlos Martín Nieto
4e498646b6 repository: remove log message override for switching the active branch
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.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
659cf2029f 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.
2015-03-03 14:40:50 +01:00
Edward Thomson
0cee70ebb7 Introduce cl_assert_equal_oid 2014-07-01 14:40:16 -04:00
Carlos Martín Nieto
99797c96cd reflog: handle symref chains
Given HEAD -> master -> foo, when updating foo's reflog we should also
update HEAD's, as it's considered the current branch.
2014-03-19 18:14:35 +01:00
Carlos Martín Nieto
6aaae94a70 reflog: handle the birth of a branch
The reflog append function was overzealous in its checking. When passed
an old and new ids, it should not do any checking, but just serialize
the data to a reflog entry.
2014-03-19 16:52:20 +01:00
Carlos Martín Nieto
1afe140043 refdb: don't update when there's no need
If the caller wants to update a ref to point to the same target as it
currently has, we should return early and avoid writing to the reflog.
2014-03-19 15:54:33 +01:00
Carlos Martín Nieto
bac95e6e1e reflog: more comprehensive HEAD tests
The existing ones lack checking zeroed ids when switching back from an
unborn branch as well as what happens when detaching.

The reflog appending function mistakenly wrote zeros when dealing with a
detached HEAD. This explicitly checks for those situations and fixes
them.
2014-03-18 19:58:52 +01:00
Carlos Martín Nieto
4b7e1b9e92 refs: append to the HEAD reflog when updating the current branch
When we update the current branch, we must also append to HEAD's reflog
to keep them in sync.

This is a bit of a hack, but as git.git says, it covers 100% of
default cases.
2014-03-17 17:47:47 +01:00
Carlos Martín Nieto
cb562c3fb3 repo: remove test which deletes HEAD
This is not something anybody would ever do; removing HEAD makes the
.git/ directory no longer be a repository, so we wouldn't be expected to
handle such a situation.
2014-03-17 17:47:47 +01:00
Ben Straub
010cec3ac2 Add reflog params to git_repository_detach_head 2014-02-04 20:50:40 -08:00
Ben Straub
eec2761f06 Fix warning 2014-02-03 15:06:32 -08:00
Ben Straub
7ac1b89942 Add failing test case 2014-02-01 11:46:15 -08:00
Ben Straub
a1710a28f6 Enhance testing of signature parameters 2014-01-30 15:53:52 -08:00
Ben Straub
2952a9d0f4 Ensure creating HEAD creates its reflog 2014-01-30 15:51:00 -08:00
Ben Straub
a2311f92c2 Ensure updating HEAD updates reflog 2014-01-30 15:51:00 -08:00
Ben Straub
94f263f59b Add reflog params to set-head calls 2014-01-30 15:51:00 -08: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
Ben Straub
1782038144 Rename tests-clar to tests 2013-11-14 14:05:52 -08:00