Skip to content
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

Make git rebase -r's label generation more resilient #327

Closed
wants to merge 2 commits into from

Commits on Nov 17, 2019

  1. rebase-merges: move labels' whitespace mangling into label_oid()

    One of the trickier aspects of the design of `git rebase
    --rebase-merges` is the way labels are generated for the initial todo
    list: those labels are supposed to be intuitive and first and foremost
    unique.
    
    To that end, `label_oid()` appends a unique suffix when necessary.
    
    Those labels not only need to be unique, but they also need to be valid
    refs. To make sure of that, `make_script_with_merges()` replaces
    whitespace by dashes.
    
    That would appear to be the wrong layer for that sanitizing step,
    though: all callers of `label_oid()` should get that same benefit.
    
    Even if it does not make a difference currently (the only called of
    `label_oid()` that passes a label that might need to be sanitized _is_
    `make_script_with_merges()`), let's move the responsibility for
    sanitizing labels into the `label_oid()` function.
    
    This commit is best viewed with `-w` because it unfortunately needs to
    change the indentation of a large block of code in `label_oid()`.
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    dscho committed Nov 17, 2019
    Configuration menu
    Copy the full SHA
    3f4d086 View commit details
    Browse the repository at this point in the history
  2. rebase -r: let label generate safer labels

    The `label` todo command in interactive rebases creates temporary refs
    in the `refs/rewritten/` namespace. These refs are stored as loose refs,
    i.e. as files in `.git/refs/rewritten/`, therefore they have to conform
    with file name limitations on the current filesystem in addition to the
    accepted ref format.
    
    This poses a problem in particular on NTFS/FAT, where e.g. the colon,
    double-quote and pipe characters are disallowed as part of a file name.
    
    Let's safeguard against this by replacing not only white-space
    characters by dashes, but all non-alpha-numeric ones.
    
    However, we exempt non-ASCII UTF-8 characters from that, as it should be
    quite possible to reflect branch names such as `↯↯↯` in refs/file names.
    
    Signed-off-by: Matthew Rogers <mattr94@gmail.com>
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    ROGERSM94 authored and dscho committed Nov 17, 2019
    Configuration menu
    Copy the full SHA
    adc22c8 View commit details
    Browse the repository at this point in the history