How can I list all modified files by the author between the commit range, but only with the last thing that happened to the file in Git?

Team:

 git log --oneline --name-status 
         --author=$AUTHOR $COMMIT_RANGE | grep -vE '[a-fA-F0-9]{5} ' 
         | sort | uniq | cat -n

Returns a list of files modified by the author between a range of commits with status, for example. Mfor modified.

 1  M   a_file
 2  M   another_file
 3  M   file
 4  D   file

How can I show only the last thing that happened with the file file, for example. was it deleted here ( D)?

I do not want to see previous changes in the file (i.e. M), only the last thing that happened in this commit range.

Thanks for attention!

+4
source share
3 answers

This is the command I ended up with that works for me:

git log --oneline --name-status --author=$AUTHOR $COMMIT_RANGE | \
 grep -vE '[a-fA-F0-9]{5}' | cat -n | sed -e 's/     / /g' | sed -e 's/^  *//g' | \
 sort -k 3,3 -k 1n,1n | uniq -f 2 | sed -e 's/^[0-9]\{1,\} //' | cat -n

$AUTHOR - , $COMMIT_RANGE - OLDER_COMMIT_SHA1..NEWER_COMMIT_SHA1 (HEAD NEWER_COMMIT_SHA1).

:

  • , git log grep -vE, cat -n;
  • TAB git --name-status , cat -n sed -e 's/ / /g' | sed -e 's/^ *//g';
  • , ( ); ( cat -n). , , ,
  • , 2 ( ). uniq , ; "" - , , --name-status, , , , ( "" ..);
  • , uniq .

codeWizard, Arne VonC uniq -f, .

+1

:

git log --oneline 
        --name-status 
        --author=$AUTHOR $COMMIT_RANGE 
        | grep -vE '[a-fA-F0-9]{5} ' | sort -r | uniq -f 1 |  head -1

:

sort -r

,

head -1

uniq -f 1

uniq, , , .

+2

You can configure uniqto look only at a specific field:

git log --oneline --name-status 
         --author=$AUTHOR $COMMIT_RANGE | grep -vE '[a-fA-F0-9]{5} ' 
         | sort -r | uniq -f 1 | tac | cat -n

I used tacto cancel the output again. You can leave it though. It is also a GNU utility that you will not find on BSD / OS X machines.

+2
source

Source: https://habr.com/ru/post/1623221/


All Articles