xref: /aosp_15_r20/development/tools/mergetool/split3.awk (revision 90c8c64db3049935a07c6143d7fd006e26f8ecca)
1#!/usr/bin/awk -f
2
3# Supports only "simple" diff3 style conflicts. Criss-cross conflicts are not supported.
4
5BEGIN {
6  if (TARGET !~ /^(LOCAL|BASE|REMOTE)$/) {
7    print "Usage: ./split3.awk <file_with_diff3_conflict_markers -v TARGET={LOCAL,BASE,REMOTE}"
8    exit 1
9  }
10
11  PRINT = 1
12}
13
14/^<{7}( .+)?$/ {
15  PRINT = (TARGET == "LOCAL")
16  next
17}
18
19/^\|{7}( .+)?$/ {
20  PRINT = (TARGET == "BASE")
21  next
22}
23
24/^={7}( .+)?$/ {
25  PRINT = (TARGET == "REMOTE")
26  next
27}
28
29/^>{7}( .+)?$/ {
30  PRINT = 1
31  next
32}
33
34PRINT { print }
35