{"id":15017217,"url":"https://github.com/torbiak/git-autofixup","last_synced_at":"2025-04-04T14:04:24.798Z","repository":{"id":47753790,"uuid":"92347511","full_name":"torbiak/git-autofixup","owner":"torbiak","description":"create fixup commits for topic branches","archived":false,"fork":false,"pushed_at":"2024-11-13T04:41:58.000Z","size":283,"stargazers_count":190,"open_issues_count":1,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-28T13:06:26.017Z","etag":null,"topics":["code-review","git","perl5"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/torbiak.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-25T00:15:39.000Z","updated_at":"2025-03-20T23:05:39.000Z","dependencies_parsed_at":"2025-01-25T04:23:05.075Z","dependency_job_id":null,"html_url":"https://github.com/torbiak/git-autofixup","commit_stats":{"total_commits":141,"total_committers":5,"mean_commits":28.2,"dds":0.07092198581560283,"last_synced_commit":"d759b89e9cd09ec8a5e0ffe0d9ad59a798fedc66"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torbiak%2Fgit-autofixup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torbiak%2Fgit-autofixup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torbiak%2Fgit-autofixup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torbiak%2Fgit-autofixup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torbiak","download_url":"https://codeload.github.com/torbiak/git-autofixup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190165,"owners_count":20898697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-review","git","perl5"],"created_at":"2024-09-24T19:50:03.208Z","updated_at":"2025-04-04T14:04:24.779Z","avatar_url":"https://github.com/torbiak.png","language":"Perl","funding_links":[],"categories":["code-review"],"sub_categories":[],"readme":"=pod\n\n=head1 NAME\n\nApp::Git::Autofixup - create fixup commits for topic branches\n\n=head1 SYNOPSIS\n\n    git-autofixup [\u003coptions\u003e] [\u003crevision\u003e]\n\n=head1 DESCRIPTION\n\nF\u003cgit-autofixup\u003e parses hunks of changes in the working directory out of C\u003cgit diff\u003e output and uses C\u003cgit blame\u003e to assign those hunks to commits in C\u003cE\u003clt\u003erevisionE\u003cgt\u003e..HEAD\u003e, which will typically represent a topic branch, and then creates fixup commits to be used with C\u003cgit rebase --interactive --autosquash\u003e. It is assumed that hunks near changes that were previously committed to the topic branch are related. C\u003cE\u003clt\u003erevisionE\u003cgt\u003e\u003e defaults to C\u003cgit merge-base --fork-point HEAD @{upstream} || git merge-base HEAD @{upstream}\u003e, but this will only work if the current branch has an upstream/tracking branch. See C\u003cgit help revisions\u003e for info about how to specify revisions.\n\nIf any changes have been staged to the index using C\u003cgit add\u003e, then F\u003cgit-autofixup\u003e will only consider staged hunks when trying to create fixup commits. A temporary index is used to create any resulting commits.\n\nBy 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 C\u003c--strict 1\u003e will be used to attempt to resolve it. If C\u003c--strict 1\u003e 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 C\u003c--strict 2\u003e is given, but each added line must be surrounded by lines blamed on the same topic branch commit.\n\nFor example,  the added line in the hunk below is adjacent to lines committed by commits C\u003c99f370af\u003e and C\u003ca1eadbe2\u003e. 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.\n\n    COMMIT  |LINE|HEAD                          |WORKING DIRECTORY\n    99f370af|   1|first line                    | first line\n            |    |                              |+added line\n    a1eadbe2|   2|second line                   | second line\n\nBut if that second line were instead blamed on an upstream commit (denoted by C\u003c^\u003e), the hunk would be added to a fixup commit for C\u003c99f370af\u003e:\n\n    99f370af|   1|first line                    | first line\n            |    |                              |+added line\n    ^       |   2|second line                   | second line\n\nOutput similar to this example can be generated by setting verbosity to 2 or greater by using the verbosity option multiple times, eg. C\u003cgit-autofixup -vv\u003e, and can be helpful in determining how a hunk will be handled.\n\nF\u003cgit-autofixup\u003e 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.\n\n=head2 Articles\n\n=over\n\n=item\n\nL\u003cJordan Torbiak: Absorb changes across a topic branch in git|https://torbiak.com/post/autofixup/\u003e\n\n=item\n\nL\u003cSymflower: Effortlessly correct your Git commits with git-autofixup|https://symflower.com/en/company/blog/2021/git-autofixup/\u003e\n\n=back\n\n=head1 OPTIONS\n\n=over\n\n=item -h\n\nShow usage.\n\n=item --help\n\nShow manpage.\n\n=item --version\n\nShow version.\n\n=item -v, --verbose\n\nIncrease verbosity. Can be used up to two times.\n\n=item -c N, --context N\n\nChange the number of context lines C\u003cgit diff\u003e uses around hunks. Default: 3. This can change how hunks are assigned to fixup commits, especially with C\u003c--strict 0\u003e.\n\n=item -s N, --strict N\n\nSet how strict F\u003cgit-autofixup\u003e is about assigning hunks to fixup commits. Default: 0. Strictness levels are described under DESCRIPTION.\n\n=item -g ARG, --gitopt ARG\n\nSpecify 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. Deprecated in favor of C\u003cGIT_CONFIG_{COUNT,KEY,VALUE}\u003e environment variables; see C\u003cgit help config\u003e.\n\nNote ARG won't be wordsplit, so to give multiple arguments, such as for setting a config option like C\u003c-c diff.algorithm\u003e, this option must be used multiple times: C\u003c-g -c -g diff.algorithm=patience\u003e.\n\n=item -e, --exit-code\n\nUse more detailed exit codes:\n\n=over\n\n=item 0:\n\nAll hunks have been assigned.\n\n=item 1:\n\nOnly some hunks have been assigned.\n\n=item 2:\n\nNo hunks have been assigned.\n\n=item 3:\n\nThere was nothing to be assigned.\n\n=item 255:\n\nUnexpected error occurred.\n\n=back\n\n=back\n\n=head1 INSTALLATION\n\nIf cpan is available, run C\u003ccpan -i App::Git::Autofixup\u003e. Otherwise, copy F\u003cgit-autofixup\u003e to a directory in C\u003cPATH\u003e and ensure it has execute permissions. It can then be invoked as either C\u003cgit-autofixup\u003e or C\u003cgit autofixup\u003e, since git searches C\u003cPATH\u003e for appropriately named binaries.\n\nGit 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.\n\nRequires a git supporting C\u003ccommit --fixup\u003e: 1.7.4 or later.\n\n=head1 BUGS/LIMITATIONS\n\ngit-autofixup works on Windows, but be careful not to use a perl compiled for cygwin with a git compiled for msys, such as L\u003cGit for Windows|https://gitforwindows.org/\u003e. It can be used from Git for Windows' \"Git Bash\" or \"Git CMD\", or you can install git using Cygwin's package manager and use git-autofixup from Cygwin. Note that while every release gets tested on Cygwin via the CPAN Testers network, testing with Git for Windows requires more effort since it's a constrained environment; thus it doesn't get tested as often. If you run into any issues, please report them on L\u003cGitHub|https://github.com/torbiak/git-autofixup/issues\u003e.\n\nIf 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.\n\n=head1 ACKNOWLEDGEMENTS\n\nF\u003cgit-autofixup\u003e was inspired by a description of L\u003chg absorb|https://bitbucket.org/facebook/hg-experimental/src/38d6e5d7f355f58330cd707059baac38d69a1210/hgext3rd/absorb/__init__.py\u003e in the L\u003cMercurial Sprint Notes|https://groups.google.com/forum/#!topic/mozilla.dev.version-control/nh4fITFlEMk\u003e. While I was working on it I found L\u003cgit-superfixup|https://gist.github.com/oktal3700/cafe086b49c89f814be4a7507a32a3f7\u003e, by oktal3700, which was helpful to examine.\n\n=head1 COPYRIGHT AND LICENSE\n\nCopyright (C) 2017, Jordan Torbiak.\n\nThis program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.\n\n\n=cut\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorbiak%2Fgit-autofixup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorbiak%2Fgit-autofixup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorbiak%2Fgit-autofixup/lists"}