Commit Graph

229 Commits

Author SHA1 Message Date
Jameson Miller
2e3e8c889b Teach remote branch to return its remote 2013-02-11 11:36:22 -05:00
Scott J. Goldman
6ce61a0bf6 tests: fix whitespace in refs/rename.c 2013-02-08 14:25:41 -08:00
nulltoken
3ad052218c Fix MSVC compilation warnings
Fix #1308
2013-02-05 20:33:27 +01:00
nulltoken
0e8e5a6189 revparse: Lookup sha before branch 2013-02-03 11:44:26 +01:00
nulltoken
545b479a07 revparse: Lookup branch before described tag
Fix #1306
2013-02-03 11:18:24 +01:00
Carlos Martín Nieto
e5ef0f1814 refs: handle ALLOW_ONELEVEL normalization with leading slash
A leading slash confuses the name normalization code when the flags
include ALLOW_ONELEVEL. Catch this case in particular to avoid
triggering an assertion in the uppercase check which expects us not to
pass it an empty string.

The existing tests don't catch this as they simply use the NORMAL
flag.

This fixes #1300.
2013-01-31 20:23:30 +01:00
Sebastian Bauer
a7f8065f8c Use cl_assert_equal_s() instead of strcmp().
Replaced all cl_assert(!strcmp()) or semantically equivalent forms
by cl_assert_equal_s().
2013-01-25 06:55:56 +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
Scott J. Goldman
5c7b77c4f8 Seperate out a new test that verifies packed-refs with no trailing newline
as per @vmg's request
2013-01-22 16:01:03 -08:00
nulltoken
bf031581d3 branch: Introduce git_branch_tracking_name() 2013-01-16 22:56:13 +01:00
Martin Woodward
ba1a430a8b Add jGit license block to derrived tests
Add the jGit license block to tests derrived from jGit as per the
terms of the BSD license.
2013-01-04 17:29:45 +00:00
Ben Straub
72629a10e3 Clean up GCC build warnings 2012-12-10 10:05:31 -08:00
Vicent Martí
e05ca13f1f Merge pull request #1115 from ben/struct-versions
Version info for public structs
2012-12-05 11:47:19 -08:00
nulltoken
cc1466264a revparse: Deploy EINVALIDSPEC usage 2012-12-01 08:34:31 +01:00
nulltoken
84166facc9 revparse: remove timezone setup in tests 2012-12-01 08:34:30 +01:00
nulltoken
bc05f30c47 object: refine git_object_peel() error report 2012-12-01 08:34:29 +01:00
nulltoken
621730383a branch: Deploy EINVALIDSPEC usage 2012-12-01 08:34:28 +01:00
nulltoken
80212ecb1c reflog: Deploy EINVALIDSPEC usage 2012-12-01 08:34:27 +01:00
nulltoken
e4aa7f58fe refs: cover git_reference_name_to_oid() unfound behavior 2012-12-01 08:34:26 +01:00
nulltoken
80d9d1df14 refs: Deploy EINVALIDSPEC usage 2012-12-01 08:34:26 +01:00
nulltoken
47261d9c8a tests: drop unused variables 2012-12-01 08:34:25 +01:00
nulltoken
3da73c40fc Fix compilation warnings 2012-12-01 08:34:21 +01:00
Ben Straub
f4fc9fdba0 Cleanup nitpicky things 2012-11-30 13:12:10 -08: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
nulltoken
f1bd50d61d tracking: remove code duplication in test 2012-11-28 20:00:06 +01:00
Ben Straub
cb7ac81c4d Fix warning 2012-11-27 13:30:04 -08:00
Russell Belfer
a8122b5d4a Fix warnings on Win64 build 2012-11-27 13:18:29 -08: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
Sascha Cunz
9094d30b93 Reset all static variables to NULL in clar's __cleanup
Without this change, any failed assertion in the second (or a later) test
inside a test suite has a chance of double deleting memory, resulting in
a heap corruption. See #1096 for details.

This leaves alone the test cases where we "just" use cl_git_sandbox_init()
and cl_git_sandbox_cleanup(). These methods already take good care to not
double delete a repository.

Fixes #1096
2012-11-23 11:41:56 +01:00
nulltoken
b15df1d937 reflog: make entry_byindex() and drop() git compliant
Passing 0 as the index now retrieves the most recent entry instead
of the oldest one.
2012-11-17 18:30:35 -08:00
nulltoken
b1a3a70ed1 repository: Refine repository_head() error report 2012-11-12 00:14:51 +01:00
nulltoken
1f87fa3595 reflog: fix bogus removal of reflog entries 2012-10-26 21:02:01 +02:00
nulltoken
383f164a09 branch: rename config section upon moving 2012-10-25 17:42:31 +02:00
nulltoken
0b98a8a424 branch: remove config section upon deletion 2012-10-25 17:42:31 +02:00
nulltoken
cd1ef82253 test: extract make_head_orphaned() logic 2012-10-20 12:07:53 +02:00
nulltoken
209e34fa70 tests: leverage git_repository_detach_head() 2012-10-20 12:01:04 +02:00
nulltoken
8b05bea870 errors: deploy GIT_EORPHANEDHEAD usage 2012-10-19 22:01:53 +02:00
nulltoken
0532e7bb87 branch: allow deletion of branch when HEAD's missing 2012-10-19 21:23:22 +02:00
nulltoken
2df37f42c1 refs: cover more refname validity edge cases 2012-10-18 23:59:22 +02:00
nulltoken
5912d74c69 revparse: properly handle refnames containing a @
Fix #994
2012-10-18 23:05:33 +02:00
Carlos Martín Nieto
7ae5ab5696 Fix leak in the tests
Also introduce the slective ref trimming promised but also missed in
the previous commit.
2012-10-15 16:35:10 +02:00
Carlos Martín Nieto
47f44b6ee4 refs: loosen the OID parsing
We used to require loose references to contain only an OID (possibly
after trimming the string). This is however not enough for letting us
lookup FETCH_HEAD, which can have a lot of content after the initial
OID.

Change the parsing rules so that a loose refernce must e at least 40
bytes long and the 41st (if it's there) must be accepted by
isspace(3). This makes the trim unnecessary, so only do it for
symrefs. This fixes #977.
2012-10-15 14:00:19 +02:00
nulltoken
6251de1d17 branches: cover EEXISTS propagation upon moving 2012-10-11 14:09:27 +02:00
nulltoken
62993b6158 branches: propagate EEXISTS upon creation 2012-10-11 14:08:32 +02:00
nulltoken
3548fcf562 refs: propagate EEXISTS upon renaming 2012-10-11 14:00:26 +02:00
nulltoken
0c78f685eb branch: introduce git_branch_is_head() 2012-10-07 21:03:51 +02:00
nulltoken
b52b6571af branch: enhance branch moving test coverage 2012-10-07 21:03:48 +02:00
Carlos Martín Nieto
c128149315 refs: propagate EEXISTS
Indicate whether the error comes from the ref already existing or
elsewhere. We always perform the check and this lets the user write
more concise code.
2012-09-30 11:56:37 +02:00
Vicent Martí
31d22037a6 Merge pull request #944 from scunz/list_tags
Tags: teach git_tag_list not to include the 'refs/tags/' prefix
2012-09-25 14:52:24 -07:00
nulltoken
77e06d7e85 refs: introduce git_reference_is_valid_name() 2012-09-25 07:49:15 +02:00
nulltoken
c030ada7ff refs: make git_reference_normalize_name() accept refspec pattern 2012-09-25 07:49:14 +02:00
Sascha Cunz
7604ddbf70 Tests: Add 3 tags to resources/testrepo.
Adjusts refs::list test (including the comments)
Adjusts objects::tags::list test
2012-09-23 01:02:07 +02:00
nulltoken
c2948c7754 refs: prevent locked refs from being enumerated
Fix #936
2012-09-14 21:56:14 +02:00
nulltoken
e16fc07f7e refspec: No remote tracking ref from a fetchspec-less remote 2012-09-13 22:31:29 +02:00
nulltoken
316659489a refs: introduce git_reference_peel()
Fix #530
2012-09-06 18:40:05 +02:00
Vicent Marti
62eafd0620 Merge branch 'branch-delete-ref' into development
Conflicts:
	include/git2/refs.h
2012-08-27 14:54:52 -07:00
Vicent Martí
b9d283d14a Merge pull request #897 from nulltoken/topic/git_reference_check_format
refs: expose git_reference_normalize_name()
2012-08-27 13:39:17 -07:00
nulltoken
2e0c881670 refs: expose git_reference_normalize_name() 2012-08-27 08:41:26 +02:00
Vicent Marti
1c947daa80 branch: Change git_branch_delete to take a ref 2012-08-26 18:00:10 -07:00
Vicent Martí
8238401ccb Merge pull request #896 from ben/revparse-ambiguous
Revparse: GIT_EAMBIGUOUS
2012-08-25 11:37:23 -07:00
Ben Straub
c9de8611d6 Revparse: GIT_EAMBIGUOUS
Revparse now returns EAMBIGUOUS if the the spec
doesn't match any refs/tags, and is <4 characters.
2012-08-25 09:56:20 -07:00
Russell Belfer
e9ca852e4d Fix warnings and merge issues on Win64 2012-08-23 09:20:17 -07:00
Vicent Martí
f98c32f3fe Merge pull request #778 from ben/clone
Clone
2012-08-19 01:26:06 -07:00
Joshua Peek
e60af90498 Test trailing space after ref oid 2012-08-09 14:39:43 -05:00
Joshua Peek
6ab6829097 Parse ref oids without trailing newline 2012-08-09 12:39:09 -05:00
Vicent Marti
51e1d80846 Merge remote-tracking branch 'arrbee/tree-walk-fixes' into development
Conflicts:
	src/notes.c
	src/transports/git.c
	src/transports/http.c
	src/transports/local.c
	tests-clar/odb/foreach.c
2012-08-06 12:41:08 +02:00
Russell Belfer
5dca201072 Update iterators for consistency across library
This updates all the `foreach()` type functions across the library
that take callbacks from the user to have a consistent behavior.
The rules are:

* A callback terminates the loop by returning any non-zero value
* Once the callback returns non-zero, it will not be called again
  (i.e. the loop stops all iteration regardless of state)
* If the callback returns non-zero, the parent fn returns GIT_EUSER
* Although the parent returns GIT_EUSER, no error will be set in
  the library and `giterr_last()` will return NULL if called.

This commit makes those changes across the library and adds tests
for most of the iteration APIs to make sure that they follow the
above rules.
2012-08-03 17:08:01 -07:00
Ben Straub
32beb2ecfe Fix testrepo ref count to include new branch. 2012-07-27 20:36:12 -07:00
Ben Straub
a4827a5b5c Merge remote-tracking branch 'upstream/development' into test-merge 2012-07-27 11:17:21 -07:00
Vicent Marti
f0244463ad branch: Add repository argument to create
Yes, we can get the repository from the owner of the object, but having
it marked explicitly makes the API more consistent.
2012-07-27 18:49:37 +02:00
Vicent Marti
b41a30bdbb Merge remote-tracking branch 'nulltoken/topic/branch-rework' into development 2012-07-27 18:45:55 +02:00
Vicent Marti
b84f75c357 reflog: Rename entry_drop to drop 2012-07-27 18:43:02 +02:00
nulltoken
c3be5c5af0 reflog: keep the reflog name in sync with the reference name 2012-07-25 08:01:13 +02:00
nulltoken
40c75652d0 reflog: prevent git_reflog_append() from persisting the reflog back to disk 2012-07-25 07:53:32 +02:00
nulltoken
bd72425d16 reflog: introduce git_reflog_write() 2012-07-25 07:53:30 +02:00
nulltoken
d284b3de63 reflog: rename git_reflog_write() to git_reflog_append() 2012-07-25 07:53:30 +02:00
nulltoken
59341a5d59 reflog: introduce git_reflog_entry_drop() 2012-07-25 07:53:29 +02:00
nulltoken
7c458e3aee reflog: add GIT_OID_HEX_ZERO constant 2012-07-25 07:53:27 +02:00
nulltoken
1cb157184b tests: reorganize reflog tests 2012-07-25 07:53:27 +02:00
nulltoken
ef4d795ec5 refs: drop git_reference_remote_tracking_from_branch() 2012-07-24 16:09:49 +02:00
nulltoken
fb910281d6 branch: introduce git_branch_tracking() 2012-07-24 16:09:48 +02:00
nulltoken
bf9e8cc86b branch: make git_branch_move() reference based 2012-07-24 16:09:47 +02:00
nulltoken
88bcd5153f branch: introduce git_reference_is_branch() 2012-07-24 16:09:45 +02:00
nulltoken
eed378b669 branch: introduce git_branch_lookup() 2012-07-24 16:09:44 +02:00
nulltoken
b308c11e4e branch: change git_branch_create() to make it return a reference 2012-07-24 16:09:43 +02:00
nulltoken
326ca710a0 branch: remove useless header 2012-07-24 16:09:42 +02:00
Carlos Martín Nieto
279b45b05b revparse: don't allow an empty string
Asking the library for "" used to give HEAD, but that's trying to
impose a default at the wrong layer. Make it fail.
2012-07-23 21:32:45 +02:00
Ben Straub
3e026f1b45 Update master-tip to fix unit test. 2012-07-17 09:00:38 -07:00
nulltoken
d448392e5d revparse: extend test coverage 2012-07-15 18:41:55 +02:00
nulltoken
d1b7921a48 revparse: fix disambiguation of refs and abbrev oids 2012-07-12 22:30:00 +02:00
nulltoken
bb89cf9478 revparse: simplify handling of the colon syntax 2012-07-12 22:29:58 +02:00
Vicent Martí
0cf6b2f29e Merge pull request #805 from nulltoken/fix/revwalk-email-parsing
Fix revwalk email parsing
2012-07-12 09:37:09 -07:00
nulltoken
84f18e3587 refs: introduce git_reference_remote_tracking_from_branch() 2012-07-12 01:06:13 +02:00
nulltoken
874303d468 refs: readonly tests don't need a sandboxed repo 2012-07-12 01:06:12 +02:00
nulltoken
5b07111529 tests: add test commit with angle brackets in the author name 2012-07-11 20:40:12 +02:00
nulltoken
3e82d6c6f0 revparse: unfound reference return ENOTFOUND 2012-07-07 12:16:15 +02:00
nulltoken
ce9e8e11ca revparse: fix invalid test reference name 2012-07-07 12:16:14 +02:00
nulltoken
b8460c2015 revparse: do not segfault when retrieving the last entry 2012-07-07 12:16:14 +02:00
nulltoken
3d78ab6427 revparse: split reflog test per feature 2012-07-07 12:16:12 +02:00