summaryrefslogtreecommitdiff
path: root/src/checkout.c
Commit message (Collapse)AuthorAgeFilesLines
* checkout: pass string instead of git_buf to `giterr_set`Patrick Steinhardt2016-11-141-2/+2
|
* checkout: don't try to calculate oid for directoriesethomson/checkout_dont_calculate_oid_for_dirsEdward Thomson2016-09-141-0/+4
| | | | | | | | | | | | | | | | | | | When trying to determine if we can safely overwrite an existing workdir item, we may need to calculate the oid for the workdir item to determine if its identical to the old side (and eligible for removal). We previously did this regardless of the type of entry in the workdir; if it was a directory, we would open(2) it and then try to read(2). The read(2) of a directory fails on many platforms, so we would treat it as if it were unmodified and continue to perform the checkout. On FreeBSD, you _can_ read(2) a directory, so this pattern failed. We would calculate an oid from the data read and determine that the directory was modified and would therefore generate a checkout conflict. This reliance on read(2) is silly (and was most likely accidentally giving us the behavior we wanted), we should be explicit about the directory test.
* git_checkout_tree options fixStefan Huber2016-08-301-1/+1
| | | | | | | | According to the reference the git_checkout_tree and git_checkout_head functions should accept NULL in the opts field This was broken since the opts field was dereferenced and thus lead to a crash.
* Merge pull request #3223 from ethomson/applyEdward Thomson2016-06-251-0/+1
|\ | | | | Reading patch files
| * git_diff_generated: abstract generated diffsEdward Thomson2016-05-261-0/+1
| |
* | checkout: use empty baseline when no indexethomson/checkout_no_indexEdward Thomson2016-06-151-1/+6
|/ | | | | When no index file exists and a baseline is not explicitly provided, use an empty baseline instead of trying to load `HEAD`.
* checkout: handle dirty submodules correctlyJason Haslam2016-05-261-1/+2
| | | | | Don't generate conflicts when checking out a modified submodule and the submodule is dirty or modified in the workdir.
* checkout: set ignorecase=0 when config lookup failsPatrick Steinhardt2016-05-021-2/+4
| | | | | | | | | | When `git_repository__cvar` fails we may end up with a `ignorecase` value of `-1`. As we subsequently check if `ignorecase` is non-zero, we may end up reporting that data should be removed when in fact it should not. Err on the safer side and set `ignorecase = 0` when `git_repository__cvar` fails.
* iterator: drop `advance_into_or_over`Edward Thomson2016-03-231-1/+1
| | | | | | Now that iterators do not return `GIT_ENOTFOUND` when advancing into an empty directory, we do not need a special `advance_into_or_over` function.
* iterator: combine fs+workdir iterators more completelyEdward Thomson2016-03-231-6/+6
| | | | | | | | | | | | | Drop some of the layers of indirection between the workdir and the filesystem iterators. This makes the code a little bit easier to follow, and reduces the number of unnecessary allocations a bit as well. (Prior to this, when we filter entries, we would allocate them, filter them and then free them; now we do the filtering before allocation.) Also, rename `git_iterator_advance_over_with_status` to just `git_iterator_advance_over`. Mostly because it's a fucking long-ass function name otherwise.
* checkout: provide internal func to compute target pathEdward Thomson2016-03-231-32/+54
| | | | | | | | | | | Many code paths in checkout need the final, full on-disk path of the file they're writing. (No surprise). However, they all munge the `data->path` buffer themselves to get there. Provide a nice helper method for them. Plus, drop the use `git_iterator_current_workdir_path` which does the same thing but different. Checkout is the only caller of this silly function, which lets us remove it.
* iterator: disambiguate reset and reset_rangeEdward Thomson2016-03-231-1/+1
| | | | | | Disambiguate the reset and reset_range functions. Now reset_range with a NULL path will clear the start or end; reset will leave the existing start and end unchanged.
* Merge pull request #3619 from ethomson/win32_forbiddenCarlos Martín Nieto2016-02-181-1/+1
|\ | | | | win32: allow us to read indexes with forbidden paths on win32
| * index: allow read of index w/ illegal entriesEdward Thomson2016-02-171-1/+1
| | | | | | | | | | | | | | | | | | Allow `git_index_read` to handle reading existing indexes with illegal entries. Allow the low-level `git_index_add` to add properly formed `git_index_entry`s even if they contain paths that would be illegal for the current filesystem (eg, `AUX`). Continue to disallow `git_index_add_bypath` from adding entries that are illegal universally illegal (eg, `.git`, `foo/../bar`).
* | Horrible fix for #3173.Arthur Schreiber2016-02-111-2/+3
| |
* | checkout: fix resource leakPatrick Steinhardt2016-02-091-1/+3
|/
* checkout: only consider nsecs when built that wayEdward Thomson2015-11-231-2/+1
| | | | | | | | When examining the working directory and determining whether it's up-to-date, only consider the nanoseconds in the index entry when built with `GIT_USE_NSEC`. This prevents us from believing that the working directory is always dirty when the index was originally written with a git client that uinderstands nsecs (like git 2.x).
* pool: Simplify implementationVicent Marti2015-10-281-2/+5
|
* diff: don't feed large files to xdiffEdward Thomson2015-10-051-1/+2
|
* git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-171-1/+1
| | | | | | | | | | | | Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter assumes that we own everything beneath the base, as if it were being called with a base of the repository or working directory, and is tailored towards checkout and ensuring that there is no bogosity beneath the base that must be cleaned up. This is (at best) slow and (at worst) unsafe in the larger context of a filesystem where we do not own things and cannot do things like unlink symlinks that are in our way.
* checkout: overwrite files with differing modesEdward Thomson2015-09-161-9/+6
| | | | | | | | | | | When a file exists on disk and we're checking out a file that differs in executableness, remove the old file. This allows us to recreate the new file with p_open, which will take the new mode into account and handle setting the umask properly. Remove any notion of chmod'ing existing files, since it is now handled by the aforementioned removal and was incorrect, as it did not take umask into account.
* checkout: use pathlist-based iteratorsEdward Thomson2015-08-301-1/+7
|
* iterator: use an options struct instead of argsEdward Thomson2015-08-281-10/+16
|
* Fix #3094 - improve use of portable size_t/ssize_t format specifiers.Matthew Plough2015-07-121-2/+2
| | | | The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c. For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
* Rename FALLBACK to UNSPECIFIEDcmn/rename-unspecifiedCarlos Martín Nieto2015-06-251-1/+1
| | | | | Fallback describes the mechanism, while unspecified explains what the user is thinking.
* submodule: add an ignore option to statusCarlos Martín Nieto2015-06-221-1/+1
| | | | | | | | | | | | | This lets us specify in the status call which ignore rules we want to use (optionally falling back to whatever the submodule has in its configuration). This removes one of the reasons for having `_set_ignore()` set the value in-memory. We re-use the `IGNORE_RESET` value for this as it is no longer relevant but has a similar purpose to `IGNORE_FALLBACK`. Similarly, we remove `IGNORE_DEFAULT` which does not have use outside of initializers and move that to fall back to the configuration as well.
* submodule: don't let status change an existing instanceCarlos Martín Nieto2015-06-221-1/+1
| | | | | | As submodules are becomes more like values, we should not let a status check to update its properties. Instead of taking a submodule, have status take a repo and submodule name.
* submodule: remove the per-repo cacheCarlos Martín Nieto2015-06-221-7/+1
| | | | | | | | | | | | | Having this cache and giving them out goes against our multithreading guarantees and it makes it impossible to use submodules in a multi-threaded environment, as any thread can ask for a refresh which may reallocate some string in the submodule struct which we've accessed in a different one via a getter. This makes the submodules behave more like remotes, where each object is created upon request and not shared except explicitly by the user. This means that some tests won't pass yet, as they assume they can affect the submodule objects in the cache and that will affect later operations.
* diff: preserve original mode in the indexEdward Thomson2015-06-201-1/+1
| | | | | | | When updating the index during a diff, preserve the original mode, which prevents us from dropping the mode to what we have interpreted as on our system (eg, what the working directory claims it to be, which may be a lie on some systems.)
* checkout: allow workdir to contain checkout targetethomson/racy-diffcmn/racy-diffEdward Thomson2015-06-161-3/+14
| | | | | | When checking out some file 'foo' that has been modified in the working directory, allow the checkout to proceed (do not conflict) if 'foo' is identical to the target of the checkout.
* Rename GIT_EMERGECONFLICT to GIT_ECONFLICTEdward Thomson2015-05-291-3/+3
| | | | | | | | | | We do not error on "merge conflicts"; on the contrary, merge conflicts are a normal part of merging. We only error on "checkout conflicts", where a change exists in the index or the working directory that would otherwise be overwritten by performing the checkout. This *may* happen during merge (after the production of the new index that we're going to checkout) but it could happen during any checkout.
* checkout: allow baseline to be specified as indexEdward Thomson2015-05-111-5/+14
| | | | | | 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.
* checkout: break case-changes into delete/addEdward Thomson2015-05-041-1/+2
| | | | | | | When checking out with a case-insensitive working directory, we want to change the case of items in the working directory to reflect changes that occured in the checkout target. Diff now has an option to break case-changing renames into delete/add.
* checkout: remove blocking dir when FORCEdEdward Thomson2015-05-041-3/+26
|
* Revert "Always checkout with case sensitive iterator"Edward Thomson2015-05-041-1/+1
| | | | This reverts commit 40d791545abfb3cb71553a27dc64129e1a9bec28.
* Fix some build warningsLeo Yang2015-04-281-1/+1
| | | | | | | | | | | | In checkout.c and filter.c we were casting a sub struct to a parent struct which breaks the strict aliasing rules in C. However we can use .parent or .base to access the parent struct to avoid the build warnings. In remote.c the local variable error was not initialized or updated in some cases. For unintialized error a build warning will be generated. So always keep error variable up-to-date.
* Merge pull request #3010 from ethomson/checkout_invalid_path_errCarlos Martín Nieto2015-03-241-1/+1
|\ | | | | checkout: report correct invalid path
| * checkout: report correct invalid pathEdward Thomson2015-03-231-1/+1
| |
* | config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-031-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
* | checkout: remove `GIT_CHECKOUT_SAFE_CREATE` as a strategyEdward Thomson2015-02-271-9/+8
| |
* | checkout: upgrade to `SAFE_CREATE` when no index fileEdward Thomson2015-02-271-0/+7
|/ | | | | | When the repository does not contain an index, emulate git's behavior and upgrade to `SAFE_CREATE`. This allows us to check out repositories created with `git clone --no-checkout`.
* filter: take `temp_buf` in `git_filter_options`Edward Thomson2015-02-191-3/+2
|
* filter: add `git_filter_list__load_ext`Edward Thomson2015-02-191-6/+12
| | | | | Refactor `git_filter_list__load_with_attr_reader` into `git_filter_list__load_ext`, which takes a `git_filter_options`.
* git_filter_opt_t -> git_filter_flag_tEdward Thomson2015-02-191-2/+2
| | | | | For consistency with the rest of the library, where an opt is an options *structure*.
* checkout: let the stream writer close the fdEdward Thomson2015-02-181-2/+1
|
* git_writestream: from git_filter_streamEdward Thomson2015-02-181-5/+5
|
* checkout: maintain temporary buffer for filtersEdward Thomson2015-02-171-0/+3
| | | | | Let the filters use the checkout data's temporary buffer, instead of having to allocate new buffers each time.
* checkout: stream the blob into the filtersEdward Thomson2015-02-171-39/+82
| | | | Use the new streaming filter API during checkout.
* Remove extra semicolon outside of a functionStefan Widgren2015-02-151-1/+1
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* checkout: introduce GIT_CHECKOUT_DONT_WRITE_INDEXEdward Thomson2015-02-141-1/+4
|