Skip to content

Commit 96379f0

Browse files
committed
Merge branch 'en/merge-directory-renames'
"git merge-recursive" backend recently learned a new heuristics to infer file movement based on how other files in the same directory moved. As this is inherently less robust heuristics than the one based on the content similarity of the file itself (rather than based on what its neighbours are doing), it sometimes gives an outcome unexpected by the end users. This has been toned down to leave the renamed paths in higher/conflicted stages in the index so that the user can examine and confirm the result. * en/merge-directory-renames: merge-recursive: switch directory rename detection default merge-recursive: give callers of handle_content_merge() access to contents merge-recursive: track information associated with directory renames t6043: fix copied test description to match its purpose merge-recursive: switch from (oid,mode) pairs to a diff_filespec merge-recursive: cleanup handle_rename_* function signatures merge-recursive: track branch where rename occurred in rename struct merge-recursive: remove ren[12]_other fields from rename_conflict_info merge-recursive: shrink rename_conflict_info merge-recursive: move some struct declarations together merge-recursive: use 'ci' for rename_conflict_info variable name merge-recursive: rename locals 'o' and 'a' to 'obuf' and 'abuf' merge-recursive: rename diff_filespec 'one' to 'o' merge-recursive: rename merge_options argument from 'o' to 'opt' Use 'unsigned short' for mode, like diff_filespec does
2 parents 83232e3 + 8c8e5bd commit 96379f0

19 files changed

+1367
-1025
lines changed

Documentation/config/merge.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,22 @@ merge.renameLimit::
3939
is turned off.
4040

4141
merge.renames::
42-
Whether and how Git detects renames. If set to "false",
43-
rename detection is disabled. If set to "true", basic rename
44-
detection is enabled. Defaults to the value of diff.renames.
42+
Whether Git detects renames. If set to "false", rename detection
43+
is disabled. If set to "true", basic rename detection is enabled.
44+
Defaults to the value of diff.renames.
45+
46+
merge.directoryRenames::
47+
Whether Git detects directory renames, affecting what happens at
48+
merge time to new files added to a directory on one side of
49+
history when that directory was renamed on the other side of
50+
history. If merge.directoryRenames is set to "false", directory
51+
rename detection is disabled, meaning that such new files will be
52+
left behind in the old directory. If set to "true", directory
53+
rename detection is enabled, meaning that such new files will be
54+
moved into the new directory. If set to "conflict", a conflict
55+
will be reported for such paths. If merge.renames is false,
56+
merge.directoryRenames is ignored and treated as false. Defaults
57+
to "conflict".
4558

4659
merge.renormalize::
4760
Tell Git that canonical representation of files in the

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static void parse_treeish_arg(const char **argv,
415415

416416
if (prefix) {
417417
struct object_id tree_oid;
418-
unsigned int mode;
418+
unsigned short mode;
419419
int err;
420420

421421
err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,

blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static void verify_working_tree_path(struct repository *r,
9999
for (parents = work_tree->parents; parents; parents = parents->next) {
100100
const struct object_id *commit_oid = &parents->item->object.oid;
101101
struct object_id blob_oid;
102-
unsigned mode;
102+
unsigned short mode;
103103

104104
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
105105
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)

blame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct blame_origin {
5252
struct blame_entry *suspects;
5353
mmfile_t file;
5454
struct object_id blob_oid;
55-
unsigned mode;
55+
unsigned short mode;
5656
/* guilty gets set when shipping any suspects to the final
5757
* blame list instead of other commits
5858
*/

builtin/rm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int check_local_mod(struct object_id *head, int index_only)
110110
const struct cache_entry *ce;
111111
const char *name = list.entry[i].name;
112112
struct object_id oid;
113-
unsigned mode;
113+
unsigned short mode;
114114
int local_changes = 0;
115115
int staged_changes = 0;
116116

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static struct cache_entry *read_one_ent(const char *which,
597597
struct object_id *ent, const char *path,
598598
int namelen, int stage)
599599
{
600-
unsigned mode;
600+
unsigned short mode;
601601
struct object_id oid;
602602
struct cache_entry *ce;
603603

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ static inline int hex2chr(const char *s)
13331333
#define FALLBACK_DEFAULT_ABBREV 7
13341334

13351335
struct object_context {
1336-
unsigned mode;
1336+
unsigned short mode;
13371337
/*
13381338
* symlink_path is only used by get_tree_entry_follow_symlinks,
13391339
* and only for symlinks that point outside the repository.

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
604604
o_name = NULL;
605605

606606
while (desc.size) {
607-
unsigned mode;
607+
unsigned short mode;
608608
const char *name;
609609
const struct object_id *oid;
610610

line-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
498498

499499
static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
500500
{
501-
unsigned mode;
501+
unsigned short mode;
502502
struct object_id oid;
503503

504504
if (get_tree_entry(&commit->object.oid, spec->path, &oid, &mode))

match-trees.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void match_trees(const struct object_id *hash1,
140140
while (one.size) {
141141
const char *path;
142142
const struct object_id *elem;
143-
unsigned mode;
143+
unsigned short mode;
144144
int score;
145145

146146
elem = tree_entry_extract(&one, &path, &mode);
@@ -196,7 +196,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
196196
rewrite_here = NULL;
197197
while (desc.size) {
198198
const char *name;
199-
unsigned mode;
199+
unsigned short mode;
200200

201201
tree_entry_extract(&desc, &name, &mode);
202202
if (strlen(name) == toplen &&
@@ -285,7 +285,7 @@ void shift_tree(const struct object_id *hash1,
285285

286286
if (add_score < del_score) {
287287
/* We need to pick a subtree of two */
288-
unsigned mode;
288+
unsigned short mode;
289289

290290
if (!*del_prefix)
291291
return;
@@ -313,7 +313,7 @@ void shift_tree_by(const struct object_id *hash1,
313313
const char *shift_prefix)
314314
{
315315
struct object_id sub1, sub2;
316-
unsigned mode1, mode2;
316+
unsigned short mode1, mode2;
317317
unsigned candidate = 0;
318318

319319
/* Can hash2 be a tree at shift_prefix in tree hash1? */

0 commit comments

Comments
 (0)