← Back to context

Comment by esafak

4 days ago

I can't make sense of that link. How many parts was the diff split up into, and along what lines?

Yeah, I don't know why I linked that as an example. Wanted to show structure of a patch. Each commit of a patch already has everything ready to be processed and chunked IF you keep them - small, atomic, semantically meaningful. As in do smaller commits.

  • > > Some make a semantic diff splitter please! Break up big commits into small, atomic, meaningful ones.

    > Each commit of a patch already has everything ready to be processed and chunked IF you keep them - small, atomic, semantically meaningful. As in do smaller commits.

    Reads like:

    User1: I need help with my colleagues who do not make independent, small, semantically intact commits

    User2: well, have you tried making smaller, more independent, semantically intact commits?

    ---

    My interpretation of the wish is to convert this, where they have intermixed two semantically independent changes in one diff:

        +++ a/alpha.py
        --- b/alpha.py
    
         def doit():
        -    awesome = 3.14
        +    awesome = 4.56
    
        -    print("my dog is fluffy")
        +    print("my cat is fluffy")
    

    into this

        +++ a/alpha.py
        --- b/alpha.py
    
         def doit():
        -    awesome = 3.14
        +    awesome = 4.56
    
             print("my dog is fluffy")
    
        +++ a/alpha.py
        --- b/alpha.py
    
         def doit():
             awesome = 3.14
    
        -    print("my dog is fluffy")
        +    print("my cat is fluffy")
    

    where each one could be cherry-picked at will because they don't semantically collide

    The semantics part would be knowing that this one could not be split in that manner, because the cherry-pick would change more than just a few lines, it would change the behavior

        +++ a/alpha.py
        --- b/alpha.py
    
         def doit():
        -    the_weight = 3.14
        +    the_weight = 4.56
    
        -    print("my dog weighs %f", the_weight)
        +    print("my cat weighs %f", the_weight)
    

    I'm sure these are very contrived examples, but it's the smallest one I could whip up offhand