@matheusbsbs / matheus-bagliano / commits / 80ff47957b
Fork 0

rebase: remember strategy and strategy options

When a rebase is resumed, interactive rebase remembers any merge strategy passed when the rebase was initated. Make non-interactive rebase remember any merge strategy as well. Also make non-interactive rebase remember any merge strategy options. To be able to resume a rebase that was initiated with an older version of git (older than this commit), make sure not to expect the saved option files to exist. Test case idea taken from Junio's 71fc224 (t3402: test "rebase -s<strategy> -X<opt>", 2010-11-11). Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin von Zweigbergk committed Feb 6, 2011 at 13:43 UTC 80ff47957b3a8ae057178a7b1113d171404e938f
3 files changed +35 -2
git-rebase--interactive.sh
-2
@@ -584,7 +584,6 @@ skip_unnecessary_picks () {
584
585 get_saved_options () {
586 test -d "$rewritten" && preserve_merges=t
587 - test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
587 test -f "$state_dir"/rebase-root && rebase_root=t
588 }
589
@@ -713,7 +712,6 @@ case "$rebase_root" in
712 *)
713 : >"$state_dir"/rebase-root ;;
714 esac
716 -test -z "$strategy" || echo "$strategy" > "$state_dir"/strategy
715 if test t = "$preserve_merges"
716 then
717 if test -z "$rebase_root"
git-rebase.sh
+6
@@ -81,6 +81,9 @@ read_basic_state () {
81 fi &&
82 GIT_QUIET=$(cat "$state_dir"/quiet) &&
83 test -f "$state_dir"/verbose && verbose=t
84 + test -f "$state_dir"/strategy && strategy="$(cat "$state_dir"/strategy)"
85 + test -f "$state_dir"/strategy_opts &&
86 + strategy_opts="$(cat "$state_dir"/strategy_opts)"
87 }
88
89 write_basic_state () {
@@ -89,6 +92,9 @@ write_basic_state () {
92 echo "$orig_head" > "$state_dir"/orig-head &&
93 echo "$GIT_QUIET" > "$state_dir"/quiet &&
94 test t = "$verbose" && : > "$state_dir"/verbose
95 + test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
96 + test -n "$strategy_opts" && echo "$strategy_opts" > \
97 + "$state_dir"/strategy_opts
98 }
99
100 output () {
t/t3418-rebase-continue.sh
+29
@@ -45,4 +45,33 @@ test_expect_success 'rebase --continue can not be used with other options' '
45 test_must_fail git rebase --continue -v
46 '
47
48 +test_expect_success 'rebase --continue remembers merge strategy and options' '
49 + rm -fr .git/rebase-* &&
50 + git reset --hard commit-new-file-F2-on-topic-branch &&
51 + test_commit "commit-new-file-F3-on-topic-branch" F3 32 &&
52 + test_when_finished "rm -fr test-bin funny.was.run" &&
53 + mkdir test-bin &&
54 + cat >test-bin/git-merge-funny <<-EOF
55 + #!$SHELL_PATH
56 + case "\$1" in --opt) ;; *) exit 2 ;; esac
57 + shift &&
58 + >funny.was.run &&
59 + exec git merge-recursive "\$@"
60 + EOF
61 + chmod +x test-bin/git-merge-funny &&
62 + (
63 + PATH=./test-bin:$PATH
64 + test_must_fail git rebase -s funny -Xopt master topic
65 + ) &&
66 + test -f funny.was.run &&
67 + rm funny.was.run &&
68 + echo "Resolved" >F2 &&
69 + git add F2 &&
70 + (
71 + PATH=./test-bin:$PATH
72 + git rebase --continue
73 + ) &&
74 + test -f funny.was.run
75 +'
76 +
77 test_done