Commit Graph

40 Commits

Author SHA1 Message Date
Carlos Martín Nieto
eec1c1fe1e clone: const-ify checkout options
The removal of many options which lead to the direct usage of the
user's checkout options means we should make sure they remain const.
2013-10-02 06:42:26 +02: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
Russell Belfer
9094ae5a3c Add target directory to checkout
This adds the ability for checkout to write to a target directory
instead of having to use the working directory of the repository.
This makes it easier to do exports of repository data and the like.

This is similar to, but not quite the same as, the --prefix option
to `git checkout-index` (this will always be treated as a directory
name, not just as a simple text prefix).

As part of this, the workdir iterator was extended to take the
path to the working directory as a parameter and fallback on the
git_repository_workdir result only if it's not specified.

Fixes #1332
2013-06-21 11:55:13 -07:00
Russell Belfer
36fd9e3065 Fix checkout of modified file when missing from wd
This fixes the checkout case when a file is modified between the
baseline and the target and yet missing in the working directory.
The logic for that case appears to have been wrong.

This also adds a useful checkout notify callback to the checkout
test helpers that will count notifications and also has a debug
mode to visualize what checkout thinks that it's doing.
2013-06-21 11:20:54 -07:00
Edward Thomson
e09d18eed6 allow checkout to proceed when a dir to be removed is in use (win32) 2013-05-03 18:54:47 -05:00
Russell Belfer
40342bd2b6 Add GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH
This adds an option to checkout a la the diff option to turn off
fnmatch evaluation for pathspec entries.  This can be useful to
make sure your "pattern" in really interpretted as an exact file
match only.
2013-01-10 15:15:37 -08:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Kevin Sawicki
7eb222fc7d Correct typos in documentation 2013-01-06 10:39:35 -08:00
Russell Belfer
77cffa31db Simplify checkout documentation
This moves a lot of the detailed checkout documentation into a new
file (docs/checkout-internals.md) and simplifies the public docs
for the checkout API.
2013-01-04 15:47:43 -08:00
Russell Belfer
5cf9875a4f Add index updating to checkout
Make checkout update entries in the index for all files that are
updated and/or removed, unless flag GIT_CHECKOUT_DONT_UPDATE_INDEX
is given.  To do this, iterators were extended to allow a little
more introspection into the index being iterated over, etc.
2013-01-04 15:47:42 -08:00
Russell Belfer
7e5c8a5b41 More checkout improvements
This flips checkout back to be driven off the changes between
the baseline and the target trees.  This reinstates the complex
code for tracking the contents of the working directory, but
overall, I think the resulting logic is easier to follow.
2013-01-04 15:47:42 -08:00
Russell Belfer
cf20803170 Rework checkout internals (again)
I've tried to map out the detailed behaviors of checkout and make
sure that we're handling the various cases correctly, along with
providing options to allow us to emulate "git checkout" and "git
checkout-index" with the various flags.  I've thrown away flags
in the checkout API that seemed like clutter and added some new
ones.  Also, I've converted the conflict callback to a general
notification callback so we can emulate "git checkout" output and
display "dirty" files.

As of this commit, the new behavior is not working 100% but some
of that is probably baked into tests that are not testing the
right thing.  This is a decent snapshot point, I think, along the
way to getting the update done.
2013-01-04 15:47:42 -08:00
Ben Straub
fac43c54a6 Allow compilation as C++ 2012-12-06 19:41:52 -08:00
Ben Straub
bde336ea51 Add version fields and init macros for public input structs. 2012-11-30 12:55:45 -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
Russell Belfer
bbe6dbec81 Add explicit git_index ptr to diff and checkout
A number of diff APIs and the `git_checkout_index` API take a
`git_repository` object an operate on the index.  This updates
them to take a `git_index` pointer explicitly and only fall back
on the `git_repository` index if the index input is NULL.  This
makes it easier to operate on a temporary index.
2012-11-14 23:29:48 -08:00
Russell Belfer
0f3def715d Fix various cross-platform build issues
This fixes a number of warnings and problems with cross-platform
builds.  Among other things, it's not safe to name a member of a
structure "strcmp" because that may be #defined.
2012-11-09 13:52:07 -08:00
Russell Belfer
ad9a921b92 Rework checkout with new strategy options
This is a major reworking of checkout strategy options.  The
checkout code is now sensitive to the contents of the HEAD tree
and the new options allow you to update the working tree so that
it will match the index content only when it previously matched
the contents of the HEAD.  This allows you to, for example, to
distinguish between removing files that are in the HEAD but not
in the index, vs just removing all untracked files.

Because of various corner cases that arise, etc., this required
some additional capabilities in rmdir and other utility functions.

This includes the beginnings of an implementation of code to read
a partial tree into the index based on a pathspec, but that is
not enabled because of the possibility of creating conflicting
index entries.
2012-11-09 13:52:07 -08:00
Ben Straub
9c05c17b7a Checkout progress now reports completed/total steps 2012-10-19 20:05:18 -07:00
Ben Straub
806426565f Convert checkout_* to use progress callback 2012-10-19 19:36:21 -07:00
Ben Straub
2c8bbb27d9 Convert checkout_index to use progress callback 2012-10-19 19:34:15 -07:00
nulltoken
8b05bea870 errors: deploy GIT_EORPHANEDHEAD usage 2012-10-19 22:01:53 +02:00
Russell Belfer
4c47a8bcfe Merge pull request #968 from arrbee/diff-support-typechange
Support TYPECHANGE records in status and adjust checkout accordingly
2012-10-17 14:14:51 -07:00
Paul Thompson
b46708aaf9 Separated git_strarray from common.h. Added doxy comments. 2012-10-11 23:04:08 +11:00
Russell Belfer
fe67e404da Move enum comments next to actual values 2012-10-09 14:35:24 -07:00
Russell Belfer
0d64bef941 Add complex checkout test and then fix checkout
This started as a complex new test for checkout going through the
"typechanges" test repository, but that revealed numerous issues
with checkout, including:

* complete failure with submodules
* failure to create blobs with exec bits
* problems when replacing a tree with a blob because the tree
  "example/" sorts after the blob "example" so the delete was
  being processed after the single file blob was created

This fixes most of those problems and includes a number of other
minor changes that made it easier to do that, including improving
the TYPECHANGE support in diff/status, etc.
2012-10-09 11:59:34 -07:00
nulltoken
9e592583fc checkout: add notification callback for skipped files 2012-09-21 08:08:29 +02:00
nulltoken
397837197d checkout: Mimic git_diff_options storage of paths 2012-09-17 20:27:28 +02:00
nulltoken
5af61863dd checkout: drop git_checkout_reference() 2012-09-17 10:48:30 +02:00
nulltoken
c214fa1caf checkout: segregate checkout strategies 2012-09-17 10:48:30 +02:00
nulltoken
e93af30411 checkout: introduce git_checkout_index() 2012-09-17 10:48:27 +02:00
nulltoken
3aa443a951 checkout: introduce git_checkout_tree() 2012-09-17 10:48:26 +02:00
nulltoken
746642a6b3 checkout: fix documentation code alignment 2012-09-06 18:40:08 +02:00
Ben Straub
5280f4e698 Add checkout.h to git2.h.
Also correcting some documentation strings.
2012-07-31 19:39:06 -07:00
Ben Straub
b31667fb69 Checkout: add head- and ref-centric checkouts.
Renamed git_checkout_index to what it really was,
and removed duplicate code from clone.c. Added
git_checkout_ref, which updates HEAD and hands off
to git_checkout_head.

Added tests for the options the caller can pass to
git_checkout_*.
2012-07-27 20:31:05 -07:00
Ben Straub
095ccc013f Checkout: implementation of most options 2012-07-26 16:31:49 -07:00
Ben Straub
b401bace1b Restructure for better checkout options
* Removed the #define for defaults
* Promoted progress structure to top-level API call
  argument
2012-07-26 13:12:21 -07:00
Ben Straub
ef9905c990 checkout: introduce git_checkout_opts
Refactor checkout into several more-sensible
entry points, which consolidates common options
into a single structure that may be passed around.
2012-07-26 12:58:44 -07:00
Ben Straub
deac801de9 Fix documentation comment to match actual params. 2012-07-13 15:50:23 -07:00
Ben Straub
14741d62d9 Clone: new home for git_checkout_force. 2012-06-21 11:13:19 -07:00