1GIT-AUTOFIXUP(1)      User Contributed Perl Documentation     GIT-AUTOFIXUP(1)
2
3
4

NAME

6       App::Git::Autofixup - create fixup commits for topic branches
7

SYNOPSIS

9           git-autofixup [<options>] <revision>
10

DESCRIPTION

12       git-autofixup parses hunks of changes in the working directory out of
13       "git diff" output and uses "git blame" to assign those hunks to commits
14       in "<revision>..HEAD", which will typically represent a topic branch,
15       and then creates fixup commits to be used with "git rebase
16       --interactive --autosquash". It is assumed that hunks near changes that
17       were previously committed to the topic branch are related.
18
19       "@{upstream}" or "@{u}" is likely a convenient value to use for
20       "<revision>" if the current branch has a tracking branch. See "git help
21       revisions" for other ways to specify revisions.
22
23       If any changes have been staged to the index using "git add", then git-
24       autofixup will only consider staged hunks when trying to create fixup
25       commits. A temporary index is used to create any resulting commits.
26
27       By default a hunk will be included in a fixup commit if all the lines
28       in the hunk's context blamed on topic branch commits refer to the same
29       commit, so there's no ambiguity about which commit the hunk corresponds
30       to. If there is ambiguity the assignment behaviour used under "--strict
31       1" will be used to attempt to resolve it. If "--strict 1" is given the
32       same topic branch commit must be blamed for every removed line and at
33       least one of the lines adjacent to each added line, and added lines
34       must not be adjacent to lines blamed on other topic branch commits. All
35       the same restrictions apply when "--strict 2" is given, but each added
36       line must be surrounded by lines blamed on the same topic branch
37       commit.
38
39       For example,  the added line in the hunk below is adjacent to lines
40       committed by commits "99f370af" and "a1eadbe2". If these are both topic
41       branch commits then it's ambiguous which commit the added line is
42       fixing up and the hunk will be ignored.
43
44           COMMIT  |LINE|HEAD                          |WORKING DIRECTORY
45           99f370af|   1|first line                    | first line
46                   |    |                              |+added line
47           a1eadbe2|   2|second line                   | second line
48
49       But if that second line were instead blamed on an upstream commit
50       (denoted by "^"), the hunk would be added to a fixup commit for
51       "99f370af":
52
53           99f370af|   1|first line                    | first line
54                   |    |                              |+added line
55           ^       |   2|second line                   | second line
56
57       Output similar to this example can be generated by setting verbosity to
58       2 or greater by using the verbosity option multiple times, eg.
59       "git-autofixup -vv", and can be helpful in determining how a hunk will
60       be handled.
61
62       git-autofixup is not to be used mindlessly. Always inspect the created
63       fixup commits to ensure hunks have been assigned correctly, especially
64       when used on a working directory that has been changed with a mix of
65       fixups and new work.
66

OPTIONS

68       -h  Show usage.
69
70       --help
71           Show manpage.
72
73       --version
74           Show version.
75
76       -v, --verbose
77           Increase verbosity. Can be used up to two times.
78
79       -c N, --context N
80           Change the number of context lines "git diff" uses around hunks.
81           Default: 3. This can change how hunks are assigned to fixup
82           commits, especially with "--strict 0".
83
84       -s N, --strict N
85           Set how strict git-autofixup is about assigning hunks to fixup
86           commits. Default: 0. Strictness levels are described under
87           DESCRIPTION.
88
89       -g ARG, --gitopt ARG
90           Specify option for git. Can be used multiple times. Useful for
91           testing, to override config options that break git-autofixup, or to
92           override global diff options to tweak what git-autofixup considers
93           a hunk.
94
95           Note ARG won't be wordsplit, so to give multiple arguments, such as
96           for setting a config option like "-c diff.algorithm", this option
97           must be used multiple times: "-g -c -g diff.algorithm=patience".
98
99       -e, --exit-code
100           Use more detailed exit codes:
101
102           0:  All hunks have been assigned.
103
104           1:  Only some hunks have been assigned.
105
106           2:  No hunks have been assigned.
107
108           3:  There was nothing to be assigned.
109
110           255:
111               Unexpected error occurred.
112

INSTALLATION

114       If cpan is available, run "cpan -i App::Git::Autofixup". Otherwise,
115       copy git-autofixup to a directory in "PATH" and ensure it has execute
116       permissions. It can then be invoked as either "git autofixup" or
117       "git-autofixup", since git searches "PATH" for appropriately named
118       binaries.
119
120       Git is distributed with Perl 5 for platforms not expected to already
121       have it installed, but installing modules with cpan requires other
122       tools that might not be available, such as make. This script has no
123       dependencies outside of the standard library, so it is hoped that it
124       works on any platform that Git does without much trouble.
125
126       Requires a git supporting "commit --fixup": 1.7.4 or later.
127

BUGS/LIMITATIONS

129       If a topic branch adds some lines in one commit and subsequently
130       removes some of them in another, a hunk in the working directory that
131       re-adds those lines will be assigned to fixup the first commit, and
132       during rebasing they'll be removed again by the later commit.
133
134       Not tested in cmd.exe on Windows. Run it from Git Bash, Cygwin, or a
135       similar Unix emulation environment.
136

ACKNOWLEDGEMENTS

138       git-autofixup was inspired by a description of hg absorb
139       <https://bitbucket.org/facebook/hg-
140       experimental/src/38d6e5d7f355f58330cd707059baac38d69a1210/hgext3rd/absorb/__init__.py>
141       in the Mercurial Sprint Notes
142       <https://groups.google.com/forum/#!topic/mozilla.dev.version-
143       control/nh4fITFlEMk>. While I was working on it I found git-superfixup
144       <https://gist.github.com/oktal3700/cafe086b49c89f814be4a7507a32a3f7>,
145       by oktal3700, which was helpful to examine.
146
148       Copyright (C) 2017, Jordan Torbiak.
149
150       This program is free software; you can redistribute it and/or modify it
151       under the terms of the Artistic License v2.0.
152
153
154
155perl v5.36.0                      2022-07-21                  GIT-AUTOFIXUP(1)
Impressum