@matheusbsbs / matheus-bagliano / commits / d9671b75ad
Fork 0

rerere: add clear, diff, and status commands

git-am and git-rebase will be updated to use 'clear', and diff/status can be used to aid the user in tracking progress in the resolution process. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Dec 8, 2006 at 13:29 UTC d9671b75ad3bbf2f95f11a8571e9beaa12ccf6dd
2 files changed +57 -2
Documentation/git-rerere.txt
+25 -2
@@ -7,8 +7,7 @@ git-rerere - Reuse recorded resolve
7
8 SYNOPSIS
9 --------
10 -'git-rerere'
11 -
10 +'git-rerere' [clear|diff|status]
11
12 DESCRIPTION
13 -----------
@@ -167,6 +166,30 @@ would conflict the same way the test merge you resolved earlier.
166 `git-rerere` is run by `git rebase` to help you resolve this
167 conflict.
168
169 +COMMANDS
170 +--------
171 +
172 +Normally, git-rerere is run without arguments or user-intervention.
173 +However, it has several commands that allow it to interact with
174 +its working state.
175 +
176 +'clear'::
177 +
178 +This resets the metadata used by rerere if a merge resolution is to be
179 +is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
180 +[--skip|--abort] will automatcally invoke this command.
181 +
182 +'diff'::
183 +
184 +This displays diffs for the current state of the resolution. It is
185 +useful for tracking what has changed while the user is resolving
186 +conflicts. Additional arguments are passed directly to the system
187 +diff(1) command installed in PATH.
188 +
189 +'status'::
190 +
191 +Like diff, but this only prints the filenames that will be tracked
192 +for resolutions.
193
194 Author
195 ------
git-rerere.perl
+32
@@ -172,6 +172,38 @@ sub merge {
172 -d "$rr_dir" || exit(0);
173
174 read_rr();
175 +
176 +if (@ARGV) {
177 + my $arg = shift @ARGV;
178 + if ($arg eq 'clear') {
179 + for my $path (keys %merge_rr) {
180 + my $name = $merge_rr{$path};
181 + if (-d "$rr_dir/$name" &&
182 + ! -f "$rr_dir/$name/postimage") {
183 + rmtree(["$rr_dir/$name"]);
184 + }
185 + }
186 + unlink $merge_rr;
187 + }
188 + elsif ($arg eq 'status') {
189 + for my $path (keys %merge_rr) {
190 + print $path, "\n";
191 + }
192 + }
193 + elsif ($arg eq 'diff') {
194 + for my $path (keys %merge_rr) {
195 + my $name = $merge_rr{$path};
196 + system('diff', ((@ARGV == 0) ? ('-u') : @ARGV),
197 + '-L', "a/$path", '-L', "b/$path",
198 + "$rr_dir/$name/preimage", $path);
199 + }
200 + }
201 + else {
202 + die "$0 unknown command: $arg\n";
203 + }
204 + exit 0;
205 +}
206 +
207 my %conflict = map { $_ => 1 } find_conflict();
208
209 # MERGE_RR records paths with conflicts immediately after merge