2014-09-25 4 views
0

레거시 코드베이스에 적용 할 패치가 있습니다. pom.xml이라는 파일이 많이 있는데 그 중 일부는 건너 뜁니다. 패치에서 제거하려면 어떻게합니까?unfied diff에서 특정 파일 제거

sed '/^diff --git .*pom.xml$/,/^diff --git/d' 

은 끝에 추가로 한 줄을 제거합니다 (이후 처리를 위해 추가로 필요함).

첫 번째 패턴을 포함하여 두 패턴 사이의 줄을 삭제하고 두 번째 패턴을 제외하는 해결책이 필요할 수 있습니다. 나는 MSYS로 제한되어 있으므로 Windows 명령 인 sed와 mawk 만 액세스 할 수 있습니다.

다음은 입력 예입니다. 거기에 세 개의 항목이 있으며 두 번째 항목은 제거됩니다.

diff --git a/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF b/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF 
index a02c3f0..b74197f 100644 
--- a/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF 
+++ b/core/contexts/org.eclipse.rcptt.ctx.debug/META-INF/MANIFEST.MF 
@@ -2,13 +2,13 @@ Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name: Q7 Debug 
Bundle-SymbolicName: org.eclipse.rcptt.ctx.debug;singleton:=true 
-Bundle-Version: 1.5.0.qualifier 
+Bundle-Version: 1.5.3.qualifier 
Bundle-ClassPath: . 
Bundle-Vendor: Eclipse RCP Testing Tool Project 
Bundle-Localization: plugin 
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 
Require-Bundle: org.eclipse.core.runtime, 
- org.eclipse.rcptt.core;bundle-version="[1.5.0,1.6.0)";visibility:=reexport 
+ org.eclipse.rcptt.core;bundle-version="[1.5.3,1.6.0)";visibility:=reexport 
Bundle-ActivationPolicy: lazy 
Export-Package: org.eclipse.rcptt.debug, 
    org.eclipse.rcptt.debug.impl, 
diff --git a/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml b/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml 
index e12f814..e18b46a 100644 
--- a/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml 
+++ b/core/contexts/org.eclipse.rcptt.ctx.debug/pom.xml 
@@ -4,10 +4,10 @@ 
    <parent> 
    <artifactId>rcptt.core.contexts</artifactId> 
    <groupId>org.eclipse.rcptt</groupId> 
- <version>1.5.0-SNAPSHOT</version> 
+ <version>1.5.3-SNAPSHOT</version> 
    </parent> 
    <groupId>org.eclipse.rcptt</groupId> 
    <artifactId>org.eclipse.rcptt.ctx.debug</artifactId> 
- <version>1.5.0-SNAPSHOT</version> 
+ <version>1.5.3-SNAPSHOT</version> 
    <packaging>eclipse-plugin</packaging> 
</project> 
diff --git a/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF b/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF 
index 88ccb8b..b8c1308 100644 
--- a/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF 
+++ b/core/contexts/org.eclipse.rcptt.ctx.extensions/META-INF/MANIFEST.MF 
@@ -2,7 +2,7 @@ Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name: Q7 Context Extensions 
Bundle-SymbolicName: org.eclipse.rcptt.ctx.extensions;singleton:=true 
-Bundle-Version: 1.5.0.qualifier 
+Bundle-Version: 1.5.3.qualifier 
Bundle-Activator: org.eclipse.rcptt.ctx.extensions.ContextExtensionsPlugin 
Bundle-Vendor: Eclipse RCP Testing Tool Project 
Require-Bundle: org.eclipse.core.runtime, 

내가 지금까지 발견 한 모든 해결책은 패턴이 있거나 시작선과 끝나는 줄을 모두 없애지 않습니다.

+0

테스트 [잠재적 솔루션] (http://www.unix.com/shell-programming-and-scripting/89484-delete-lines-between-two-pattern-without-deleting-second-pattern.html)' sed '/ FROM_HERE /,/TO_HERE/{// p; d;}'' – Basilevs

답변

1

마지막으로, 작업 솔루션 :

awk ' 
    /^diff --git/ {skip = 0} 
    /^diff --git .*pom.xml$/ { skip = 1} 
    {if (!skip) print $0} 
' 

이 아마 A의 나오지 작업이 아니었다.