From: NeilBrown Date: Wed, 13 Feb 2013 23:22:18 +0000 (+1100) Subject: merge: remove useless context at the start of a conflict. X-Git-Tag: v1.0~64 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=9c8b9a1a1407eb6893dab5cd001fe2bfca3d0d12;p=wiggle.git merge: remove useless context at the start of a conflict. There are two fixes here. The first allows the newline at the end of an unchanged region to be the 'first' newline found so that if there are several others to provide backup, it will be used. The second allows the start-of-file to be strong enough context to not require three full lines of explicit context. Then we change a lot of the self-tests to match. In each case the result is a clear improvement. Signed-off-by: NeilBrown --- diff --git a/merge2.c b/merge2.c index 92f5c22..b2cc4cf 100644 --- a/merge2.c +++ b/merge2.c @@ -190,7 +190,7 @@ int isolate_conflicts(struct file af, struct file bf, struct file cf, */ for (k = m[j].al; k > 0; k--) if (ends_line(af.list[m[j].a+k-1])) { - if (firstk >= m[j].al) + if (firstk > m[j].al) firstk = k; newlines++; if (newlines >= 3) { @@ -200,6 +200,8 @@ int isolate_conflicts(struct file af, struct file bf, struct file cf, } if (k > 0) m[j].hi = k; + else if (j == 0) + m[j].hi = firstk; else if (is_cutpoint(m[j], af,bf,cf)) m[j].hi = 0; else diff --git a/tests/linux/inode-justrej/lmerge b/tests/linux/inode-justrej/lmerge index 08b0a9b..685b14e 100644 --- a/tests/linux/inode-justrej/lmerge +++ b/tests/linux/inode-justrej/lmerge @@ -952,14 +952,12 @@ void remove_inode_hash(struct inode *inode) void generic_delete_inode(struct inode *inode) { struct super_operations *op = inode->i_sb->s_op; -<<<<<<< +<<<<<<< hlist_del_init(&inode->i_hash); ||||||| - list_del_init(&inode->i_hash); ======= - >>>>>>> list_del_init(&inode->i_list); inode->i_state|=I_FREEING; diff --git a/tests/linux/md-loop/merge b/tests/linux/md-loop/merge index ebb59ea..682ed20 100644 --- a/tests/linux/md-loop/merge +++ b/tests/linux/md-loop/merge @@ -3950,13 +3950,11 @@ MD_EXPORT_SYMBOL(md_update_sb); MD_EXPORT_SYMBOL(md_wakeup_thread); MD_EXPORT_SYMBOL(md_print_devices); MD_EXPORT_SYMBOL(find_rdev_nr); -<<<<<<< MD_EXPORT_SYMBOL(md_interrupt_thread); +<<<<<<< MD_EXPORT_SYMBOL(mddev_map); ||||||| -MD_EXPORT_SYMBOL(md_interrupt_thread); EXPORT_SYMBOL(mddev_map); ======= -MD_EXPORT_SYMBOL(md_interrupt_thread); >>>>>>> MODULE_LICENSE("GPL"); diff --git a/tests/linux/raid1-A/merge b/tests/linux/raid1-A/merge index 86abd0b..8361ac4 100644 --- a/tests/linux/raid1-A/merge +++ b/tests/linux/raid1-A/merge @@ -710,14 +710,12 @@ static int make_request(mddev_t *mddev, struct bio * bio) struct bio *read_bio; int i, targets = 0, disks; struct bitmap *bitmap; -<<<<<<< unsigned long flags; +<<<<<<< ||||||| - unsigned long flags; struct bio_list bl; struct page **behind_pages = NULL; ======= - unsigned long flags; struct bio_list bl; int bl_count; struct page **behind_pages = NULL; @@ -1951,8 +1949,8 @@ static conf_t *setup_conf(mddev_t *mddev) spin_lock_init(&conf->resync_lock); init_waitqueue_head(&conf->wait_barrier); -<<<<<<< bio_list_init(&conf->pending_bio_list); +<<<<<<< conf->last_used = -1; for (i = 0; i < conf->raid_disks; i++) { @@ -2320,12 +2318,10 @@ MODULE_ALIAS("md-level-1"); module_param(max_queued, int, S_IRUGO|S_IWUSR); ||||||| - bio_list_init(&conf->pending_bio_list); bio_list_init(&conf->flushing_bio_list); ======= - bio_list_init(&conf->pending_bio_list); conf->pending_count = 0; bio_list_init(&conf->flushing_bio_list); diff --git a/tests/simple/conflict/merge b/tests/simple/conflict/merge index 8bbd487..fb97f49 100644 --- a/tests/simple/conflict/merge +++ b/tests/simple/conflict/merge @@ -1,16 +1,12 @@ -<<<<<<< this is a file with the word +<<<<<<< two which is misspelt ||||||| -this is a file -with the word to which is misspelt ======= -this is a file -with the word too which is misspelt >>>>>>> diff --git a/tests/simple/conflictmixed/lmerge b/tests/simple/conflictmixed/lmerge index 6d7071e..bb4d03c 100644 --- a/tests/simple/conflictmixed/lmerge +++ b/tests/simple/conflictmixed/lmerge @@ -1,14 +1,10 @@ -<<<<<<< this is a file with the word +<<<<<<< two which is ||||||| -this is a file -with the word to which is ======= -this is a file -with the word too which was >>>>>>> misspelt diff --git a/tests/simple/conflictmixed/merge b/tests/simple/conflictmixed/merge index bb38d8a..5af8ed0 100644 --- a/tests/simple/conflictmixed/merge +++ b/tests/simple/conflictmixed/merge @@ -1,16 +1,12 @@ -<<<<<<< this is a file with the word +<<<<<<< two which is misspelt ||||||| -this is a file -with the word to which is misspelt ======= -this is a file -with the word too which was misspelt >>>>>>> diff --git a/tests/simple/multiple-add/lmerge b/tests/simple/multiple-add/lmerge index 5827de2..f2a4151 100644 --- a/tests/simple/multiple-add/lmerge +++ b/tests/simple/multiple-add/lmerge @@ -4,14 +4,12 @@ the current version of -<<<<<<< the +<<<<<<< file. ||||||| -the file ======= -the file that has changed >>>>>>> diff --git a/tests/simple/show-wiggle-1/Wmerge b/tests/simple/show-wiggle-1/Wmerge index d5cba67..805a091 100644 --- a/tests/simple/show-wiggle-1/Wmerge +++ b/tests/simple/show-wiggle-1/Wmerge @@ -1,17 +1,14 @@ -<<<<<<< +<<<<<<< This is one line of the file ||||||| - This is 1 line of the file ======= - This is 1 line of the document &&&&&&& - This is one line of the document >>>>>>>