.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "GIT-AUTOFIXUP 1p" .TH GIT-AUTOFIXUP 1p "2022-01-21" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" App::Git::Autofixup \- create fixup commits for topic branches .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& git\-autofixup [] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIgit-autofixup\fR parses hunks of changes in the working directory out of \f(CW\*(C`git diff\*(C'\fR output and uses \f(CW\*(C`git blame\*(C'\fR to assign those hunks to commits in \f(CW\*(C`..HEAD\*(C'\fR, which will typically represent a topic branch, and then creates fixup commits to be used with \f(CW\*(C`git rebase \-\-interactive \-\-autosquash\*(C'\fR. It is assumed that hunks near changes that were previously committed to the topic branch are related. .PP \&\f(CW\*(C`@{upstream}\*(C'\fR or \f(CW\*(C`@{u}\*(C'\fR is likely a convenient value to use for \f(CW\*(C`\*(C'\fR if the current branch has a tracking branch. See \f(CW\*(C`git help revisions\*(C'\fR for other ways to specify revisions. .PP If any changes have been staged to the index using \f(CW\*(C`git add\*(C'\fR, then \fIgit-autofixup\fR will only consider staged hunks when trying to create fixup commits. A temporary index is used to create any resulting commits. .PP By default a hunk will be included in a fixup commit if all the lines in the hunk's context blamed on topic branch commits refer to the same commit, so there's no ambiguity about which commit the hunk corresponds to. If there is ambiguity the assignment behaviour used under \f(CW\*(C`\-\-strict 1\*(C'\fR will be used to attempt to resolve it. If \f(CW\*(C`\-\-strict 1\*(C'\fR is given the same topic branch commit must be blamed for every removed line and at least one of the lines adjacent to each added line, and added lines must not be adjacent to lines blamed on other topic branch commits. All the same restrictions apply when \f(CW\*(C`\-\-strict 2\*(C'\fR is given, but each added line must be surrounded by lines blamed on the same topic branch commit. .PP For example, the added line in the hunk below is adjacent to lines committed by commits \f(CW\*(C`99f370af\*(C'\fR and \f(CW\*(C`a1eadbe2\*(C'\fR. If these are both topic branch commits then it's ambiguous which commit the added line is fixing up and the hunk will be ignored. .PP .Vb 4 \& COMMIT |LINE|HEAD |WORKING DIRECTORY \& 99f370af| 1|first line | first line \& | | |+added line \& a1eadbe2| 2|second line | second line .Ve .PP But if that second line were instead blamed on an upstream commit (denoted by \f(CW\*(C`^\*(C'\fR), the hunk would be added to a fixup commit for \f(CW\*(C`99f370af\*(C'\fR: .PP .Vb 3 \& 99f370af| 1|first line | first line \& | | |+added line \& ^ | 2|second line | second line .Ve .PP Output similar to this example can be generated by setting verbosity to 2 or greater by using the verbosity option multiple times, eg. \f(CW\*(C`git\-autofixup \-vv\*(C'\fR, and can be helpful in determining how a hunk will be handled. .PP \&\fIgit-autofixup\fR is not to be used mindlessly. Always inspect the created fixup commits to ensure hunks have been assigned correctly, especially when used on a working directory that has been changed with a mix of fixups and new work. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\-h" 4 .IX Item "-h" Show usage. .IP "\-\-help" 4 .IX Item "--help" Show manpage. .IP "\-\-version" 4 .IX Item "--version" Show version. .IP "\-v, \-\-verbose" 4 .IX Item "-v, --verbose" Increase verbosity. Can be used up to two times. .IP "\-c N, \-\-context N" 4 .IX Item "-c N, --context N" Change the number of context lines \f(CW\*(C`git diff\*(C'\fR uses around hunks. Default: 3. This can change how hunks are assigned to fixup commits, especially with \f(CW\*(C`\-\-strict 0\*(C'\fR. .IP "\-s N, \-\-strict N" 4 .IX Item "-s N, --strict N" Set how strict \fIgit-autofixup\fR is about assigning hunks to fixup commits. Default: 0. Strictness levels are described under \s-1DESCRIPTION.\s0 .IP "\-g \s-1ARG,\s0 \-\-gitopt \s-1ARG\s0" 4 .IX Item "-g ARG, --gitopt ARG" Specify option for git. Can be used multiple times. Useful for testing, to override config options that break git-autofixup, or to override global diff options to tweak what git-autofixup considers a hunk. .Sp Note \s-1ARG\s0 won't be wordsplit, so to give multiple arguments, such as for setting a config option like \f(CW\*(C`\-c diff.algorithm\*(C'\fR, this option must be used multiple times: \f(CW\*(C`\-g \-c \-g diff.algorithm=patience\*(C'\fR. .IP "\-e, \-\-exit\-code" 4 .IX Item "-e, --exit-code" Use more detailed exit codes: .RS 4 .IP "0:" 4 .IX Item "0:" All hunks have been assigned. .IP "1:" 4 .IX Item "1:" Only some hunks have been assigned. .IP "2:" 4 .IX Item "2:" No hunks have been assigned. .IP "3:" 4 .IX Item "3:" There was nothing to be assigned. .IP "255:" 4 .IX Item "255:" Unexpected error occurred. .RE .RS 4 .RE .SH "INSTALLATION" .IX Header "INSTALLATION" If cpan is available, run \f(CW\*(C`cpan \-i App::Git::Autofixup\*(C'\fR. Otherwise, copy \fIgit-autofixup\fR to a directory in \f(CW\*(C`PATH\*(C'\fR and ensure it has execute permissions. It can then be invoked as either \f(CW\*(C`git autofixup\*(C'\fR or \f(CW\*(C`git\-autofixup\*(C'\fR, since git searches \f(CW\*(C`PATH\*(C'\fR for appropriately named binaries. .PP Git is distributed with Perl 5 for platforms not expected to already have it installed, but installing modules with cpan requires other tools that might not be available, such as make. This script has no dependencies outside of the standard library, so it is hoped that it works on any platform that Git does without much trouble. .PP Requires a git supporting \f(CW\*(C`commit \-\-fixup\*(C'\fR: 1.7.4 or later. .SH "BUGS/LIMITATIONS" .IX Header "BUGS/LIMITATIONS" If a topic branch adds some lines in one commit and subsequently removes some of them in another, a hunk in the working directory that re-adds those lines will be assigned to fixup the first commit, and during rebasing they'll be removed again by the later commit. .PP Not tested in \fIcmd.exe\fR on Windows. Run it from Git Bash, Cygwin, or a similar Unix emulation environment. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" \&\fIgit-autofixup\fR was inspired by a description of hg absorb in the Mercurial Sprint Notes . While I was working on it I found git-superfixup , by oktal3700, which was helpful to examine. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2017, Jordan Torbiak. .PP This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.