0

I am trying to print the commit date in 2021April09 format using --date=format:'%Y%b%d' but it gives me segmentation fault. Neither of below works for me even for standard formats.

git log --pretty=format:%cd --date=format:%Y%m%d -5

git log --pretty=format:%cd --date=format:'%Y-%m-%d' -5

I know I can use git log --pretty=format:%cd --date=short to get the shorter version but I want to use strftime format to print the abbreviated month etc

Garry S
  • 79
  • 9
  • 1
    Segmentation faults are usually due to a corrupt program or memory. I don't see how a `git log` can cause a segmentation fault just by formatting a date. Unless there's something in the repo that's causing the fault. Do other `git` commands work? – Kim Hallberg Apr 09 '21 at 22:06
  • 1
    What git version are you using? All commands in your post work for me. – KamilCuk Apr 09 '21 at 22:10
  • May it be that you have to put the format in quotation marks? This answer could also help you: https://stackoverflow.com/a/34778736/3535187 – Jakob Liskow Apr 09 '21 at 22:13
  • Does `date +'%Y %b %d'` work ? – LeGEC Apr 09 '21 at 22:35
  • Yes, Other Git commands work. I am using Git version 2.26. – Garry S Apr 09 '21 at 22:55
  • @LeGEC - How would I use that (date + ) syntax ? Can you give an example based on what I am trying ? thanks – Garry S Apr 09 '21 at 22:56
  • 1
    On what OS are you running this command? And on what type of terminal are you running this from? – Gino Mempin Apr 10 '21 at 02:51
  • I meant : from bash cli, without using git, check if the standard "date" utility behaves correctly – LeGEC Apr 10 '21 at 15:37
  • btw : "Neither of below works for me" do you mean they also trigger a segmentation fault ? – LeGEC Apr 10 '21 at 15:39

2 Answers2

0
git log --pretty='%cd' --date=format:'%Y/%m/%d' 

try with this

Kaumadie Kariyawasam
  • 1,232
  • 3
  • 17
  • 35
0

git log --pretty=format:%cd --date=format:%Y%m%d -5

git log --pretty=format:%cd --date=format:'%Y-%m-%d' -5

Both of the above works fine from a CMake based command invocation but won't work for me from Git BASH on windows (MINGW32). I also tried updating Git the latest 2.31.x.

I keep getting segmentation fault. I have moved on to something else but will be looking at this thread to see if anyone else has any suggestion. Thanks

Garry S
  • 79
  • 9