diff --git a/git2/frameworks/libgit2.0.17.0.dylib b/git2/frameworks/libgit2.0.17.0.dylib index 933ca3765..6cee2cf63 100755 Binary files a/git2/frameworks/libgit2.0.17.0.dylib and b/git2/frameworks/libgit2.0.17.0.dylib differ diff --git a/git2/include/git2.h b/git2/include/git2.h index e138e279a..5f9fc4824 100644 --- a/git2/include/git2.h +++ b/git2/include/git2.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/attr.h b/git2/include/git2/attr.h index b1a7e0eb6..dea44f0e3 100644 --- a/git2/include/git2/attr.h +++ b/git2/include/git2/attr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/blob.h b/git2/include/git2/blob.h index 30055b614..0c0f3e580 100644 --- a/git2/include/git2/blob.h +++ b/git2/include/git2/blob.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -91,7 +91,7 @@ GIT_INLINE(const git_oid *) git_blob_id(const git_blob *blob) * @param blob pointer to the blob * @return the pointer; NULL if the blob has no contents */ -GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob); +GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob); /** * Get the size in bytes of the contents of a blob @@ -99,7 +99,7 @@ GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob); * @param blob pointer to the blob * @return size on bytes */ -GIT_EXTERN(git_off_t) git_blob_rawsize(git_blob *blob); +GIT_EXTERN(git_off_t) git_blob_rawsize(const git_blob *blob); /** * Read a file from the working folder of a repository diff --git a/git2/include/git2/branch.h b/git2/include/git2/branch.h index f55903cd6..3bda43170 100644 --- a/git2/include/git2/branch.h +++ b/git2/include/git2/branch.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/checkout.h b/git2/include/git2/checkout.h index c36e2a41b..dfc7e0580 100644 --- a/git2/include/git2/checkout.h +++ b/git2/include/git2/checkout.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -9,8 +9,7 @@ #include "common.h" #include "types.h" -#include "indexer.h" -#include "strarray.h" +#include "diff.h" /** * @file git2/checkout.h @@ -24,105 +23,113 @@ GIT_BEGIN_DECL /** * Checkout behavior flags * - * These flags control what checkout does with files. Pass in a - * combination of these values OR'ed together. If you just pass zero - * (i.e. no flags), then you are effectively doing a "dry run" where no - * files will be modified. + * In libgit2, checkout is used to update the working directory and index + * to match a target tree. Unlike git checkout, it does not move the HEAD + * commit for you - use `git_repository_set_head` or the like to do that. * - * Checkout groups the working directory content into 3 classes of files: - * (1) files that don't need a change, and files that do need a change - * that either (2) we are allowed to modifed or (3) we are not. The flags - * you pass in will decide which files we are allowed to modify. + * Checkout looks at (up to) four things: the "target" tree you want to + * check out, the "baseline" tree of what was checked out previously, the + * working directory for actual files, and the index for staged changes. * - * By default, checkout is not allowed to modify any files. Anything - * needing a change would be considered a conflict. + * You give checkout one of four strategies for update: * - * GIT_CHECKOUT_UPDATE_UNMODIFIED means that checkout is allowed to update - * any file where the working directory content matches the HEAD - * (e.g. either the files match or the file is absent in both places). + * - `GIT_CHECKOUT_NONE` is a dry-run strategy that checks for conflicts, + * etc., but doesn't make any actual changes. * - * GIT_CHECKOUT_UPDATE_MISSING means checkout can create a missing file - * that exists in the index and does not exist in the working directory. - * This is usually desirable for initial checkout, etc. Technically, the - * missing file differs from the HEAD, which is why this is separate. + * - `GIT_CHECKOUT_FORCE` is at the opposite extreme, taking any action to + * make the working directory match the target (including potentially + * discarding modified files). * - * GIT_CHECKOUT_UPDATE_MODIFIED means checkout is allowed to update files - * where the working directory does not match the HEAD so long as the file - * actually exists in the HEAD. This option implies UPDATE_UNMODIFIED. + * In between those are `GIT_CHECKOUT_SAFE` and `GIT_CHECKOUT_SAFE_CREATE` + * both of which only make modifications that will not lose changes. * - * GIT_CHECKOUT_UPDATE_UNTRACKED means checkout is allowed to update files - * even if there is a working directory version that does not exist in the - * HEAD (i.e. the file was independently created in the workdir). This - * implies UPDATE_UNMODIFIED | UPDATE_MISSING (but *not* UPDATE_MODIFIED). + * | target == baseline | target != baseline | + * ---------------------|-----------------------|----------------------| + * workdir == baseline | no action | create, update, or | + * | | delete file | + * ---------------------|-----------------------|----------------------| + * workdir exists and | no action | conflict (notify | + * is != baseline | notify dirty MODIFIED | and cancel checkout) | + * ---------------------|-----------------------|----------------------| + * workdir missing, | create if SAFE_CREATE | create file | + * baseline present | notify dirty DELETED | | + * ---------------------|-----------------------|----------------------| + * + * The only difference between SAFE and SAFE_CREATE is that SAFE_CREATE + * will cause a file to be checked out if it is missing from the working + * directory even if it is not modified between the target and baseline. * * - * On top of these three basic strategies, there are some modifiers - * options that can be applied: + * To emulate `git checkout`, use `GIT_CHECKOUT_SAFE` with a checkout + * notification callback (see below) that displays information about dirty + * files. The default behavior will cancel checkout on conflicts. * - * If any files need update but are disallowed by the strategy, normally - * checkout calls the conflict callback (if given) and then aborts. - * GIT_CHECKOUT_ALLOW_CONFLICTS means it is okay to update the files that - * are allowed by the strategy even if there are conflicts. The conflict - * callbacks are still made, but non-conflicting files will be updated. + * To emulate `git checkout-index`, use `GIT_CHECKOUT_SAFE_CREATE` with a + * notification callback that cancels the operation if a dirty-but-existing + * file is found in the working directory. This core git command isn't + * quite "force" but is sensitive about some types of changes. * - * Any unmerged entries in the index are automatically considered conflicts. - * If you want to proceed anyhow and just skip unmerged entries, you can use - * GIT_CHECKOUT_SKIP_UNMERGED which is less dangerous than just allowing all - * conflicts. Alternatively, use GIT_CHECKOUT_USE_OURS to proceed and - * checkout the stage 2 ("ours") version. GIT_CHECKOUT_USE_THEIRS means to - * proceed and use the stage 3 ("theirs") version. + * To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`. * - * GIT_CHECKOUT_UPDATE_ONLY means that update is not allowed to create new - * files or delete old ones, only update existing content. With this - * flag, files that needs to be created or deleted are not conflicts - - * they are just skipped. This also skips typechanges to existing files - * (because the old would have to be removed). - * - * GIT_CHECKOUT_REMOVE_UNTRACKED means that files in the working directory - * that are untracked (and not ignored) will be removed altogether. These - * untracked files (that do not shadow index entries) are not considered - * conflicts and would normally be ignored. + * To emulate `git clone` use `GIT_CHECKOUT_SAFE_CREATE` in the options. * * - * Checkout is "semi-atomic" as in it will go through the work to be done - * before making any changes and if may decide to abort if there are - * conflicts, or you can use the conflict callback to explicitly abort the - * action before any updates are made. Despite this, if a second process - * is modifying the filesystem while checkout is running, it can't - * guarantee that the choices is makes while initially examining the - * filesystem are still going to be correct as it applies them. + * There are some additional flags to modified the behavior of checkout: + * + * - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates + * even if there are conflicts (instead of cancelling the checkout). + * + * - GIT_CHECKOUT_REMOVE_UNTRACKED means remove untracked files (i.e. not + * in target, baseline, or index, and not ignored) from the working dir. + * + * - GIT_CHECKOUT_REMOVE_IGNORED means remove ignored files (that are also + * untracked) from the working directory as well. + * + * - GIT_CHECKOUT_UPDATE_ONLY means to only update the content of files that + * already exist. Files will not be created nor deleted. This just skips + * applying adds, deletes, and typechanges. + * + * - GIT_CHECKOUT_DONT_UPDATE_INDEX prevents checkout from writing the + * updated files' information to the index. + * + * - Normally, checkout will reload the index and git attributes from disk + * before any operations. GIT_CHECKOUT_NO_REFRESH prevents this reload. + * + * - Unmerged index entries are conflicts. GIT_CHECKOUT_SKIP_UNMERGED skips + * files with unmerged index entries instead. GIT_CHECKOUT_USE_OURS and + * GIT_CHECKOUT_USE_THEIRS to proceed with the checkout using either the + * stage 2 ("ours") or stage 3 ("theirs") version of files in the index. */ typedef enum { - GIT_CHECKOUT_DEFAULT = 0, /** default is a dry run, no actual updates */ + GIT_CHECKOUT_NONE = 0, /** default is a dry run, no actual updates */ - /** Allow update of entries where working dir matches HEAD. */ - GIT_CHECKOUT_UPDATE_UNMODIFIED = (1u << 0), + /** Allow safe updates that cannot overwrite uncommitted data */ + GIT_CHECKOUT_SAFE = (1u << 0), - /** Allow update of entries where working dir does not have file. */ - GIT_CHECKOUT_UPDATE_MISSING = (1u << 1), - - /** Allow safe updates that cannot overwrite uncommited data */ - GIT_CHECKOUT_SAFE = - (GIT_CHECKOUT_UPDATE_UNMODIFIED | GIT_CHECKOUT_UPDATE_MISSING), - - /** Allow update of entries in working dir that are modified from HEAD. */ - GIT_CHECKOUT_UPDATE_MODIFIED = (1u << 2), - - /** Update existing untracked files that are now present in the index. */ - GIT_CHECKOUT_UPDATE_UNTRACKED = (1u << 3), + /** Allow safe updates plus creation of missing files */ + GIT_CHECKOUT_SAFE_CREATE = (1u << 1), /** Allow all updates to force working directory to look like index */ - GIT_CHECKOUT_FORCE = - (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_UPDATE_MODIFIED | GIT_CHECKOUT_UPDATE_UNTRACKED), + GIT_CHECKOUT_FORCE = (1u << 2), - /** Allow checkout to make updates even if conflicts are found */ + + /** Allow checkout to make safe updates even if conflicts are found */ GIT_CHECKOUT_ALLOW_CONFLICTS = (1u << 4), /** Remove untracked files not in index (that are not ignored) */ GIT_CHECKOUT_REMOVE_UNTRACKED = (1u << 5), + /** Remove ignored files not in index */ + GIT_CHECKOUT_REMOVE_IGNORED = (1u << 6), + /** Only update existing files, don't create new ones */ - GIT_CHECKOUT_UPDATE_ONLY = (1u << 6), + GIT_CHECKOUT_UPDATE_ONLY = (1u << 7), + + /** Normally checkout updates index entries as it goes; this stops that */ + GIT_CHECKOUT_DONT_UPDATE_INDEX = (1u << 8), + + /** Don't refresh index/config/etc before doing checkout */ + GIT_CHECKOUT_NO_REFRESH = (1u << 9), /** * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED @@ -142,56 +149,92 @@ typedef enum { } git_checkout_strategy_t; +/** + * Checkout notification flags + * + * Checkout will invoke an options notification callback (`notify_cb`) for + * certain cases - you pick which ones via `notify_flags`: + * + * - GIT_CHECKOUT_NOTIFY_CONFLICT invokes checkout on conflicting paths. + * + * - GIT_CHECKOUT_NOTIFY_DIRTY notifies about "dirty" files, i.e. those that + * do not need an update but no longer match the baseline. Core git + * displays these files when checkout runs, but won't stop the checkout. + * + * - GIT_CHECKOUT_NOTIFY_UPDATED sends notification for any file changed. + * + * - GIT_CHECKOUT_NOTIFY_UNTRACKED notifies about untracked files. + * + * - GIT_CHECKOUT_NOTIFY_IGNORED notifies about ignored files. + * + * Returning a non-zero value from this callback will cancel the checkout. + * Notification callbacks are made prior to modifying any files on disk. + */ +typedef enum { + GIT_CHECKOUT_NOTIFY_NONE = 0, + GIT_CHECKOUT_NOTIFY_CONFLICT = (1u << 0), + GIT_CHECKOUT_NOTIFY_DIRTY = (1u << 1), + GIT_CHECKOUT_NOTIFY_UPDATED = (1u << 2), + GIT_CHECKOUT_NOTIFY_UNTRACKED = (1u << 3), + GIT_CHECKOUT_NOTIFY_IGNORED = (1u << 4), +} git_checkout_notify_t; + +/** Checkout notification callback function */ +typedef int (*git_checkout_notify_cb)( + git_checkout_notify_t why, + const char *path, + const git_diff_file *baseline, + const git_diff_file *target, + const git_diff_file *workdir, + void *payload); + +/** Checkout progress notification function */ +typedef void (*git_checkout_progress_cb)( + const char *path, + size_t completed_steps, + size_t total_steps, + void *payload); + /** * Checkout options structure * - * Use zeros to indicate default settings. - * This needs to be initialized with the `GIT_CHECKOUT_OPTS_INIT` macro: + * Zero out for defaults. Initialize with `GIT_CHECKOUT_OPTS_INIT` macro to + * correctly set the `version` field. E.g. * * git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; */ typedef struct git_checkout_opts { unsigned int version; + unsigned int checkout_strategy; /** default will be a dry run */ - int disable_filters; /** don't apply filters like CRLF conversion */ - int dir_mode; /** default is 0755 */ - int file_mode; /** default is 0644 or 0755 as dictated by blob */ - int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */ + int disable_filters; /** don't apply filters like CRLF conversion */ + unsigned int dir_mode; /** default is 0755 */ + unsigned int file_mode; /** default is 0644 or 0755 as dictated by blob */ + int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */ - /** Optional callback made on files where the index differs from the - * working directory but the rules do not allow update. Return a - * non-zero value to abort the checkout. All such callbacks will be - * made before any changes are made to the working directory. - */ - int (*conflict_cb)( - const char *conflicting_path, - const git_oid *index_oid, - unsigned int index_mode, - unsigned int wd_mode, - void *payload); - void *conflict_payload; + unsigned int notify_flags; /** see `git_checkout_notify_t` above */ + git_checkout_notify_cb notify_cb; + void *notify_payload; /* Optional callback to notify the consumer of checkout progress. */ - void (*progress_cb)( - const char *path, - size_t completed_steps, - size_t total_steps, - void *payload); + git_checkout_progress_cb progress_cb; void *progress_payload; /** When not zeroed out, array of fnmatch patterns specifying which * paths should be taken into account, otherwise all files. */ git_strarray paths; + + git_tree *baseline; /** expected content of workdir, defaults to HEAD */ } git_checkout_opts; #define GIT_CHECKOUT_OPTS_VERSION 1 #define GIT_CHECKOUT_OPTS_INIT {GIT_CHECKOUT_OPTS_VERSION} /** - * Updates files in the index and the working tree to match the content of the - * commit pointed at by HEAD. + * Updates files in the index and the working tree to match the content of + * the commit pointed at by HEAD. * * @param repo repository to check out (must be non-bare) * @param opts specifies checkout options (may be NULL) diff --git a/git2/include/git2/clone.h b/git2/include/git2/clone.h index c6ab8032b..e299c155d 100644 --- a/git2/include/git2/clone.h +++ b/git2/include/git2/clone.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/commit.h b/git2/include/git2/commit.h index 872f691ce..764053eaa 100644 --- a/git2/include/git2/commit.h +++ b/git2/include/git2/commit.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/common.h b/git2/include/git2/common.h index ad23d2d34..7a4c54c10 100644 --- a/git2/include/git2/common.h +++ b/git2/include/git2/common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/config.h b/git2/include/git2/config.h index b186e70da..19d4cb78d 100644 --- a/git2/include/git2/config.h +++ b/git2/include/git2/config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -297,7 +297,7 @@ GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The - * first occurence of the variable will be returned here. + * first occurrence of the variable will be returned here. * * @param out pointer to the variable where the value should be stored * @param cfg where to look for the variable @@ -314,7 +314,7 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The - * first occurence of the variable will be returned here. + * first occurrence of the variable will be returned here. * * @param out pointer to the variable where the value should be stored * @param cfg where to look for the variable @@ -331,7 +331,7 @@ GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char * * All config files will be looked into, in the order of their * defined level. A higher level means a higher priority. The - * first occurence of the variable will be returned here. + * first occurrence of the variable will be returned here. * * @param out pointer to the variable's value * @param cfg where to look for the variable diff --git a/git2/include/git2/diff.h b/git2/include/git2/diff.h index b26dd4214..c052f34f8 100644 --- a/git2/include/git2/diff.h +++ b/git2/include/git2/diff.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -241,8 +241,8 @@ typedef struct { * callback functions and you can use the contents to understand exactly * what has changed. * - * The `old_file` repesents the "from" side of the diff and the `new_file` - * repesents to "to" side of the diff. What those means depend on the + * The `old_file` represents the "from" side of the diff and the `new_file` + * represents to "to" side of the diff. What those means depend on the * function that was used to generate the diff and will be documented below. * You can also use the `GIT_DIFF_REVERSE` flag to flip it around. * @@ -802,28 +802,50 @@ GIT_EXTERN(int) git_diff_patch_to_str( */ /** - * Directly run a text diff on two blobs. + * Directly run a diff on two blobs. * * Compared to a file, a blob lacks some contextual information. As such, - * the `git_diff_file` parameters of the callbacks will be filled - * accordingly to the following: `mode` will be set to 0, `path` will be set - * to NULL. When dealing with a NULL blob, `oid` will be set to 0. + * the `git_diff_file` given to the callback will have some fake data; i.e. + * `mode` will be 0 and `path` will be NULL. * - * When at least one of the blobs being dealt with is binary, the - * `git_diff_delta` binary attribute will be set to 1 and no call to the - * hunk_cb nor line_cb will be made. + * NULL is allowed for either `old_blob` or `new_blob` and will be treated + * as an empty blob, with the `oid` set to NULL in the `git_diff_file` data. + * + * We do run a binary content check on the two blobs and if either of the + * blobs looks like binary data, the `git_diff_delta` binary attribute will + * be set to 1 and no call to the hunk_cb nor line_cb will be made (unless + * you pass `GIT_DIFF_FORCE_TEXT` of course). * * @return 0 on success, GIT_EUSER on non-zero callback, or error code */ GIT_EXTERN(int) git_diff_blobs( - git_blob *old_blob, - git_blob *new_blob, + const git_blob *old_blob, + const git_blob *new_blob, const git_diff_options *options, git_diff_file_cb file_cb, git_diff_hunk_cb hunk_cb, git_diff_data_cb line_cb, void *payload); +/** + * Directly run a diff between a blob and a buffer. + * + * As with `git_diff_blobs`, comparing a blob and buffer lacks some context, + * so the `git_diff_file` parameters to the callbacks will be faked a la the + * rules for `git_diff_blobs()`. + * + * @return 0 on success, GIT_EUSER on non-zero callback, or error code + */ +GIT_EXTERN(int) git_diff_blob_to_buffer( + const git_blob *old_blob, + const char *buffer, + size_t buffer_len, + const git_diff_options *options, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb data_cb, + void *payload); + GIT_END_DECL /** @} */ diff --git a/git2/include/git2/errors.h b/git2/include/git2/errors.h index 4eb9e94ef..9e0a1a9e6 100644 --- a/git2/include/git2/errors.h +++ b/git2/include/git2/errors.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/graph.h b/git2/include/git2/graph.h index c89efa6dd..5850aa6e2 100644 --- a/git2/include/git2/graph.h +++ b/git2/include/git2/graph.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/ignore.h b/git2/include/git2/ignore.h index 592c96e65..d0c1877a8 100644 --- a/git2/include/git2/ignore.h +++ b/git2/include/git2/ignore.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -57,7 +57,7 @@ GIT_EXTERN(int) git_ignore_clear_internal_rules( * * This function checks the ignore rules to see if they would apply to the * given file. This indicates if the file would be ignored regardless of - * whether the file is already in the index or commited to the repository. + * whether the file is already in the index or committed to the repository. * * One way to think of this is if you were to do "git add ." on the * directory containing the file, would it be added or not? diff --git a/git2/include/git2/index.h b/git2/include/git2/index.h index fa9a19785..2df5103fd 100644 --- a/git2/include/git2/index.h +++ b/git2/include/git2/index.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -312,6 +312,17 @@ GIT_EXTERN(const git_index_entry *) git_index_get_bypath( */ GIT_EXTERN(int) git_index_remove(git_index *index, const char *path, int stage); +/** + * Remove all entries from the index under a given directory + * + * @param index an existing index object + * @param dir container directory path + * @param stage stage to search + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_remove_directory( + git_index *index, const char *dir, int stage); + /** * Add or update an index entry from an in-memory struct * diff --git a/git2/include/git2/indexer.h b/git2/include/git2/indexer.h index 41a1503a4..c428d43a8 100644 --- a/git2/include/git2/indexer.h +++ b/git2/include/git2/indexer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/merge.h b/git2/include/git2/merge.h index 59493969c..f4c5d9881 100644 --- a/git2/include/git2/merge.h +++ b/git2/include/git2/merge.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/message.h b/git2/include/git2/message.h index e89d022a1..395c88690 100644 --- a/git2/include/git2/message.h +++ b/git2/include/git2/message.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/net.h b/git2/include/git2/net.h index 2543ff8e0..6e3525f5d 100644 --- a/git2/include/git2/net.h +++ b/git2/include/git2/net.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/notes.h b/git2/include/git2/notes.h index ddd54b039..c51d3732a 100644 --- a/git2/include/git2/notes.h +++ b/git2/include/git2/notes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/object.h b/git2/include/git2/object.h index e5ca17e16..e029f0125 100644 --- a/git2/include/git2/object.h +++ b/git2/include/git2/object.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/odb.h b/git2/include/git2/odb.h index 3854fa6f6..f39e7b541 100644 --- a/git2/include/git2/odb.h +++ b/git2/include/git2/odb.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/odb_backend.h b/git2/include/git2/odb_backend.h index 7b5a51ed9..029c61b9f 100644 --- a/git2/include/git2/odb_backend.h +++ b/git2/include/git2/odb_backend.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/oid.h b/git2/include/git2/oid.h index 43717ad70..6be02da6e 100644 --- a/git2/include/git2/oid.h +++ b/git2/include/git2/oid.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/pack.h b/git2/include/git2/pack.h index 585cffef6..bc628c56a 100644 --- a/git2/include/git2/pack.h +++ b/git2/include/git2/pack.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/push.h b/git2/include/git2/push.h index 900a1833e..51f059ac4 100644 --- a/git2/include/git2/push.h +++ b/git2/include/git2/push.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/reflog.h b/git2/include/git2/reflog.h index 418826d1d..4944530af 100644 --- a/git2/include/git2/reflog.h +++ b/git2/include/git2/reflog.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/refs.h b/git2/include/git2/refs.h index cfc96a68c..a0abbc339 100644 --- a/git2/include/git2/refs.h +++ b/git2/include/git2/refs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/refspec.h b/git2/include/git2/refspec.h index 1100e9022..ee06f8eca 100644 --- a/git2/include/git2/refspec.h +++ b/git2/include/git2/refspec.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -56,7 +56,7 @@ GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char * * Transform a reference to its target following the refspec's rules * * @param out where to store the target name - * @param outlen the size ouf the `out` buffer + * @param outlen the size of the `out` buffer * @param spec the refspec * @param name the name of the reference to transform * @return 0, GIT_EBUFS or another error diff --git a/git2/include/git2/remote.h b/git2/include/git2/remote.h index 5f6a78097..a0f5d5246 100644 --- a/git2/include/git2/remote.h +++ b/git2/include/git2/remote.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/repository.h b/git2/include/git2/repository.h index 1371d5409..e207e5bb5 100644 --- a/git2/include/git2/repository.h +++ b/git2/include/git2/repository.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -609,7 +609,7 @@ GIT_EXTERN(int) git_repository_set_head_detached( * updated into making it point to the peeled Commit, and 0 is returned. * * If the HEAD is already detached and points to a non commitish, the HEAD is - * unaletered, and -1 is returned. + * unaltered, and -1 is returned. * * Otherwise, the HEAD will be detached and point to the peeled Commit. * diff --git a/git2/include/git2/reset.h b/git2/include/git2/reset.h index b5fc4a6cb..00d25dff0 100644 --- a/git2/include/git2/reset.h +++ b/git2/include/git2/reset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/revparse.h b/git2/include/git2/revparse.h index 3df6fef7f..6edb7767c 100644 --- a/git2/include/git2/revparse.h +++ b/git2/include/git2/revparse.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/revwalk.h b/git2/include/git2/revwalk.h index 893ad2c9d..ad57b622e 100644 --- a/git2/include/git2/revwalk.h +++ b/git2/include/git2/revwalk.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/signature.h b/git2/include/git2/signature.h index 7a265bd8e..00d19de66 100644 --- a/git2/include/git2/signature.h +++ b/git2/include/git2/signature.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/stash.h b/git2/include/git2/stash.h index b57d47b3a..cf8bc9d4c 100644 --- a/git2/include/git2/stash.h +++ b/git2/include/git2/stash.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/status.h b/git2/include/git2/status.h index a898d1f34..d0c4a496d 100644 --- a/git2/include/git2/status.h +++ b/git2/include/git2/status.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -210,7 +210,7 @@ GIT_EXTERN(int) git_status_file( * * This function checks the ignore rules to see if they would apply to the * given file. This indicates if the file would be ignored regardless of - * whether the file is already in the index or commited to the repository. + * whether the file is already in the index or committed to the repository. * * One way to think of this is if you were to do "git add ." on the * directory containing the file, would it be added or not? diff --git a/git2/include/git2/strarray.h b/git2/include/git2/strarray.h index 338d13873..6ea570c14 100644 --- a/git2/include/git2/strarray.h +++ b/git2/include/git2/strarray.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/submodule.h b/git2/include/git2/submodule.h index 90e45cebd..1abd33e79 100644 --- a/git2/include/git2/submodule.h +++ b/git2/include/git2/submodule.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -504,6 +504,24 @@ GIT_EXTERN(int) git_submodule_status( unsigned int *status, git_submodule *submodule); +/** + * Get the locations of submodule information. + * + * This is a bit like a very lightweight version of `git_submodule_status`. + * It just returns a made of the first four submodule status values (i.e. + * the ones like GIT_SUBMODULE_STATUS_IN_HEAD, etc) that tell you where the + * submodule data comes from (i.e. the HEAD commit, gitmodules file, etc.). + * This can be useful if you want to know if the submodule is present in the + * working directory at this point in time, etc. + * + * @param status Combination of first four `GIT_SUBMODULE_STATUS` flags + * @param submodule Submodule for which to get status + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_location( + unsigned int *location_status, + git_submodule *submodule); + /** @} */ GIT_END_DECL #endif diff --git a/git2/include/git2/tag.h b/git2/include/git2/tag.h index a9773be56..1ffeb0b4a 100644 --- a/git2/include/git2/tag.h +++ b/git2/include/git2/tag.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/threads.h b/git2/include/git2/threads.h index f448f6a4d..11f89729a 100644 --- a/git2/include/git2/threads.h +++ b/git2/include/git2/threads.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/transport.h b/git2/include/git2/transport.h index c2f205295..fba5fb920 100644 --- a/git2/include/git2/transport.h +++ b/git2/include/git2/transport.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/tree.h b/git2/include/git2/tree.h index b3c22e71d..7726a6599 100644 --- a/git2/include/git2/tree.h +++ b/git2/include/git2/tree.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/types.h b/git2/include/git2/types.h index 06fcf3613..c16bb8872 100644 --- a/git2/include/git2/types.h +++ b/git2/include/git2/types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/git2/include/git2/version.h b/git2/include/git2/version.h index 8edbe323c..bc03e85d6 100644 --- a/git2/include/git2/version.h +++ b/git2/include/git2/version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index 8a334ed02..dae65d953 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -86,7 +86,7 @@ public: char *copiedPath = (char *)malloc(sizeof(char) * (strlen(path) + 1)); strcpy(copiedPath, path); git_checkout_opts options = GIT_CHECKOUT_OPTS_INIT; - options.checkout_strategy = GIT_CHECKOUT_UPDATE_MODIFIED; + options.checkout_strategy = GIT_CHECKOUT_FORCE; git_strarray paths; paths.count = 1; paths.strings = &copiedPath;