Commit Graph

9946 Commits

Author SHA1 Message Date
Patrick Steinhardt
2a503485fa worktree: implement locking mechanisms
Working trees support locking by creating a file `locked` inside
the tree's gitdir with an optional reason inside. Support this
feature by adding functions to get and set the locking status.
2017-02-13 11:01:09 +01:00
Patrick Steinhardt
dea7488e93 worktree: implement git_worktree_add
Implement the `git_worktree_add` function which can be used to create
new working trees for a given repository.
2017-02-13 11:00:17 +01:00
Patrick Steinhardt
372dc9ff6a worktree: implement git_worktree_validate
Add a new function that checks wether a given `struct
git_worktree` is valid. The validation includes checking if the
gitdir, parent directory and common directory are present.
2017-02-13 10:59:16 +01:00
Patrick Steinhardt
8c8d726ef7 worktree: implement git_repository_open_from_worktree
Add function `git_repository_open_from_worktree`, which allows to open a
`git_worktree` as repository.
2017-02-13 10:59:04 +01:00
Patrick Steinhardt
d3bc09e816 worktree: introduce struct git_worktree
Introduce a new `struct git_worktree`, which holds information
about a possible working tree connected to a repository.
Introduce functions to allow opening working trees for a
repository.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
45f2b7a43f worktree: implement git_worktree_list
Add new module for working trees with the `git_worktree_list`
function. The function lists names for all working trees of a
certain repository.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
854b5c70e3 repository: expose repo_init_create_head
Expose the function `repo_init_create_head` as
`git_repository_create_head`.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
4292837d50 config: open configuration in commondir
A repository's configuartion file can always be found in the
GIT_COMMON_DIR, which has been newly introduced. For normal
repositories this does change nothing, but for working trees this
change allows to access the shared configuration file.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
e9403024fe refdb: look for reflog in commondir 2017-02-13 10:28:15 +01:00
Patrick Steinhardt
e0a6c28eb3 refdb: introduce commondir awareness
The refdb_fs_backend is not aware of the git commondir, which
stores common objects like the o bject database and packed/loose
refereensces when worktrees are used.

Make refdb_fs_backend aware of the common directory by
introducing a new commonpath variable that points to the actual
common path of the database and using it instead of the gitdir
for the mentioned objects.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
71dd086195 refdb: rename refdb_fs_backend's .path to .gitpath
The variable '.path' of the refdb_fs_backend struct becomes
confusing regarding the introduction of the git commondir. It
does not immediatly become obvious what it should point to.

Fix this problem by renaming the variable to `gitpath`,
clarifying that it acutally points to the `.git` directory of the
repository, in contrast to the commonpath directory, which points
to the directory containing shared objects like references and
the object store.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
79ab3ef69f repository: introduce is_worktree variable 2017-02-13 10:28:15 +01:00
Patrick Steinhardt
c5f3da9692 repository: use git_repository_item_path
The recent introduction of the commondir variable of a repository
requires callers to distinguish whether their files are part of
the dot-git directory or the common directory shared between
multpile worktrees. In order to take the burden from callers and
unify knowledge on which files reside where, the
`git_repository_item_path` function has been introduced which
encapsulate this knowledge.

Modify most existing callers of `git_repository_path` to use
`git_repository_item_path` instead, thus making them implicitly
aware of the common directory.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
cb3269c970 repository: add function to retrieve paths for repo items 2017-02-13 10:28:15 +01:00
Patrick Steinhardt
c09fd54e2e repository: introduce commondir variable
The commondir variable stores the path to the common directory.
The common directory is used to store objects and references
shared across multiple repositories. A current use case is the
newly introduced `git worktree` feature, which sets up a separate
working copy, where the backing git object store and references
are pointed to by the common directory.
2017-02-13 10:13:02 +01:00
Patrick Steinhardt
807d57e7df tests: implement worktree helpers 2017-02-13 10:13:02 +01:00
Patrick Steinhardt
8acc3b16ef tests: add merge-conflict branch for testrepo
Add a new branch that causes a merge conflict to `testrepo` so
that we are able to test merging in worktrees.
2017-02-13 10:13:02 +01:00
Patrick Steinhardt
e5a620de80 tests: add submodule worktree test data
Create worktrees for submodule repositories. The worktrees are
created for the parent repository (e.g. the one containing
submodules) and for the contained child repository.
2017-02-13 10:13:02 +01:00
Patrick Steinhardt
bd9f4fd24c tests: add worktree test data 2017-02-13 10:13:02 +01:00
Edward Thomson
b0c3fa36c1 Merge pull request #4112 from cbargren/fix/proxy-env-vars
Add support for lowercase proxy environment variables
2017-02-10 16:15:41 +00:00
Christopher Bargren
61189a115b Fixing a code style issue 2017-02-10 07:59:22 -07:00
Edward Thomson
683ff4f323 Merge pull request #4111 from pks-t/pks/dos-prefix
dirname with DOS prefixes
2017-02-10 11:01:23 +00:00
Edward Thomson
2b8163b8b3 Merge pull request #4117 from rcjsuen/patch-1
Flag options in git_stash_apply and git_stash_pop as being optional
2017-02-10 10:59:27 +00:00
Edward Thomson
45d55797b6 Merge pull request #4119 from libgit2/ethomson/submodule_renames
rename detection: don't try to detect submodule renames
2017-02-10 08:57:37 +00:00
Edward Thomson
191474a1f4 diff: don't do rename detection on submodules 2017-02-09 22:35:09 +00:00
Edward Thomson
95367366b2 merge: don't do rename detection on submodules 2017-02-09 18:28:39 +00:00
Edward Thomson
49806e9bc4 merge_trees: introduce test for submodule renames
Test that shows that submodules are incorrectly considered in renames,
and `git_merge_trees` will fail to lookup the submodule as a blob.
2017-02-09 18:13:06 +00:00
Remy Suen
93e2c74493 Flag optional parameters for apply and pop
The options parameter in both git_stash_apply and git_stash_pop can
be NULL. They should be flagged as such in the documentation.
2017-02-09 19:12:31 +09:00
Edward Thomson
b4bd5e8453 Merge pull request #4104 from cbargren/fix/windows-digest-proxy
Fix digest credentials for proxy in windows
2017-02-09 09:27:04 +00:00
Christopher Bargren
2af282d835 Addressing PR feedback 2017-02-08 15:01:30 -07:00
Christopher Bargren
5f3276c7e6 Add support for lowercase proxy environment variables
curl supports HTTPS_PROXY in addition to https_proxy (and their http counterparts). This change ensures parity with curl's behavior.
2017-02-08 15:01:24 -07:00
Patrick Steinhardt
3428a52359 tests: repo: assert discovery starting at Win32 roots finishes
As of recently, we failed to correctly discover repositories at a
Win32 system root. Instead of aborting the upwards-traversal of
the file system, we were looping infinitely when traversal
started at either a Win32 drive prefix ("C:/") or a network path
("//somehost").

The issue has been fixed, so add a test to catch regressions.
2017-02-08 12:06:05 +01:00
Patrick Steinhardt
9e8d75c7d4 path: ensure dirname on Win32 prefix always has a trailing '/'
When calling `git_path_dirname_r` on a Win32 prefix, e.g. a drive
or network share prefix, we always want to return the trailing
'/'. This does not work currently when passing in a path like
'C:', where the '/' would not be appended correctly.

Fix this by appending a '/' if we try to normalize a Win32 prefix
and there is no trailing '/'.
2017-02-08 12:05:47 +01:00
Patrick Steinhardt
5d59520ccd path: get correct dirname for Windows root
Getting the dirname of a filesystem root should return the filesystem
root itself. E.g. the dirname of "/" is always "/". On Windows, we
emulate this behavior and as such, we should return e.g. "C:/" if
calling dirname on "C:/". But we currently fail to do so and instead
return ".", as we do not check if we actually have a Windows prefix
before stripping off the last directory component.

Fix this by calling out to `win32_prefix_length` immediately after
stripping trailing slashes, returning early if we have a prefix.
2017-02-08 12:03:49 +01:00
Patrick Steinhardt
d8c06070a8 path: extract win32_path_prefix function
Extract code which determines if a path is at a Windows system's root.
This incluses drive prefixes (e.g. "C:\") as well as network computer
names (e.g. "//computername/").
2017-02-08 12:03:45 +01:00
Edward Thomson
be249bca1b Merge pull request #4109 from rcjsuen/patch-1
Flag checkout_opts in git_reset as optional
2017-02-08 10:21:55 +00:00
Christopher Bargren
1e929eb5e2 Pass proxy options payload to credentials callback 2017-02-06 11:00:06 -07:00
Chris Bargren
fa2dfcf924 Fix digest credentials for proxy in windows 2017-02-06 10:56:00 -07:00
Remy Suen
3a13365269 Flag checkout_opts in git_reset as optional
The check_outs argument can be NULL and should be flagged accordingly
in the header file.
2017-02-05 07:12:32 +09:00
Edward Thomson
887c1931a2 Merge pull request #4108 from rcjsuen/patch-1
Flag given_opts in git_revert as optional
2017-02-04 11:04:30 +01:00
Remy Suen
21d4a3783e Flag given_opts in git_revert as optional
The given_opts argument can actually be NULL and thus should be
flagged accordingly in the header file.
2017-02-04 17:24:31 +09:00
Edward Thomson
104a1b0bd9 Merge pull request #4105 from pks-t/pks/vector-reverse-overflow
Vector reverse overflow
2017-02-02 17:21:23 +01:00
Patrick Steinhardt
f47db3c799 vector: do not reverse a vector if it is empty
The code reversing a vector initially determines the rear-pointer by
simply subtracting 1 from the vector's length. Obviously, this fails if
the vector is empty, in which case we have an integer overflow.

Fix the issue by returning early if the vector is empty.
2017-02-02 16:02:57 +01:00
Adam Niedzielski
390431c322 revwal: add failing test for walking with topo-sort 2017-02-02 16:01:37 +01:00
Edward Thomson
9ba610a11a Merge pull request #4096 from mplough/master
Update docs for git_oid_fromstrn and p
2017-02-02 13:31:33 +00:00
Matthew Plough
921493cc94 Update docs for git_oid_fromstrn and p 2017-01-27 14:37:16 -05:00
Edward Thomson
dad3c319d7 Merge pull request #4095 from mplough/master
Fix uninitialized variable warning
2017-01-27 17:56:52 +00:00
Matthew Plough
d0c418c0bb Fix uninitialized variable warning
Fix the following warning emitted by clang:
[ 16%] Building C object CMakeFiles/libgit2_clar.dir/src/submodule.c.o
/Users/mplough/devel/external/libgit2/src/submodule.c:408:6: warning: variable 'i' is used uninitialized whenever 'if' condition is true
      [-Wsometimes-uninitialized]
        if ((error = load_submodule_names(names, cfg)))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mplough/devel/external/libgit2/src/submodule.c:448:20: note: uninitialized use occurs here
        git_iterator_free(i);
                          ^
/Users/mplough/devel/external/libgit2/src/submodule.c:408:2: note: remove the 'if' if its condition is always false
        if ((error = load_submodule_names(names, cfg)))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mplough/devel/external/libgit2/src/submodule.c:404:17: note: initialize the variable 'i' to silence this warning
        git_iterator *i;
                       ^
                        = NULL
1 warning generated.
2017-01-27 12:49:48 -05:00
Carlos Martín Nieto
8df1cfc9d7 Merge pull request #4086 from libgit2/ethomson/fixes
WIP: some coverity & compiler warning fixes
2017-01-24 21:26:41 +00:00
Carlos Martín Nieto
9b51cc82ff Merge pull request #4050 from ethomson/ethomson/winhttp_errmsgs
WinHTTP: set proper error messages when SSL fails
2017-01-24 21:10:46 +00:00