-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix mergetool p4merge #174
Conversation
Nice Pull Request!
Yes, it is.
This one is more tricky: Also, the Or is this the issue where working directory files differ in line ending convention from the files in the repository? In that case, I imagine that we would want |
Thanks for your comments. I wasn't aware of the Coding Guidelines. Indeed --strip-trailing-cr seems to be supported by less implementations than the unified format (-u), e. g. OpenBSD seems to ship with a version of diff that supports -u, but not the stripping of CR. To give a background of this issue: I'm not fond of any kind of sed scripts to get rid of the trailing CRs. Also I wonder if it makes sense to ditch the |
My preference would have been
I actually had looked into that already myself because I wanted to get rid of the dependency on the diff(1) utility (because of the incompatibilities you pointed out). The only problem is that Git's diff command does not understand the Let's see, what would it take to implement that Okay, I think I have a good plan to implement the As for the implementation: the parsing needs to be done in https://github.com/git/git/blob/v2.4.3/diff-no-index.c#L254 I guess. As the If I were to implement the const char *labels[2] = { NULL, NULL };
int label_counter = 0; and then parse (using Then the @calle2010 How about it, want to give it a shot? |
Hmm, my last encounter with C was 17 years back. At least I can try first if git diff really handles this case better. Otherwise it would not make sense to even start this enhancement. |
I verified that |
I tried it a described, but it is not so easy. If noindex_filespec() just overrides the name with the label the diff algorithm still tries to read the file from the label path in diff_fill_sha1_info(). So I think there are potentiality two options now:
ad 2. I tried this at end of noindex_filespec
and it nearly works. But if the two labels are the same then no diff is printed due to the checks in diff_unmodified_pair(). I feel like option 1. is too much for this. Is it really required that create_virtual_base leaves the second file untouched? If not a much easier solution could be implemented there without enhancing git diff at all. |
So I found a solution to the last issue, but there is still some to do:
|
I could't spend much time on this unfortunately. I'd like to know if I'm on the right path. My biggest concern with this change is that the first line of the generated patch contains the label instead of the actual file name. This is different to the behavior in the normal diff command. In order to change this I'd have to enhance Also tests for directory mode have to be added. |
The progress looks good! I have a hunch that it might be a wise course to submit this to the Git mailing list already; there are most likely people with a good idea how to hand down the label to the diff machinery such that it is not automatically prefixed by "a/" or "b/". |
(Unless you are uncomfortable with the mailing list-based work flow, of course...) |
@calle2010 did you get any chance to work on this a bit more? As I am preparing the release, I stumbled over this ticket; It is probably the best to not rush it out the door and take care of it properly after the release. |
No, I haven't had time to continue with this so far. It will probably not be different for the coming three weeks. |
Since commit c536c07 git apply (called in create_virtual_base) doesn't accept path names with leading dots anymore and fails with "invalid path" instead. Signed-off-by: Christian Schaefer <chr.j.schaefer@web.de>
- parse -L label option for git diff --no-index - make use of git diff for create_virtual_base - new test t4059-diff-label.sh - open issues: - test fails since implementation in git is not correct: label and filenames on first line can't be different - test dir mode - first line of created patch contains the label instead of the actual file name
@calle2010 how about now? |
/remind me to close this (unless a princess kisses it awake in the meantime) in two weeks |
The merge tool p4merge fails in certain cases when there is no base version for a 3-way merge. In this case
create_virtual_base
is called to create a base file which contains only the common content of the files to be merged. This base file is presented in p4merge.With this script https://gist.github.com/calle2010/b4910e9b8f0dbbf58fb6 I can replicate the issues in a repository with core.autocrlf=true.
There are two issues:
diff
. This leads to error messages about trailing whitespace in git-apply.Even though the patch resolves the issues I have some doubts about this patch:
create_virtual_base
seems to be used by mergetools/p4merge and git-merge-one-file.sh only. The latter is described as an sample script in the documentation of git-merge-index. So I hope I'm not in the risk of breaking anything very central here.