Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7a135475d3
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 626c0b5d39
Choose a head ref
  • 10 commits
  • 7 files changed
  • 1 contributor

Commits on Jul 17, 2018

  1. xdiff/xdiff.h: remove unused flags

    These flags were there since the beginning (3443546 (Use a *real*
    built-in diff generator, 2006-03-24), but were never used. Remove them.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    25790be View commit details
    Browse the repository at this point in the history
  2. xdiff/xdiffi.c: remove unneeded function declarations

    There is no need to forward-declare these functions, as they are used
    after their implementation only.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    21c770b View commit details
    Browse the repository at this point in the history
  3. t4015: avoid git as a pipe input

    In t4015 we have a pattern of
    
        git diff [<options, related to color>] |
            grep -v "index" |
            test_decode_color >actual &&
    
    to produce output that we want to test against. This pattern was introduced
    in 86b452e (diff.c: add dimming to moved line detection, 2017-06-30)
    as then the focus on getting the colors right. However the pattern used
    is not best practice as we do care about the exit code of Git. So let's
    not have Git as the upstream of a pipe. Piping the output of grep to
    some function is fine as we assume grep to be un-flawed in our test suite.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    74cfa7b View commit details
    Browse the repository at this point in the history
  4. diff.c: do not pass diff options as keydata to hashmap

    When we initialize the hashmap, we give it a pointer to the
    diff_options, which it then passes along to each call of the
    hashmap_cmp_fn function. There's no need to pass it a second time as
    the "keydata" parameter, and our comparison functions never look at
    keydata.
    
    This was a mistake left over from an earlier round of 2e2d5ac
    (diff.c: color moved lines differently, 2017-06-30), before hashmap
    learned to pass the data pointer for us.
    
    Explanation-by: Jeff King <peff@peff.net>
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    3783aad View commit details
    Browse the repository at this point in the history
  5. diff.c: adjust hash function signature to match hashmap expectation

    This makes the follow up patch easier.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    ee1df66 View commit details
    Browse the repository at this point in the history
  6. diff.c: add a blocks mode for moved code detection

    The new "blocks" mode provides a middle ground between plain and zebra.
    It is as intuitive (few colors) as plain, but still has the requirement
    for a minimum of lines/characters to count a block as moved.
    
    Suggested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     (https://public-inbox.org/git/87o9j0uljo.fsf@evledraar.gmail.com/)
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    51da15e View commit details
    Browse the repository at this point in the history
  7. diff.c: decouple white space treatment from move detection algorithm

    In the original implementation of the move detection logic the choice for
    ignoring white space changes is the same for the move detection as it is
    for the regular diff.  Some cases came up where different treatment would
    have been nice.
    
    Allow the user to specify that white space should be ignored differently
    during detection of moved lines than during generation of added and removed
    lines. This is done by providing analogs to the --ignore-space-at-eol,
    -b, and -w options by introducing the option --color-moved-ws=<modes>
    with the modes named "ignore-space-at-eol", "ignore-space-change" and
    "ignore-all-space", which is used only during the move detection phase.
    
    As we change the default, we'll adjust the tests.
    
    For now we do not infer any options to treat white spaces in the move
    detection from the generic white space options given to diff.
    This can be tuned later to reasonable default.
    
    As we plan on adding more white space related options in a later patch,
    that interferes with the current white space options, use a flag field
    and clamp it down to  XDF_WHITESPACE_FLAGS, as that (a) allows to easily
    check at parse time if we give invalid combinations and (b) can reuse
    parts of this patch.
    
    By having the white space treatment in its own option, we'll also
    make it easier for a later patch to have an config option for
    spaces in the move detection.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    b309571 View commit details
    Browse the repository at this point in the history
  8. diff.c: factor advance_or_nullify out of mark_color_as_moved

    This moves the part of code that checks if we're still in a block
    into its own function.  We'll need a different approach on advancing
    the blocks in a later patch, so having it as a separate function will
    prove useful.
    
    While at it rename the variable `p` to `prev` to indicate that it refers
    to the previous line. This is as pmb[i] was assigned in the last iteration
    of the outmost for loop.
    
    Further rename `pnext` to `cur` to indicate that this should match up with
    the current line of the outmost for loop.
    
    Also replace the advancement of pmb[i] to reuse `cur` instead of
    using `p->next` (which is how the name for pnext could be explained.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 17, 2018
    Configuration menu
    Copy the full SHA
    e2fe6ab View commit details
    Browse the repository at this point in the history

Commits on Jul 19, 2018

  1. diff.c: add white space mode to move detection that allows indent cha…

    …nges
    
    The option of --color-moved has proven to be useful as observed on the
    mailing list. However when refactoring sometimes the indentation changes,
    for example when partitioning a functions into smaller helper functions
    the code usually mostly moved around except for a decrease in indentation.
    
    To just review the moved code ignoring the change in indentation, a mode
    to ignore spaces in the move detection as implemented in a previous patch
    would be enough.  However the whole move coloring as motivated in commit
    2e2d5ac (diff.c: color moved lines differently, 2017-06-30), brought
    up the notion of the reviewer being able to trust the move of a "block".
    
    As there are languages such as python, which depend on proper relative
    indentation for the control flow of the program, ignoring any white space
    change in a block would not uphold the promises of 2e2d5ac that allows
    reviewers to pay less attention to the inside of a block, as inside
    the reviewer wants to assume the same program flow.
    
    This new mode of white space ignorance will take this into account and will
    only allow the same white space changes per line in each block. This patch
    even allows only for the same change at the beginning of the lines.
    
    As this is a white space mode, it is made exclusive to other white space
    modes in the move detection.
    
    This patch brings some challenges, related to the detection of blocks.
    We need a wide net to catch the possible moved lines, but then need to
    narrow down to check if the blocks are still intact. Consider this
    example (ignoring block sizes):
    
     - A
     - B
     - C
     +    A
     +    B
     +    C
    
    At the beginning of a block when checking if there is a counterpart
    for A, we have to ignore all space changes. However at the following
    lines we have to check if the indent change stayed the same.
    
    Checking if the indentation change did stay the same, is done by computing
    the indentation change by the difference in line length, and then assume
    the change is only in the beginning of the longer line, the common tail
    is the same. That is why the test contains lines like:
    
     - <TAB> A
     ...
     + A <TAB>
     ...
    
    As the first line starting a block is caught using a compare function that
    ignores white spaces unlike the rest of the block, where the white space
    delta is taken into account for the comparison, we also have to think about
    the following situation:
    
     - A
     - B
     -   A
     -   B
     +    A
     +    B
     +      A
     +      B
    
    When checking if the first A (both in the + and - lines) is a start of
    a block, we have to check all 'A' and record all the white space deltas
    such that we can find the example above to be just one block that is
    indented.
    
    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 19, 2018
    Configuration menu
    Copy the full SHA
    ca1f4ae View commit details
    Browse the repository at this point in the history
  2. diff.c: offer config option to control ws handling in move detection

    Signed-off-by: Stefan Beller <sbeller@google.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    stefanbeller authored and gitster committed Jul 19, 2018
    Configuration menu
    Copy the full SHA
    626c0b5 View commit details
    Browse the repository at this point in the history
Loading