Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Konstantin Khomoutov
On Fri, 30 Oct 2015 10:59:49 -0700 (PDT)
Ivan Švaljek  wrote:

> Yes I would like to get the diff state in a C# program of mine, Git
> is one candidate if it's the easiest way to get such a state.
> Git is also a candidate because it has some merge functionality if
> I'm not wrong.

Well, you can leverage git for diffing, and it supports several diffing
algorythms of various properties (and respective sets of tradeoffs) but
you should be aware of certain things:

* Git's tools related to diffing and merging only work on objects
  contained in a Git repository.
  That is, to use these algos on arbitrary data you'd need to either
  shovel such data to a Git repo or extract those algos from the Git
  source code and re-write them in C#.

* Your notion of "destructiveness" is *very* specific to your particular
  task.  Sure, no generic tool such as Git does not implement anything
  even remotely resembling what you are after.  Git is only smart about
  fuzzy matching and ignoring whitespace changes (when told to do so).
  Sure it knows nothing about CSS or any other textual data format.

Hence my personal opinion on this is that you will hardly be able to
leverage existing *generic* tools except for actually using them to
detect the changed lines of text; after that, you'd need to use your
custom logic to classify those changes.  But that really is not that
simple: take CSS for instance -- it's not a line-wise but rather a
block-wise format with the complicated set of rules of how a block or a
declaration in it applies to the DOM.  So IMO to *semantically* diff CSS
files you actually should have code which parses both complete versions
to abstract syntax trees and then compares them, not files.

And if you still think that a poor man's line-wise approach would be
"good enough", that's okay, and I think that there should exist
pure-.NET libraries implementing diffing algorythms for textual data.
So why not just use these assemblies instead of depending on a
hard-to-package external tool like Git?

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Ivan Švaljek
Yes I would like to get the diff state in a C# program of mine, Git is one 
candidate if it's the easiest way to get such a state.
Git is also a candidate because it has some merge functionality if I'm not 
wrong.

Dana petak, 30. listopada 2015. u 14:44:49 UTC+1, korisnik Konstantin 
Khomoutov napisao je:
>
> On Fri, 30 Oct 2015 05:06:00 -0700 (PDT) 
> Ivan Švaljek > wrote: 
>
> > >> Is it possible to automate an C# app using git, so I get a flag 
> > >> whether the changes in the new file version are destructive or 
> > >> non-destructive? Bonus question: is there a functionality in git 
> > >> to then merge those two file versions if the changes were non 
> > >> destructive (line addition in css or a comment in php)? 
> [...] 
> > > First things first: what do you think destrictive? Removing "rm -rf 
> > > \*" from a shell script doesn’t seem destructive to me, for example… 
> > By destructive I mean any code overwrite or deletation, by 
> > non-destructive I mean anything added to the source file that doesn't 
> > overwrite or delete old version's content. 
> > 
> > Destructive 
> > .banner_wrap {display:block;} -> .banner_wrap {display:inline-block;} 
> > 
> > Non-destructive 
> > .banner_wrap {display:block;} -> .banner_wrap {display:block; 
> > border:1px solid #eee; } 
>
> So what did you mean by referring to a C# program in your original 
> message?  Did you mean writing a program which would call out to Git, 
> ask it for the list of changes between two files and decide whether 
> they are "destructive" or not? 
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Konstantin Khomoutov
On Fri, 30 Oct 2015 05:06:00 -0700 (PDT)
Ivan Švaljek  wrote:

> >> Is it possible to automate an C# app using git, so I get a flag
> >> whether the changes in the new file version are destructive or
> >> non-destructive? Bonus question: is there a functionality in git
> >> to then merge those two file versions if the changes were non
> >> destructive (line addition in css or a comment in php)?
[...]
> > First things first: what do you think destrictive? Removing "rm -rf
> > \*" from a shell script doesn’t seem destructive to me, for example…
> By destructive I mean any code overwrite or deletation, by
> non-destructive I mean anything added to the source file that doesn't
> overwrite or delete old version's content.
> 
> Destructive
> .banner_wrap {display:block;} -> .banner_wrap {display:inline-block;}
> 
> Non-destructive
> .banner_wrap {display:block;} -> .banner_wrap {display:block;
> border:1px solid #eee; }

So what did you mean by referring to a C# program in your original
message?  Did you mean writing a program which would call out to Git,
ask it for the list of changes between two files and decide whether
they are "destructive" or not?

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Gergely Polonkai
>From Git’s perspective, both are “destructive”. You will see that the old
line is deleted and a new one is added. Also, if you simply check if
something was added to the code, your destructive example becomes
non-destructive, as the new version only adds “inline-” in the middle of
the line.

What you need here is a semantic scanner, which you can run from within a
Git hook. The former doesn’t really belong to this group, while the latter
is explained at [1] and [2].

Best,
Gergely

[1] https://git-scm.com/docs/githooks
[2] https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

2015-10-30 13:06 GMT+01:00 Ivan Švaljek :

> By destructive I mean any code overwrite or deletation, by non-destructive
> I mean anything added to the source file that doesn't overwrite or delete
> old version's content.
>
> Destructive
> .banner_wrap {display:block;} -> .banner_wrap {display:inline-block;}
>
> Non-destructive
> .banner_wrap {display:block;} -> .banner_wrap {display:block; border:1px
> solid #eee; }
>
>
> Dana petak, 30. listopada 2015. u 12:17:04 UTC+1, korisnik Gergely
> Polonkai napisao je:
>>
>> First things first: what do you think destrictive? Removing "rm -rf \*"
>> from a shell script doesn’t seem destructive to me, for example…
>>
>> 2015-10-29 20:58 GMT+01:00 Ivan Švaljek :
>>
>>> Is it possible to automate an C# app using git, so I get a flag whether
>>> the changes in the new file version are destructive or non-destructive?
>>> Bonus question: is there a functionality in git to then merge those two
>>> file versions if the changes were non destructive (line addition in css or
>>> a comment in php)?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Git for human beings" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to git-users+...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Ivan Švaljek
By destructive I mean any code overwrite or deletation, by non-destructive 
I mean anything added to the source file that doesn't overwrite or delete 
old version's content.

Destructive
.banner_wrap {display:block;} -> .banner_wrap {display:inline-block;}

Non-destructive
.banner_wrap {display:block;} -> .banner_wrap {display:block; border:1px 
solid #eee; }


Dana petak, 30. listopada 2015. u 12:17:04 UTC+1, korisnik Gergely Polonkai 
napisao je:
>
> First things first: what do you think destrictive? Removing "rm -rf \*" 
> from a shell script doesn’t seem destructive to me, for example…
>
> 2015-10-29 20:58 GMT+01:00 Ivan Švaljek 
> >:
>
>> Is it possible to automate an C# app using git, so I get a flag whether 
>> the changes in the new file version are destructive or non-destructive?
>> Bonus question: is there a functionality in git to then merge those two 
>> file versions if the changes were non destructive (line addition in css or 
>> a comment in php)?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Git for human beings" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to git-users+...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Detect destructive changes betweeen two file versions

2015-10-30 Thread Gergely Polonkai
First things first: what do you think destrictive? Removing "rm -rf \*"
from a shell script doesn’t seem destructive to me, for example…

2015-10-29 20:58 GMT+01:00 Ivan Švaljek :

> Is it possible to automate an C# app using git, so I get a flag whether
> the changes in the new file version are destructive or non-destructive?
> Bonus question: is there a functionality in git to then merge those two
> file versions if the changes were non destructive (line addition in css or
> a comment in php)?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.