mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Binary file not shown.
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user