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

committing empty diffs

From
Don Zickus <dzickus@gmail.com>
Date
Feb 12, 2007, 19:49 UTC
Message-ID
<68948ca0702121149p4d87ae07jd3aa532a0df79156@mail.gmail.com>

I was toying around with the idea of keeping track of scripts or config files in my home directory. Most of the time my commits would include a change to the file I was tracking. However, there are a couple of cases where I wanted to commit empty diffs. For example, ideas or todos about that particular file that I didn't want to embed in the file itself nor write it in yet another file labeled ideas or todos. I thought it would be easier to just to run a 'git log' on the file and see my whole thought process.

Considering git-commit doesn't allow this (probably for good reason), is it technically safe to do the following sequence of events?

tree=$(git-write-tree) #basically the same tree HEAD points to commit=$(echo $IDEAS | git-commit-tree $tree -p HEAD) git-update-ref HEAD $commit HEAD

I figured all a commit is doing is taking a snapshot of a particular tree at a moment in time. And taking multiple snapshots at that same moment and stringing them together (pointed to by HEAD) wouldn't be a big deal.

Am I going to wind up shooting myself in the foot later or will this work? Light testing didn't show any issues. Thought I would ask the experts. Thanks.

Cheers, Don

Next: Shawn O. Pearce
Message 1 of 5 in “committing empty diffs”
  1. Don ZickusFeb 12, 2007
  2. Shawn O. PearceFeb 12, 2007
  3. Shawn O. PearceFeb 12, 2007
  4. Don ZickusFeb 12, 2007
  5. Linus TorvaldsFeb 12, 2007

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.