git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Misusing git: trimming old commits

From
Martin Langhoff <martin.langhoff@gmail.com>
Date
May 9, 2013, 15:40 UTC
Message-ID
<CACPiFC+XKVzNk2fm4beer0xD6yBnVW6QXCrSFm2w8T2r68xGvg@mail.gmail.com>

I am misusing git as a store-and-forward tool to transfer reports to a server in a resilient manner.

The context is puppet (and ppg, I've spammed the list about it... ). The reports are small, with small deltas, but created frequently.

With the exaction of the final destination, I want to expire reports that are old and successfully transferred.

My current approach is (bash-y pseudocode):
  git push bla bla || exit $?
  prunehash=$(git log -n1 --until=one.month.ago --pretty=format:%H)
  test -z "$prunehash" && exit 0
  # prep empty commit
  # skip git read-tree --empty, we get the same with
  export GIT_INDEX_FILE=/does/not/exist
  empty_tree="$(git write-tree)"
  unset GIT_INDEX_FILE
  empty_commit="$(git commit-tree -m empty "$empty_tree")"
  echo "${prunehash} ${empty_commit}" >> .git/info/grafts
  git gc
  # TODO: cleanup stale grafts :-)
is this a reasonable approach?
m
--
 martin.langhoff@gmail.com
 -  ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 ~ http://docs.moodle.org/en/User:Martin_Langhoff
Next: Martin Langhoff
Message 1 of 2 in “Misusing git: trimming old commits”
  1. Martin LanghoffMay 9, 2013
  2. Martin LanghoffMay 11, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.