Re: `git diff`/`git apply` can generate/apply ambiguous hunks (ie. in the wrong place) (just like gnu diff/patch)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >I consider that I don't know enough to understand how `git diff`/`git apply` works
> >internally (and similarly, gnu `diff`/`patch`) to actually change them and make them
> >generate unambiguous hunks where only the hunks that would've been ambiguous
> >have increased context size, instead of the whole patch have increased context size
> >for all hunks(which is what I did for `diffy` too so far, in that proof of concept patch),
> >therefore if a "fix" is deemed necessary(it may not be, as I might've missed
> >something and I'm unaware of it, so a fix may be messing other things up, who
> >knows?!) then I hope someone much more knowledgeable could implement
> >it(maybe even for gnu diff/patch too), and while I don't think that a "please" would
> >be enough, I'm still gonna say it: please do so, if so inclined.
> >
> >Thank you for your time and consideration.
>
> You make good points, but Rust code should not be put into the main git code base as it will break many non-GNU platforms. Perhaps rewriting it is C to be compatible with the git code-base.
> --Randall
>
Ah, definitely whoever writes the fix would do it in C for the git
code base, I didn't mean to imply it would be or should be done in
rust, therefore please excuse my failure to communicate that clearly.
The `diffy` proof-of-concept patch, is just for `diffy`, in rust, and
it's just to show a way this could be done and that "it works" that
way. It was easier for me to do it for `diffy` in rust, than in C for
git diff/apply or gnu diff/patch.
If a fix is to be implemented for `git diff/apply`, it would
definitely not be in rust by any means, but C, as you mentioned.
Thank you for your reply.

Also, I notice that I made a mistake when pasting the patch with the
context length of 4, it was a real patch not the one I used in the
examples, here's the corrected unambiguous patch:
```diff
--- original
+++ modified
@@ -1114,8 +1114,12 @@
                     self.config.shell().warn(msg)?
                 }
             }
         }
+        if seen_any_warnings {
+            //comment
+            bail!("reasons");
+        }
         Ok(())
     }

     pub fn set_target_dir(&mut self, target_dir: Filesystem) {
```

Cheers, have a great day everyone!




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux