diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-02-26 11:51:52 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-02-26 11:51:52 +0000 |
commit | f585763060076fdd5104409554613b9ca110f910 (patch) | |
tree | a5efde1dda2ad6004d987edbf7f7208173f605f5 /baserock-system-config-sync | |
parent | bcfb17b890e74538655695c4f76962b16565f664 (diff) | |
parent | 087ad206db4ef25eff2c21c3d6e06194f0e217ee (diff) | |
download | tbdiff-f585763060076fdd5104409554613b9ca110f910.tar.gz |
Merge branch 'baserock/pedroalvarez/bscs-wrong-merge2'
Reviewed-by: Richard Maw
Diffstat (limited to 'baserock-system-config-sync')
-rwxr-xr-x | baserock-system-config-sync/baserock-system-config-sync | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/baserock-system-config-sync/baserock-system-config-sync b/baserock-system-config-sync/baserock-system-config-sync index a093b15..e297197 100755 --- a/baserock-system-config-sync/baserock-system-config-sync +++ b/baserock-system-config-sync/baserock-system-config-sync @@ -134,6 +134,7 @@ merge_regular_file() { v1_exists=$(test -f "$v1" && echo exists || echo none) vu_exists=$(test -f "$vu" && echo exists || echo none) v2_exists=$(test -f "$v2" && echo exists || echo none) + case "$v1_exists $vu_exists $v2_exists" in 'exists none none') cp -a "$v1" "$vt" @@ -152,16 +153,24 @@ merge_regular_file() { ;; 'none exists exists') cp -a "$v2" "$vt" - if ! (diff -u "$v2" --label="$v2" "$vu" --label="$vu" | patch "$vt" -t); then - cp -a "$v2" "$vt" # merge failed, use v2 - # 'patch' creates a file '.rej' with the diff that did not apply + + # If v2 == vu, then use v2 + if ! cmp -s "$v2" "$vu"; then + if ! (diff -u "$v2" --label="$v2" "$vu" --label="$vu" | patch "$vt" -f); then + cp -a "$v2" "$vt" # merge failed, use v2 + # 'patch' creates a file '.rej' with the diff that did not apply + fi fi ;; 'exists exists exists') cp -a "$v2" "$vt" - if ! (diff -u "$v1" --label="$v1" "$vu" --label="$vu" | patch "$vt" -t); then - cp -a "$v2" "$vt" # merge failed, use v2 - # 'patch' creates a file '.rej' with the diff that did not apply + + # If v2 == vu, then use v2 + if ! cmp -s "$v2" "$vu"; then + if ! (diff -u "$v1" --label="$v1" "$vu" --label="$vu" | patch "$vt" -f); then + cp -a "$v2" "$vt" # merge failed, use v2 + # 'patch' creates a file '.rej' with the diff that did not apply + fi fi ;; *) |