Following the git 2.0.0 release two-and-a-half months ago we’re being treated to a new minor version of git, 2.1.0, with a host of exciting new features! The full release notes are available here, but they can be a bit terse if you’re not deeply involved in the git community. This blog is my own commentary on some aspects of the release that got us excited at Atlassian. Better pager defaults The quotes in this article are lifted directly from the release notes, with my own commentary below. Since the very beginning of Git, we gave the LESS environment a default value “FRSX” when we spawn “less” as the pager. “S” (chop long lines instead of wrapping) has been removed from this default set of options, because it is more or less a personal taste thing, as opposed to the others that have good justifications (i.e. “R” is very much justified because many kinds of output we produce are colored and “FX” is justified because output we produce is often shorter than a page). If you haven’t already overridden your git pager defaults, this change means that paged output from git commands will wrap instead of being truncated at the width of your terminal. Here’s an example with git 2.1.0 (wrapped) on the left and 2.0.3 (truncated) on the right: This will likely only affect your log output if you use a narrow terminal or have long unbroken lines in your commit messages. The general git wisdom is to keep commit messages at no more than 72 characters wide, but if the wrapping bothers you you can disable it by restoring the original behavior with: 1$ git config core.pager "less -S" Of course, the pager is used to display other output as well, such as git blame, which can have very long lines depending on author name length and coding style. The 2.1.0 release notes also point out that you can enable the -S flag for just the blame pager with: 1$ git config pager.blame "less -S" If you’re curious about the default less options that git still uses: -F makes less exit if there’s less than a page of output, -R ensures only ANSI color escape sequences are output in raw form (so your git console colors work), and -X prevents the screen from being cleared when less launches (again useful for logs of less than a page in length). Better bash completion The completion script for bash (in contrib/) has been updated to better handle aliases that define a complex sequence of commands. This is super cool! I’m a big fan of custom git aliases. The ability to plug git’s bash completion into my complex aliases makes them that much more powerful and convenient to use from the command line. For example, I have an alias defined that greps out JIRA-style issue keys (e.g. STASH-123) from the log: 1issues = !sh -c 'git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq' - All arguments are passed […]
Comments (0)
Sign in to post comments.