3

I want to find out which files changed in what tag. So I use git whatchanged but this prints me the commit IDs. I want to print the commits in a format like in git describe (which takes the last tag and adds the number of additional commits.

The commands

git whatchanged --pretty=%d *
git whatchanged --pretty=%gd *

are both not working (no output of the commit info at all).

EDIT:

I am using the command on a list of files (by using the *), i.e. what happens if the tagging took place after that commit. Aim is to find out the software version which contains the commit

Alex
  • 32,506
  • 16
  • 106
  • 171

2 Answers2

2

Based on VonC's answer I ended up in using

FILEPATH=/the/path/I/want/to/Observe
git log --name-only --oneline --tags --pretty="%d"|egrep "$FILEPATH|^ \("

Explanation:

git log shows the changes of the full repository including the tags. Then I grep for the files I am interested in. Additionally I grep for ␣( at the beginning of a line to get the tag names which look for example like ␣(1.1.0)

Alex
  • 32,506
  • 16
  • 106
  • 171
1

You are not supposed to use whatchanged from quite some time now: see "Difference between git-log and git-whatchanged?".

Instead, use git log:

git log -p --no-walk --tags --pretty="%H %d" --decorate=full

That works correctly since git 1.8.5.4 (see "show all tags in git log")

With the -p option, it display the diffs.

Other options are available for displaying files:

 git log --name-only --oneline --tags --pretty="%d" | grep -v "^$" | more

(See more at "How to show changed file name only with git log?")

For instance, on the git repo itself:

C:\Users\VonC\prog\git\git>
git log --name-only --oneline --tags --pretty="%d"|grep -v "^$"|more

 (tag: v2.0.0-rc0)
Documentation/RelNotes/2.0.0.txt
GIT-VERSION-GEN
Documentation/RelNotes/2.0.0.txt
config.c
contrib/completion/git-prompt.sh
contrib/remote-helpers/test-bzr.sh
t/t5560-http-backend-noserver.sh
t/t7001-mv.sh
contrib/completion/git-completion.bash
contrib/completion/git-completion.zsh
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/test-bzr.sh
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-hg-bidi.sh
contrib/remote-helpers/test-hg-hg-git.sh

 (tag: v1.9.2, upstream/maint)
Documentation/RelNotes/1.9.2.txt
Documentation/git.txt
GIT-VERSION-GEN
Documentation/git-http-backend.txt
utf8.c
Documentation/RelNotes/2.0.0.txt
Documentation/RelNotes/1.9.2.txt
git-p4.py
contrib/hooks/multimail/CHANGES
contrib/hooks/multimail/README
contrib/hooks/multimail/README.Git
contrib/hooks/multimail/git_multimail.py
contrib/hooks/multimail/post-receive
builtin/pack-objects.c
....
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250