Possible bug regarding trailers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am able to produce a commit with a trailer which does not show up in:
    `git log --format="%(trailers:key=old-scm-change-id,valueonly,separator=%x2c) %H %T" HEAD`
But does show up in:
    `git cat-file commit HEAD | git interpret-trailers --parse`

The following script reproduces the issue.  It deletes directory /tmp/foo (from previous runs if you want to change something and run it again) then creates a new git directory in /tmp/foo and operates within there.
The comments at the bottom of the script were from run of the script.  You'll see the "WE WILL SEE THIS TRAILER" but you will not see the "THIS TRAILER GETS LOST" even though they both show up on an explicit call to `git interpret-trailers --parse`

I'm looking for a reliable way to store some meta-data from an old SCM system as we migrate to Git.
I'd prefer to utilize Git's native trailers and not have to resort to using a (foreign to Git) sqlite database or something.

Thanks,
~Eric


#!/bin/bash

rm -rf /tmp/foo
mkdir /tmp/foo
cd /tmp/foo
git init
git config user.email a@xxxxx
git config user.name "example"
git config commit.gpgSign false

echo "CHANGE" >> README.md
git add .
git commit -m "A bad commit

--- let's mess stuff up ---

Have fun
" --trailer "old-scm-change-id:THIS TRAILER GETS LOST"

echo "CHANGE" >> README.md
git add .
git commit -m "A good commit

*** no problem here ***

Have fun
" --trailer "old-scm-change-id:WE WILL SEE THIS TRAILER"

echo "******************** git log ********************"
git log

echo "******************** git cat-file commit HEAD^ ********************"
git cat-file commit HEAD^

echo "******************** git cat-file commit HEAD ********************"
git cat-file commit HEAD

echo "*****"
echo "*****"
echo "*****"
echo "*****"
echo "*****"

echo -e "\n\n***** git cat-file commit HEAD^ | git interpret-trailers --parse *****"
git cat-file commit HEAD^ | git interpret-trailers --parse

echo -e "\n\n***** git cat-file commit HEAD | git interpret-trailers --parse *****"
git cat-file commit HEAD | git interpret-trailers --parse

echo -e "\n\n******************** git log w/ trailers in format ********************"
git log --format="%(trailers:key=old-scm-change-id,valueonly,separator=%x2c) %H %T" HEAD

echo -e "\n\n******************** git version ********************"
git version


# OUTPUT:


# Initialized empty Git repository in /tmp/foo/.git/
# [main (root-commit) 62d1150] A bad commit
#  1 file changed, 1 insertion(+)
#  create mode 100644 README.md
# [main 0deff83] A good commit
#  1 file changed, 1 insertion(+)
# ******************** git log ********************
# commit 0deff83a2955ab5bb8aef24eca77e5399feabacc
# Author: example <a@xxxxx>
# Date:   Thu Jun 15 13:39:37 2023 -0400
# 
#     A good commit
#     
#     *** no problem here ***
#     
#     Have fun
#     
#     old-scm-change-id: WE WILL SEE THIS TRAILER
# 
# commit 62d11500db250440c190ebe60945789e13fb0bbf
# Author: example <a@xxxxx>
# Date:   Thu Jun 15 13:39:37 2023 -0400
# 
#     A bad commit
#     
#     old-scm-change-id: THIS TRAILER GETS LOST
#     
#     --- let's mess stuff up ---
#     
#     Have fun
# ******************** git cat-file commit HEAD^ ********************
# tree 1dd017bdd070190005e5e162d87afebcd61e0fa8
# author example <a@xxxxx> 1686850777 -0400
# committer example <a@xxxxx> 1686850777 -0400
# 
# A bad commit
# 
# old-scm-change-id: THIS TRAILER GETS LOST
# 
# --- let's mess stuff up ---
# 
# Have fun
# ******************** git cat-file commit HEAD ********************
# tree cd83b4c038415891bff254e2954113df2f78aa62
# parent 62d11500db250440c190ebe60945789e13fb0bbf
# author example <a@xxxxx> 1686850777 -0400
# committer example <a@xxxxx> 1686850777 -0400
# 
# A good commit
# 
# *** no problem here ***
# 
# Have fun
# 
# old-scm-change-id: WE WILL SEE THIS TRAILER
# *****
# *****
# *****
# *****
# *****
# 
# 
# ***** git cat-file commit HEAD^ | git interpret-trailers --parse *****
# old-scm-change-id: THIS TRAILER GETS LOST
# 
# 
# ***** git cat-file commit HEAD | git interpret-trailers --parse *****
# old-scm-change-id: WE WILL SEE THIS TRAILER
# 
# 
# ******************** git log w/ trailers in format ********************
# WE WILL SEE THIS TRAILER 0deff83a2955ab5bb8aef24eca77e5399feabacc cd83b4c038415891bff254e2954113df2f78aa62
#  62d11500db250440c190ebe60945789e13fb0bbf 1dd017bdd070190005e5e162d87afebcd61e0fa8
# 
# 
# ******************** git version ********************
# git version 2.41.0.187.g15d354cc3d




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux