threads / bug / 60281

Git log bug

Subject: Git log bug

## tl;dr

2 messages between Sep 29, 2023 and Sep 29, 2023.

replies: 1people: 2as markdown or json

liangxiong zhu· Sep 29, 2023, 09:35 UTC · lore

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

git clone $repo_url $repo_name cd $repo_name mkdir dir01 mkdir dir02 touch dir01/file01.txt git add . git commit -m 'Add file01.txt' git push

touch dir02/file02.txt git add . git commit -m 'Add file02.txt' git push

git log -1 -- dir01

What did you expect to happen? (Expected behavior) print out commit with message 'Add file01.txt'

What happened instead? (Actual behavior) print out commit with message 'Add file02.txt'

What's different between what you expected and what actually happened?
I would like to get the last commit to a specified directory in the repo, But I get the last commit of the whole repo
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.42.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.15.0-1036-azure #43-Ubuntu SMP Wed Mar 29 16:11:05 UTC 2023 x86_64 compiler info: gnuc: 11.4 libc info: glibc: 2.35 $SHELL (typically, interactive shell): <unset>

[Enabled Hooks]
Junio C Hamano· Sep 29, 2023, 15:12 UTC · re: liangxiong zhu · lore

Re: Git log bug

liangxiong zhu <lxzhu@outlook.com> writes:
Show 21 quoted lines
> git clone $repo_url $repo_name
> cd $repo_name
> mkdir dir01
> mkdir dir02
> touch dir01/file01.txt
> git add .
> git commit -m 'Add file01.txt'
> git push
>
> touch dir02/file02.txt
> git add .
> git commit -m 'Add file02.txt'
> git push
>
> git log -1 -- dir01
>
> What did you expect to happen? (Expected behavior)
> print out commit with message 'Add file01.txt'
>
> What happened instead? (Actual behavior)
> print out commit with message 'Add file02.txt'

Thanks, but it does not reproduce with the above procedure. Following the above (with $repo_name set to "trash" that is not a name of any existing directory in the current directory, and $repo_url set to a local repository that exists but without any history), I got the "Add file01.txt" from the last step.

I got
    No refs in common and none specified; doing nothing.
    Perhaps you should specify a branch.
    fatal: the remote end hung up unexpectedly
    error: failed to push some refs to '/var/tmp/x/./empty.git'

after both of "git push", but becuase "git log" that does not say where to start cares only about HEAD, in the above reproduction precipe "git push" should be irrelevant (i.e., if your copy of Git is broken to exhibit the above reported bug, it should show the same symptom without these steps to run "git push").

If there are some hooks that modifies the history after your "git push", it would be a different story, but otherwise I am not sure how any version of Git would exhibit such a symptom.

Puzzled.

← back to recent threads