svn diff 또는 git diff에서 at 기호가있는 "@@… @@"메타 라인은 무엇을 의미합니까?
내가 사용할 때 svn diff
또는 git diff
다음과 같은 줄이 표시됩니다.
@@ -1,5 +1,9 @@
무슨 뜻입니까?
이를 (c) hunk 헤더라고하며 범위 정보를 포함합니다.
그들은 이중 표지판에 둘러싸여 @@
있습니다. 형식은 다음과 같습니다.
@@ -l,s +l,s @@
여기서는 l
시작 줄 번호이고 s
변경 (c) hunk가 각 파일에 적용되는 줄 수입니다. 는 -
원본 파일을 나타내고는 +
새로운 (수정) 파일을 나타냅니다. 영향을받은 줄뿐만 아니라 컨텍스트 줄도 표시합니다.
이 -1,5
원본 파일에 있습니다 (로 -
표시됨). 첫 번째 줄이 시작이고 5 개의 영향을받는 / 컨텍스트 줄임을 보여줍니다.
(가) +1,9
제 (의해 새로운 지시 (수정) 파일에 +
) 다시 첫번째 라인은 처음 9 영향 / 컨텍스트 라인이다.
자세한 내용은 여기 : http://en.wikipedia.org/wiki/Diff#Unified_format
간단한 예제 분석
형식은 기본적으로 diff -u
통합 diff 와 동일합니다 .
예를 들면 :
diff -u <(seq 16) <(seq 16 | grep -Ev '^(2|3|14|15)$')
여기에서 2, 3, 14 및 15 행을 제거했습니다. 출력 :
@@ -1,6 +1,4 @@
1
-2
-3
4
5
6
@@ -11,6 +9,4 @@
11
12
13
-14
-15
16
@@ -1,6 +1,4 @@
방법:
-1,6
첫 번째 파일의이 부분이 1 행에서 시작하여 총 6 행을 표시 함을 의미합니다. 따라서 1 ~ 6 행을 표시합니다.1 2 3 4 5 6
-
"오래된"을 의미하며 일반적으로diff -u old new
.+1,4
두 번째 파일의이 부분은 1 행에서 시작하여 총 4 행을 표시 함을 의미합니다. 따라서 1 ~ 4 행을 표시합니다.+
"새로운"을 의미합니다.2 개 라인이 제거 되었기 때문에 6 개 대신 4 개 라인 만 있습니다! 새로운 덩어리는 다음과 같습니다.
1 4 5 6
@@ -11,6 +9,4 @@
for the second hunk is analogous:
on the old file, we have 6 lines, starting at line 11 of the old file:
11 12 13 14 15 16
on the new file, we have 4 lines, starting at line 9 of the new file:
11 12 13 16
Note that line
11
is the 9th line of the new file because we have already removed 2 lines on the previous hunk: 2 and 3.
Hunk header
Depending on your git version and configuration, you can also get a code line next to the @@
line, e.g. the func1() {
in:
@@ -4,7 +4,6 @@ func1() {
This can also be obtained with the -p
flag of plain diff
.
Example: old file:
func1() {
1;
2;
3;
4;
5;
6;
7;
8;
9;
}
If we remove line 6
, the diff shows:
@@ -4,7 +4,6 @@ func1() {
3;
4;
5;
- 6;
7;
8;
9;
Note that this is not the correct line for func1
: it skipped lines 1
and 2
.
This awesome feature often tells exactly to which function or class each hunk belongs, which is very useful to interpret the diff.
How the algorithm to choose the header works exactly is discussed at: Where does the excerpt in the git diff hunk header come from?
These describe the lines affected by the diff hunk. In your case, it means the hunk affects 5 lines starting from line 1, resulting in a replacement starting at line 1 which is 9 lines long.
Note that this is the format used by the unified diff format. The "classical" diff format uses a different model (but who uses classical diff these days?).
'Nice programing' 카테고리의 다른 글
스프링 자체 주입 (0) | 2020.12.12 |
---|---|
R : 2 개의 다른 패키지에 같은 이름을 가진 2 개의 기능 (0) | 2020.12.12 |
MemoryCache를 사용하여 비용이 많이 드는 건물 작업을 처리하는 방법은 무엇입니까? (0) | 2020.12.12 |
R에서 플로팅 목적으로 POSIXct에서 시간 및 초 추출 (0) | 2020.12.12 |
두 폴더를 자동으로 동기화하는 방법은 무엇입니까? (0) | 2020.12.12 |