Git, diffs, and patches

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Git, diffs, and patches
Date: 2021-01-15 18:39:49
Message-ID: 20210115183949.GB8740@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I learned a few things when working on the key management patch that I
want to share here in case it helps anyone:

* git diff effectively creates a squashed diff of all commits/changes
* git format-patch wants to retain each commit (no squash)
* git format-patch has information about file name changes
(add/rename/remove) that git diff does not

* git apply and git am cannot process context diffs, only unified diffs
* git apply only applies changes to the files and therefore cannot
record file name changes in git, e.g., git add
* git am applies and merges changes, including file name changes

* to create a squashed format-patch, you have to create a new branch
and merge --squash your changed branch into that, then use git
format-patch
* to create a squashed git format-patch on top of a lower branch
you have to make a copy of the lower branch, merge --squash on the
upper branch on top of that, and then use git format-patch comparing
the lower branch to the upper one

Maybe everyone else knew these things, but I didn't. I can provide more
details if desired.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

The usefulness of a cup is in its emptiness, Bruce Lee

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2021-01-15 18:43:25 Re: fdatasync(2) on macOS
Previous Message Tom Lane 2021-01-15 17:55:52 Re: fdatasync(2) on macOS