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

[PATCH 0/1] git-p4: add format-patch subcommand

From
Luke Diamand <luke@diamand.org>
Date
Feb 26, 2018, 11:48 UTC
Message-ID
<20180226114822.1617-1-luke@diamand.org>

This is an initial attempt to add a "format-patch" command to git-p4, following on from the earlier discussion about shelving.

It uses the "p4 describe" command to generate the diff content and post-processes it enough to generate git-style patches. These can be fed to tools such as patch, or "git am".

This is useful for "unshelving" a P4 changelist into your git tree, since the usual git subcommands (sync, clone) cannot easily read a shelved changelist: there is no good way to get from Perforce a consistent single revision against which to generate a diff using git fast-import, since Perforce doesn't have the concept of a repo revision.

By default, it leaves the depot prefix in the patch, but using the option "--strip-depot-prefix" makes it suitable for "git am".

Use it like this:
 $ git p4 format-patch 12345 >out.patch
or
 $ mkdir patches
 $ git p4 format-patch --output patches 12345 12346
or
 $ git p4 format-patch --strip-depot-prefix 12347 >out.patch
 $ git am out.patch

Limitations of "p4 describe" mean that this will not work reliably with binary files. There's no easy way around this. The change makes a small attempt to at least stop on binary files, but in the case of a file marked in P4 as "text", which contains binary deltas, the file will unavoidably come out corrupted.

Luke Diamand (1):
  git-p4: add format-patch subcommand
 Documentation/git-p4.txt |  33 +++++
 git-p4.py                | 304 +++++++++++++++++++++++++++++++++++++++++++++--
 t/t9832-make-patch.sh    | 135 +++++++++++++++++++++
 3 files changed, 462 insertions(+), 10 deletions(-)
 create mode 100755 t/t9832-make-patch.sh
-- 
2.15.1.272.gc310869385
Next: Luke Diamand
Message 1 of 5 in “git-p4: add format-patch subcommand”
  1. 0/1 git-p4: add format-patch subcommandLuke Diamand, Feb 26, 2018
  2. 1/1 git-p4: add format-patch subcommandLuke Diamand, Feb 26, 2018
  3. Miguel TorrojaFeb 26, 2018
  4. Eric SunshineFeb 26, 2018
  5. Luke DiamandMar 12, 2018

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.