author | Junio C Hamano <gitster@pobox.com> | |
Fri, 3 Sep 2010 16:43:41 +0000 (09:43 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 3 Sep 2010 16:43:41 +0000 (09:43 -0700) |
* jn/merge-renormalize:
merge-recursive --renormalize
rerere: never renormalize
rerere: migrate to parse-options API
t4200 (rerere): modernize style
ll-merge: let caller decide whether to renormalize
ll-merge: make flag easier to populate
Documentation/technical: document ll_merge
merge-trees: let caller decide whether to renormalize
merge-trees: push choice to renormalize away from low level
t6038 (merge.renormalize): check that it can be turned off
t6038 (merge.renormalize): try checkout -m and cherry-pick
t6038 (merge.renormalize): style nitpicks
Don't expand CRLFs when normalizing text during merge
Try normalizing files to avoid delete/modify conflicts when merging
Avoid conflicts when merging branches with mixed normalization
Conflicts:
builtin/rerere.c
t/t4200-rerere.sh
merge-recursive --renormalize
rerere: never renormalize
rerere: migrate to parse-options API
t4200 (rerere): modernize style
ll-merge: let caller decide whether to renormalize
ll-merge: make flag easier to populate
Documentation/technical: document ll_merge
merge-trees: let caller decide whether to renormalize
merge-trees: push choice to renormalize away from low level
t6038 (merge.renormalize): check that it can be turned off
t6038 (merge.renormalize): try checkout -m and cherry-pick
t6038 (merge.renormalize): style nitpicks
Don't expand CRLFs when normalizing text during merge
Try normalizing files to avoid delete/modify conflicts when merging
Avoid conflicts when merging branches with mixed normalization
Conflicts:
builtin/rerere.c
t/t4200-rerere.sh
1 | 2 | |||
---|---|---|---|---|
Documentation/gitattributes.txt | patch | | diff1 | | diff2 | | blob | history |
builtin/checkout.c | patch | | diff1 | | diff2 | | blob | history |
builtin/merge-recursive.c | patch | | diff1 | | diff2 | | blob | history |
builtin/merge.c | patch | | diff1 | | diff2 | | blob | history |
builtin/rerere.c | patch | | diff1 | | diff2 | | blob | history |
builtin/revert.c | patch | | diff1 | | diff2 | | blob | history |
cache.h | patch | | diff1 | | diff2 | | blob | history |
merge-recursive.c | patch | | diff1 | | diff2 | | blob | history |
merge-recursive.h | patch | | diff1 | | diff2 | | blob | history |
rerere.c | patch | | diff1 | | diff2 | | blob | history |
t/t4200-rerere.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc Documentation/gitattributes.txt
Simple merge
diff --cc builtin/checkout.c
Simple merge
diff --cc builtin/merge-recursive.c
Simple merge
diff --cc builtin/merge.c
Simple merge
diff --cc builtin/rerere.c
index 67793fa2c795777b02c340551a5c4cee152ff68b,295fe75d8f0b12685a4e89a67d40d9627830d05a..642bf35587ed994948d3eeac0a189ae29e39bf11
--- 1/builtin/rerere.c
--- 2/builtin/rerere.c
+++ b/builtin/rerere.c
int cmd_rerere(int argc, const char **argv, const char *prefix)
{
- struct string_list merge_rr = { NULL, 0, 0, 1 };
+ struct string_list merge_rr = STRING_LIST_INIT_DUP;
- int i, fd, flags = 0;
-
- if (2 < argc) {
- if (!strcmp(argv[1], "-h"))
- usage(git_rerere_usage);
- if (!strcmp(argv[1], "--rerere-autoupdate"))
- flags = RERERE_AUTOUPDATE;
- else if (!strcmp(argv[1], "--no-rerere-autoupdate"))
- flags = RERERE_NOAUTOUPDATE;
- if (flags) {
- argc--;
- argv++;
- }
- }
- if (argc < 2)
+ int i, fd, autoupdate = -1, flags = 0;
+
+ struct option options[] = {
+ OPT_SET_INT(0, "rerere-autoupdate", &autoupdate,
+ "register clean resolutions in index", 1),
+ OPT_END(),
+ };
+
+ argc = parse_options(argc, argv, prefix, options, rerere_usage, 0);
+
+ if (autoupdate == 1)
+ flags = RERERE_AUTOUPDATE;
+ if (autoupdate == 0)
+ flags = RERERE_NOAUTOUPDATE;
+
+ if (argc < 1)
return rerere(flags);
- if (!strcmp(argv[1], "forget")) {
- const char **pathspec = get_pathspec(prefix, argv + 2);
+ if (!strcmp(argv[0], "forget")) {
+ const char **pathspec = get_pathspec(prefix, argv + 1);
return rerere_forget(pathspec);
}
if (!has_rerere_resolution(name))
unlink_rr_item(name);
}
- unlink_or_warn(git_path("rr-cache/MERGE_RR"));
+ unlink_or_warn(git_path("MERGE_RR"));
- } else if (!strcmp(argv[1], "gc"))
+ } else if (!strcmp(argv[0], "gc"))
garbage_collect(&merge_rr);
- else if (!strcmp(argv[1], "status"))
+ else if (!strcmp(argv[0], "status"))
for (i = 0; i < merge_rr.nr; i++)
printf("%s\n", merge_rr.items[i].string);
- else if (!strcmp(argv[1], "diff"))
+ else if (!strcmp(argv[0], "diff"))
for (i = 0; i < merge_rr.nr; i++) {
const char *path = merge_rr.items[i].string;
const char *name = (const char *)merge_rr.items[i].util;
diff --cc builtin/revert.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc merge-recursive.c
Simple merge
diff --cc merge-recursive.h
Simple merge
diff --cc rerere.c
Simple merge
diff --cc t/t4200-rerere.sh
index 093b1389116250ada236b5949fab269fd567b643,876f09a6fef39fa2f7ef1ba8bd4898225bd5125a..36255d608a7af7d85f479986e302138401f25a8d
--- 1/t/t4200-rerere.sh
--- 2/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
grep ^=======$ $rr/preimage
'
- test_expect_success 'no postimage or thisimage yet' \
- "test ! -f $rr/postimage -a ! -f $rr/thisimage"
+ test_expect_success 'set up rr-cache' '
+ rm -rf .git/rr-cache &&
+ git config rerere.enabled true &&
+ git reset --hard &&
+ test_must_fail git merge first &&
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
+ rr=.git/rr-cache/$sha1
+ '
- test_expect_success 'preimage has right number of lines' '
+ test_expect_success 'rr-cache looks sane' '
+ # no postimage or thisimage yet
+ ! test -f $rr/postimage &&
+ ! test -f $rr/thisimage &&
+ # preimage has right number of lines
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
+ echo $cnt &&
test $cnt = 13
-
'
- git show first:a1 > a1
-
- cat > expect << EOF
- --- a/a1
- +++ b/a1
- @@ -1,4 +1,4 @@
- -Some Title
- +Some title
- ==========
- Whether 'tis nobler in the mind to suffer
- The slings and arrows of outrageous fortune,
- @@ -8,21 +8,11 @@
- The heart-ache and the thousand natural shocks
- That flesh is heir to, 'tis a consummation
- Devoutly to be wish'd.
- -<<<<<<<
- -Some Title
- -==========
- -To die! To sleep;
- -=======
- Some title
- ==========
- To die, to sleep;
- ->>>>>>>
- To sleep: perchance to dream: ay, there's the rub;
- For in that sleep of death what dreams may come
- When we have shuffled off this mortal coil,
- Must give us pause: there's the respect
- That makes calamity of so long life;
- -<<<<<<<
- -=======
- -* END *
- ->>>>>>>
- EOF
- git rerere diff > out
-
- test_expect_success 'rerere diff' 'test_cmp expect out'
-
- cat > expect << EOF
- a1
- EOF
-
- git rerere status > out
-
- test_expect_success 'rerere status' 'test_cmp expect out'
-
- test_expect_success 'commit succeeds' \
- "git commit -q -a -m 'prefer first over second'"
-
- test_expect_success 'recorded postimage' "test -f $rr/postimage"
-
- oldmtimepost=$(test-chmtime -v -60 $rr/postimage |cut -f 1)
-
- test_expect_success 'another conflicting merge' '
- git checkout -b third master &&
- git show second^:a1 | sed "s/To die: t/To die! T/" > a1 &&
- git commit -q -a -m third &&
- test_must_fail git pull . first
+ test_expect_success 'rerere diff' '
+ git show first:a1 >a1 &&
+ cat >expect <<-\EOF &&
+ --- a/a1
+ +++ b/a1
+ @@ -1,4 +1,4 @@
+ -Some Title
+ +Some title
+ ==========
+ Whether '\''tis nobler in the mind to suffer
+ The slings and arrows of outrageous fortune,
+ @@ -8,21 +8,11 @@
+ The heart-ache and the thousand natural shocks
+ That flesh is heir to, '\''tis a consummation
+ Devoutly to be wish'\''d.
+ -<<<<<<<
+ -Some Title
+ -==========
+ -To die! To sleep;
+ -=======
+ Some title
+ ==========
+ To die, to sleep;
+ ->>>>>>>
+ To sleep: perchance to dream: ay, there'\''s the rub;
+ For in that sleep of death what dreams may come
+ When we have shuffled off this mortal coil,
+ Must give us pause: there'\''s the respect
+ That makes calamity of so long life;
+ -<<<<<<<
+ -=======
+ -* END *
+ ->>>>>>>
+ EOF
+ git rerere diff >out &&
+ test_cmp expect out
'
- git show first:a1 | sed 's/To die: t/To die! T/' > expect
- test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
-
- test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
-
- test_expect_success 'rerere updates postimage timestamp' '
- newmtimepost=$(test-chmtime -v +0 $rr/postimage |cut -f 1) &&
- test $oldmtimepost -lt $newmtimepost
+ test_expect_success 'rerere status' '
+ echo a1 >expect &&
+ git rerere status >out &&
+ test_cmp expect out
'
- rm $rr/postimage
- echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
+ test_expect_success 'first postimage wins' '
+ git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
- test_expect_success 'rerere clear' 'git rerere clear'
+ git commit -q -a -m "prefer first over second" &&
+ test -f $rr/postimage &&
- test_expect_success 'clear removed the directory' "test ! -d $rr"
++ oldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) &&
+
- mkdir $rr
- echo Hello > $rr/preimage
- echo World > $rr/postimage
+ git checkout -b third master &&
+ git show second^:a1 | sed "s/To die: t/To die! T/" >a1 &&
+ git commit -q -a -m third &&
- sha2=4000000000000000000000000000000000000000
- rr2=.git/rr-cache/$sha2
- mkdir $rr2
- echo Hello > $rr2/preimage
+ test_must_fail git pull . first &&
+ # rerere kicked in
+ ! grep "^=======\$" a1 &&
+ test_cmp expect a1
+ '
- almost_15_days_ago=$((60-15*86400))
- just_over_15_days_ago=$((-1-15*86400))
- almost_60_days_ago=$((60-60*86400))
- just_over_60_days_ago=$((-1-60*86400))
++test_expect_success 'rerere updates postimage timestamp' '
++ newmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) &&
++ test $oldmtimepost -lt $newmtimepost
++'
+
- test-chmtime =$just_over_60_days_ago $rr/preimage
- test-chmtime =$almost_60_days_ago $rr/postimage
- test-chmtime =$almost_15_days_ago $rr2/preimage
+ test_expect_success 'rerere clear' '
+ rm $rr/postimage &&
+ echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR &&
+ git rerere clear &&
+ ! test -d $rr
+ '
- test_expect_success 'garbage collection (part1)' 'git rerere gc'
+ test_expect_success 'set up for garbage collection tests' '
+ mkdir -p $rr &&
+ echo Hello >$rr/preimage &&
+ echo World >$rr/postimage &&
- test_expect_success 'young or recently used records still live' \
- "test -f $rr/preimage && test -f $rr2/preimage"
+ sha2=4000000000000000000000000000000000000000 &&
+ rr2=.git/rr-cache/$sha2 &&
+ mkdir $rr2 &&
+ echo Hello >$rr2/preimage &&
- test-chmtime =$just_over_60_days_ago $rr/postimage
- test-chmtime =$just_over_15_days_ago $rr2/preimage
+ almost_15_days_ago=$((60-15*86400)) &&
+ just_over_15_days_ago=$((-1-15*86400)) &&
+ almost_60_days_ago=$((60-60*86400)) &&
+ just_over_60_days_ago=$((-1-60*86400)) &&
- test_expect_success 'garbage collection (part2)' 'git rerere gc'
- test-chmtime =$almost_60_days_ago $rr/preimage &&
++ test-chmtime =$just_over_60_days_ago $rr/preimage &&
++ test-chmtime =$almost_60_days_ago $rr/postimage &&
+ test-chmtime =$almost_15_days_ago $rr2/preimage
+ '
- test_expect_success 'old records rest in peace' \
- "test ! -f $rr/preimage && test ! -f $rr2/preimage"
-test_expect_success 'garbage collection preserves young records' '
++test_expect_success 'gc preserves young or recently used records' '
+ git rerere gc &&
+ test -f $rr/preimage &&
+ test -f $rr2/preimage
+ '
- test_expect_success 'file2 added differently in two branches' '
+ test_expect_success 'old records rest in peace' '
- test-chmtime =$just_over_60_days_ago $rr/preimage &&
++ test-chmtime =$just_over_60_days_ago $rr/postimage &&
+ test-chmtime =$just_over_15_days_ago $rr2/preimage &&
+ git rerere gc &&
+ ! test -f $rr/preimage &&
+ ! test -f $rr2/preimage
+ '
+
+ test_expect_success 'setup: file2 added differently in two branches' '
git reset --hard &&
+
git checkout -b fourth &&
- echo Hallo > file2 &&
+ echo Hallo >file2 &&
git add file2 &&
+ test_tick &&
git commit -m version1 &&
+
git checkout third &&
- echo Bello > file2 &&
+ echo Bello >file2 &&
git add file2 &&
+ test_tick &&
git commit -m version2 &&
+
test_must_fail git merge fourth &&
- echo Cello > file2 &&
+ echo Cello >file2 &&
git add file2 &&
git commit -m resolution
'