Commit Graph

58 Commits

Author SHA1 Message Date
Edward Thomson
b926648839 documentation: improve docs for checkout_head
`git_checkout_head` is sadly misunderstood as something that can
switch branches.  It cannot.  Update the documentation to reflect this.
2016-06-15 15:23:39 -05:00
Edward Thomson
1f1f5c639e checkout: better document the baseline_index opt 2015-05-11 14:13:31 -04:00
Edward Thomson
73dce1f688 checkout: allow baseline to be specified as index
Allow the baseline to be specified as an index, so that users
need not write their index to a tree just to checkout with that
as the baseline.
2015-05-11 14:12:01 -04:00
Edward Thomson
96b82b11c6 checkout: remove GIT_CHECKOUT_SAFE_CREATE as a strategy 2015-02-27 13:50:44 -05:00
Edward Thomson
8639ea5f98 checkout: introduce GIT_CHECKOUT_DONT_WRITE_INDEX 2015-02-14 09:25:35 -05:00
Edward Thomson
e74340b000 checkout: remove files before writing new ones
On case insensitive filesystems, we may have files in the working
directory that case fold to a name we want to write.  Remove those
files (by default) so that we will not end up with a filename that
has the unexpected case.
2015-01-20 17:13:31 -06:00
Edward Thomson
1d50b3649d checkout: introduce git_checkout_perfdata
Checkout can now provide performance data about the number of (some)
syscalls performed using an optional callback.
2015-01-20 17:12:23 -06:00
Carlos Martín Nieto
eb5f03461f checkout: fix docs formatting for the options 2014-07-11 12:22:48 +02:00
Carlos Martín Nieto
11e2665e50 Formatting fixes for the docs
These are some issues I found while playing around with the new parser
for docurium.
2014-06-03 16:05:35 +02:00
Russell Belfer
bc91347b58 Fix remaining init_options inconsistencies
There were a couple of "init_opts()" functions a few more cases
of structure initialization that I somehow missed.
2014-05-02 09:21:33 -07:00
Ben Straub
6affd71f33 git_checkout_opts -> git_checkout_options 2014-03-06 09:44:51 -08:00
Matthew Bowen
b9f819978c Added function-based initializers for every options struct.
The basic structure of each function is courtesy of arrbee.
2014-03-05 21:49:23 -05:00
Edward Thomson
e651e8e2b5 Introduce diff3 mode for checking out conflicts 2014-01-20 17:15:13 -05:00
Edward Thomson
81a2012d99 Overwrite ignored files on checkout 2013-12-13 09:29:55 -05:00
Russell Belfer
cbd048969e Fix checkout notify callback docs and tests
The checkout notify callback behavior on non-zero return values
was not being tested.  This adds tests, fixes a bug with positive
values, and clarifies the documentation to make it clear that the
checkout can be canceled via this mechanism.
2013-12-11 10:57:50 -08:00
Sascha Cunz
352214416c Checkout: Don't assert if treeish is NULL
In git_checkout_tree, the first check tests if either repo or treeish is
NULL and says that eithor of them has to have a valid value. But there
is no code to handle the treeish == NULL case.

So, do something meaningful in that case: use HEAD instead.
2013-11-02 03:43:34 +00:00
Sascha Cunz
10749f6ca2 Checkout: Unifiy const-ness of opts parameter
Since all 3 checkout APIs perform the same operation with the options,
all of them should use the same const-ness.
2013-11-02 03:20:05 +00:00
Edward Thomson
629b661caa checkout (from index) can write conflicts 2013-10-16 16:20:06 -04:00
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