Commit Graph

8 Commits

Author SHA1 Message Date
Carlos Martín Nieto
05b179648a Make refcounting atomic 2013-04-22 17:12:11 +02:00
Russell Belfer
1384b688d0 Move some low-level repo fns to include/git2/sys 2013-04-21 11:50:56 -07: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
Russell Belfer
991a56c704 Add flag to write gitlink on setting repo workdir
This added a flag to the `git_repository_set_workdir()` function
that enables generation of a `.git` gitlink file that links the
new workdir to the parent repository.  Essentially, the flag tells
the function to write out the changes to disk to permanently set
the workdir of the repository to the new path.

If you pass this flag as true, then setting the workdir to something
other than the default workdir (i.e. the parent of the .git repo
directory), will create a plain file named ".git" with the standard
gitlink contents "gitdir: <repo-path>", and also update the
"core.worktree" and "core.bare" config values.

Setting the workdir to the default repo workdir will clear the
core.worktree flag (but still permanently set core.bare to false).

BTW, the libgit2 API does not currently provide a function for
clearing the workdir and converting a non-bare repo into a bare one.
2012-07-10 23:19:47 -07:00
nulltoken
baf861a511 Fix git_repository_set_odb() refcount issue
git_repository_free() calls git_odb_free() if the owned odb is not null.

According to the doc, when setting a new odb through git_repository_set_odb() the caller has to take care of releasing the odb by himself.
2012-04-23 11:07:19 +02:00
nulltoken
c1aefb35dd Fix git_repository_set_index() refcount issue
git_repository_free() calls git_index_free() if the owned index is not null.

According to the doc, when setting a new index through git_repository_set_index() the caller has still to take care of releasing the index by itself.

In order to cope with this, this fix makes sure the index refcount is incremented when a new repository is being plugged a new index.
2012-04-14 15:05:38 +02:00
Russell Belfer
1de77cd314 Cannot set workdir to a nonexistent dir 2012-04-11 12:10:14 -07:00
nulltoken
b78fb64d2f repository: make git_repository_set_workdir() prettify the path it is being passed 2012-04-11 12:40:21 +02:00