2017-11-22 15 views
0

파일 상태 정보가있는 사용자 정의 형식의 git 로그를 가져 오려고합니다. 그러나, 개행 위치 지정에 이상한 작은 문제가 발생했습니다.git log에서 누락 된 줄 바꿈 --graph --format = ... 파일 상태와 함께 전환 하시겠습니까?

분명히 --format 또는 --pretty 인수를 사용할 때마다 파일 상태 정보 뒤에 일반적으로 삽입되는 줄 바꿈이 생략됩니다. 이는 다소 파일 상태가 잘못 커밋과 함께 그룹화 보이는 시각적으로

>> git log -3 --graph --name-status --format=%h:%s 
* eee8e08:Second commit With more details in the body. 
| 
| M hello.txt 
* b6146f7:First commit. 
| 
| A hello.txt 
| A world.txt 
* 30cb21f:We start from here. Bla bla bla. 

같은 출력 어려운 읽고 이어집니다.

--graph 옵션이 없어도 형식 시작 부분에 줄 바꿈 (%n)을 추가하면 쉽게 수정할 수 있지만 wth --graph는 훨씬 더 이상한 모양으로 이어지고 커밋 메시지를 멀리 이동시킵니다 그래프의 메모를 나타내는 *.

>> git log -3 --graph --name-status --format=%n%h:%s 
* 
| 1868195:Second commit With more details in the body. 
| 
| M hello.txt 
* 
| 0f03672:First commit. 
| 
| A hello.txt 
| A world.txt 
* 
| 033f27f:We start from here. Bla bla bla. 

누락 개행 모든 파일의 상태를 전환 (예컨대 --name-status, --stat, --numstat)에 영향을 미친다. 형식이없는 참고로

는 자세한 정보 표시 메시지가 더 줄 바꿈 위치를 가지고 메시지 헤더와 더 명확 파일 상태의 그룹화를 makses

>> git log -3 --graph --name-status 
* commit eee8e08d3c892e96228844bcdc6324dc895041af 
| Author: me <[email protected]> 
| Date: Wed Nov 22 16:26:58 2017 +0100 
| 
|  Second commit 
|  With more details in the body. 
| 
| M hello.txt 
| 
* commit b6146f70b3406508f5b1300c8cda6fd954d3eadd 
| Author: me <[email protected]> 
| Date: Wed Nov 22 16:26:58 2017 +0100 
| 
|  First commit. 
| 
| A hello.txt 
| A world.txt 
| 
* commit 30cb21f8aba82b30a2f780165533b477cb4555f9 
| Author: me <[email protected]> 
| Date: Wed Nov 22 16:26:58 2017 +0100 
| 
|  We start from here. 
|  Bla bla bla. 

명령.

파일 상태 정보를 이전 커밋과 분리 한 줄 바꿈없이 사용자 지정 로그 형식으로 가져 오는 방법이 있습니까? 내 생각 tformat을 사용하여 서식 자식에 기본적으로 git log -3 --graph --name-status --pretty='format:%h:%s%n'

:


는 참고로, 출력은 작업을 수행해야하는 스크립트 https://pastebin.com/exLswmeR

답변

2

이 함께 테스트 저장소에 만들어졌습니다. https://git-scm.com/docs/git-log을 참조하십시오. format으로 설정하면 새 행이 정상적으로 추가됩니다.

는 나는 (자식 문서에서) 이것 때문에 tformat로 변경 생각 :

In addition, any unrecognized string that has a % in it is interpreted 
as if it has tformat: in front of it. For example, these two are 
equivalent: 
$ git log -2 --pretty=tformat:%h 4da45bef 
$ git log -2 --pretty=%h 4da45bef