Skip to contentSkip to conversation

What should a user expect from git log -M -- file

DISCUSSION Mike Hommey 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I recently reorganized a project of mine, and the result is that a lot of files moved from the top directory to a sub directory.

Now, I innocently tried to 'git log -M' some of these files in the subdirectories, and well, the history just stops when the file was created. Obviously, if I put both the old and the new location it works, but shouldn't users expect 'git log -M -- file' to try to find the previous path and continue from there ?

Mike

#1 lore raw
Quoted 8 lines · Mike Hommey

I recently reorganized a project of mine, and the result is that a lot of files moved from the top directory to a sub directory.

Now, I innocently tried to 'git log -M' some of these files in the subdirectories, and well, the history just stops when the file was created. Obviously, if I put both the old and the new location it works, but shouldn't users expect 'git log -M -- file' to try to find the previous path and continue from there ?

What you want is not

git log -M -- file

but

  git log --follow file

"git log -M -- file" IIRC first applies path limiting, simplifying history, *then* does rename detection, and finally filters output (unless --full-diff is used).

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#2 lore raw
Quoted 15 lines · Jakub Narebski
Quoted 8 lines · Mike Hommey

I recently reorganized a project of mine, and the result is that a lot of files moved from the top directory to a sub directory.

Now, I innocently tried to 'git log -M' some of these files in the subdirectories, and well, the history just stops when the file was created. Obviously, if I put both the old and the new location it works, but shouldn't users expect 'git log -M -- file' to try to find the previous path and continue from there ?

What you want is not

git log -M -- file

Quoted 7 lines

but

  git log --follow file

"git log -M -- file" IIRC first applies path limiting, simplifying history, *then* does rename detection, and finally filters output (unless --full-diff is used).

That's what I was looking for, thanks. I would suggest to put --follow closer to -M and -C in the documentation, but the way the git-log manual is generated (including diff options) makes that impossible :(

Mike