mirror of
https://github.com/git/git.git
synced 2024-11-30 21:44:02 +08:00
5521883490
The logic to checkout a different commit implements the safety to never lose user's local changes. For example, switching from a commit to another commit, when you have changed a path that is different between them, need to merge your changes to the version from the switched-to commit, which you may not necessarily be able to resolve easily. By default, "git checkout" refused to switch branches, to give you a chance to stash your local changes (or use "-m" to merge, accepting the risks of getting conflicts). This safety, however, had one deliberate hole since early June 2005. When your local change was to remove a path (and optionally to stage that removal), the command checked out the path from the switched-to commit nevertheless. This was to allow an initial checkout to happen smoothly (e.g. an initial checkout is done by starting with an empty index and switching from the commit at the HEAD to the same commit). We can tighten the rule slightly to allow this special case to pass, without losing sight of removal explicitly done by the user, by noticing if the index is truly empty when the operation begins. For historical background, see: http://thread.gmane.org/gmane.comp.version-control.git/4641/focus=4646 This case is marked as *0* in the message, which both Linus and I said "it feels somewhat wrong but otherwise we cannot start from an empty index". Signed-off-by: Junio C Hamano <gitster@pobox.com>
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
#ifndef UNPACK_TREES_H
|
|
#define UNPACK_TREES_H
|
|
|
|
#define MAX_UNPACK_TREES 8
|
|
|
|
struct unpack_trees_options;
|
|
|
|
typedef int (*merge_fn_t)(struct cache_entry **src,
|
|
struct unpack_trees_options *options);
|
|
|
|
struct unpack_trees_error_msgs {
|
|
const char *would_overwrite;
|
|
const char *not_uptodate_file;
|
|
const char *not_uptodate_dir;
|
|
const char *would_lose_untracked;
|
|
const char *bind_overlap;
|
|
};
|
|
|
|
struct unpack_trees_options {
|
|
unsigned int reset:1,
|
|
merge:1,
|
|
update:1,
|
|
index_only:1,
|
|
nontrivial_merge:1,
|
|
trivial_merges_only:1,
|
|
verbose_update:1,
|
|
aggressive:1,
|
|
skip_unmerged:1,
|
|
initial_checkout:1,
|
|
gently:1;
|
|
const char *prefix;
|
|
int pos;
|
|
struct dir_struct *dir;
|
|
merge_fn_t fn;
|
|
struct unpack_trees_error_msgs msgs;
|
|
|
|
int head_idx;
|
|
int merge_size;
|
|
|
|
struct cache_entry *df_conflict_entry;
|
|
void *unpack_data;
|
|
|
|
struct index_state *dst_index;
|
|
struct index_state *src_index;
|
|
struct index_state result;
|
|
};
|
|
|
|
extern int unpack_trees(unsigned n, struct tree_desc *t,
|
|
struct unpack_trees_options *options);
|
|
|
|
int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o);
|
|
int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o);
|
|
int bind_merge(struct cache_entry **src, struct unpack_trees_options *o);
|
|
int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o);
|
|
|
|
#endif
|