Commit Briefs

684a9a6c24 Omar Polo

got patch: handle the removal of binary files

Diffs that remove binary files don't have hunks so got patch would skip over them, treating that part of the diff as "noise". Different programs outputs a slightly different diff for this kind of patches, but the "Binary files ... and /dev/null differ" is usually shown, so try to match it. The adedd regress test covers got diff, git diff, and OpenBSD' /usr/bin/diff. CVS diffs will currently fail because the guessed file name will be wrong. CVS prints the file name in the Index and RCS lines which got patch currently ignores, and shows an useless path in the "Binary files /tmp/cvs... and /dev/null differ" line. Discussed with and ok stsp@


5f94a4e005 Omar Polo

regress: consistently use ed -s

didn't know about -s when writing those tests; saves some output redirection. ok jamsek


b2b3fce13e Omar Polo

respect umask when creating or changing files and directories

This behaviour is already documented in got-worktree(5) but wasn't actually implemented. ok stsp@


9cda65e55e Stefan Sperling

simplify the way 'got patch' opens a tempfile when reading from stdin

Also add basic test coverage for reading patches from stdin, while here. ok op@


611e5fc207 Mark Jamsek

ensure got patch respects x-bit perms for new files

Reported by stsp on IRC: got patch failed to set the x-bit for a new file despite got diff recording mode 755. Parse got and git diffs for this data and set file modes accordingly. Tweaked with hint from op. ok stsp@


57b1c3f23f Omar Polo

patch regress: unify some tests


5f56d41e1a Omar Polo

got patch: add -c flag to apply at a specified commit

it's useful for e.g. to apply old patches that weren't generated by `got diff' or git-diff(1) and so lacks the metadata needed for the 3-way merge. manpage improvements from and ok stsp@


38d61ead4d Omar Polo

fix `got patch -R' when using diff3 merge

`got patch -R' fails spectacularly when applied on a diff that contains the info of the original blob for the diff3 merge machinery since it tries to apply the reverse of the patch to the old blob. change it to run the patch (_not_ reversed) on the old blob and then swap the arguments to got_diff3_merge which gives us the correct reverse merge of the diff. while here add a test case too. reported by naddy, discussed with and ok stsp@


a92a20426c Omar Polo

got patch: handle mangled whitespaces

This makes 'got patch' try to ignore whitespaces when trying to match a hunk. Discused with and ok stsp@


5dffb1a14a Omar Polo

got patch: don't loose the x bit when merging with diff3

This fixes a regression introduced with the diff3 merge: files merged this way have their permissions resetted after patch. The issue is due the fact that patch_file looks at a temporary files and not at the original "old file". Reported by and ok stsp@


f5b0315f0e Omar Polo

aesthetic: rename regress to test_patch_rm_file

drop the "simple" part, there's no "complex" way of removing files.


ed2ff8b9f9 Omar Polo

augment test_patch_add_line

Try to create a file with more than one line, it would have catched an issue with my wip diff for ignore whitespaces in got patch. While here rename the function to drop "simple".


acf749fc60 Omar Polo

refactor the patch parser

Introduce a patch_start routine that finds the next "diff" header (if there is one); the idea is to persist some state (commit id and wether it's a "git diff") while processing the content of the diff. It's needed because in the case of 'got diff' some information like the commit id are only present once at the beginning. As a consequence, the patch parser becomes slightly more robust (concatenating diffs produced by different means shouldn't confuse it anymore) and drops the support for "old" got diffs, the ones previous the introduction of the "commit -/+" header. ok tracey@


db0dfdd7e5 Omar Polo

got patch: handle git-style diffs for the 3-way merge too

tweak and ok stsp@


9802c41ca7 Omar Polo

got patch: use status G for merged files (and document it)

Suggested by stsp@. This makes possible to tell if 'got patch' used a merge-base from the repository for the 3-way merge or did a simple search/replace operation. While here update the tests to look for the 'G' status and the manpage, which was also missing the documentation for the 'C' status in got patch. ok stsp@