git-who icon indicating copy to clipboard operation
git-who copied to clipboard

Can't analyse deleted paths

Open L3viathan opened this issue 10 months ago • 2 comments

In a repo of mine, the directory containing most code was moved relatively recently.

When I call git who without params, the top committer has hundreds of commits, but most of these commits happened on the (moved) folder.

$ git who
┌─────────────────────────────────────────────────────┐
│Author                            Last Edit   Commits│
├─────────────────────────────────────────────────────┤
│[REDACTED]                        1 month ago     676│
│[REDACTED]                        2 mon. ago       78│
│[REDACTED]                        4 yr. ago         5│
...
$ git who src
┌─────────────────────────────────────────────────────┐
│Author                            Last Edit   Commits│
├─────────────────────────────────────────────────────┤
│[REDACTED]                        1 month ago      16│
│[REDACTED]                        6 mon. ago        1│
└─────────────────────────────────────────────────────┘
$ git who previousname  # now at "src/previousname"
Git subprocess exited with code 128. Error output:
fatal: ambiguous argument 'previousname': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
$ git who *
┌─────────────────────────────────────────────────────┐
│Author                            Last Edit   Commits│
├─────────────────────────────────────────────────────┤
│[REDACTED]                        1 month ago     385│
│[REDACTED]                        2 mon. ago       51│
│[REDACTED]                        4 yr. ago         3│
...

L3viathan avatar Mar 19 '25 09:03 L3viathan

I'm not sure what you're asking exactly. Are you trying to run git who on previousname, to get a sense for how many commits were made by each author to that old directory?

You should be able to do this by running git who -- previousname. Just like with git log, if the path isn't present in the working tree, you need to add the --.

Let me know if that works!

sinclairtarget avatar Mar 20 '25 21:03 sinclairtarget

Yeah, that doesn't work.

git log -- previousname shows me all commits made involving that path, git who -- previousname has the same error output as git who previousname.


Steps to reproduce:

$ git init
$ git commit -m 'commit 1' --allow-empty
$ echo test >foo
$ git add foo && git commit -am 'commit 2'
$ git who  # shows 2 commits
$ git mv foo bar && git commit -m 'commit 3'
$ git who  # shows 3 commits
$ git who bar  # shows only 1 commit
$ git who foo  # errors

L3viathan avatar Mar 20 '25 21:03 L3viathan

Hmm, thanks for spotting this. I think I had this working at one point but maybe since broke it.

I definitely intended that this should work, so stay tuned for a fix.

sinclairtarget avatar Mar 23 '25 11:03 sinclairtarget

Okay this is fixed in v0.7. Feel free to re-open if you still encounter trouble

sinclairtarget avatar Mar 29 '25 01:03 sinclairtarget