Commit Briefs

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@


dbc68eedb1 Omar Polo

got patch: ignore blobs not found

since diffs are often enclosed in other formats (e.g. emails) we might parse something and think it's a blob id when it's not. This should already happens, but apply_patch is looking for the wrong error due to a leftover from previous attempts. Reported by stsp@ while here tweak the test_patch_merge_unknown_blob to also try with a dummy commit id, as now got-read-patch requires it in order to consider a blob id. ok stsp@


d8b5af438b Omar Polo

use the commitid in the patch diff3 conflict header

suggested by and ok stsp@


55e9459f41 Omar Polo

got patch: use diff3 to merge the changes

Parse the "blob -" metadata in diffs produced by 'got diff' and use the original file for patching. Then, use the diff3 with the current version of the file to merge the differences. This solves many failures automagically or at least turns them into a conflict. ok/improvements stsp@


a19f439c4e Omar Polo

don't pass $ret to test_done on failure when it's known to be zero

Otherwise the test directory it's not left in place; ok tracey@


be33dff7fa Omar Polo

got patch: fail when reading empty hunks


4379a9aae9 Omar Polo

got patch: handle git-style rename diffs

extend the support for git-style diffs to include the "pure rename" case, i.e. when a file is renamed without any edits. ok stsp@


bad961bf76 Omar Polo

got patch: allow to reverse a patch

add a flag to got_patch to reverse a patch before applying and the -R flag for `got patch'. ok stsp@


15e1bda6b8 Omar Polo

test `got patch' vs path-prefixes, relative paths and strip

reminded by and 'looks fine' to stsp@


f1d6cebb43 Omar Polo

typos


ed3bff8307 Omar Polo

got patch: resolve paths from the current working directory

this allow to apply patches from subdirectories of the work tree root. Prodded by naddy@, ok stsp@.


3313bcd840 Omar Polo

delete trailing whitespaces


9d6cabd512 Omar Polo

got patch: allow to strip path components

Move some bits from the libexec helper to the main process so we know if the patch was generated by git or not and finally document the automatic stripping of a/ and b/ prefixes added by git-diff(1). ok stsp@


b3c57ab2fb Omar Polo

got patch: handle "\ No newline at end of file"


7a30b5cb05 Omar Polo

got patch: prefer new name if not /dev/null and not a git-style diff

This fixes a common issue when for e.g. generating patches with $ diff -u foo.orig foo where 'got patch' failed because 'foo.orig' has an 'unexpected status'. prodded by naddy, ok stsp


78f5ac2436 Omar Polo

move got_patch file status checking in worktree.c

check_file_status used got_worktree_status to check if the file was in an allowed state, but it's wrong since the callback is not invoked on unchanged files. While here also fix a relate bug: unlink(newpath) is in the wrong spot and ends up removing files even when it shouldn't, so move it early in the got_worktree_schedule_* error handling. Finally, update the appropriate test case. It was passing before because got_worktree_schedule_add returned GOT_ERR_FILE_STATUS, not because check_file_status failed. ok stsp@