Repository navigation
Conversation
Port gitwatch's SKIP_IF_MERGING (-M): while a merge is in progress, skip the whole stage/commit cycle instead of committing a half-resolved merge with conflict markers still in the working tree. The check is wider than the shell script, which only looks for MERGE_HEAD: any repository state other than RepositoryState::Clean skips the commit, so a stopped rebase, cherry-pick, revert or bisect is covered as well. Configurable via --skip-if-merging or skip_if_merging in gitwatch.yaml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the
-M(SKIP_IF_MERGING) option of the original gitwatch.sh.Today, if a
git mergestops on conflicts and you save a file while you resolve them, gitwatch stages everything and commits. libgit2'scommit()ignoresMERGE_HEAD, so the result is a single-parent commit that contains the<<<<<<<conflict markers, and gitwatch does not removeMERGE_HEAD. A stopped rebase or cherry-pick has the same problem.With
--skip-if-merging, gitwatch checksRepository::state()before it stages anything. It skips the commit when the state is notClean.Usage
gitwatch watch --skip-if-merging .Or in
gitwatch.yaml:Differences from gitwatch.sh
gitwatch.sh only checks for
MERGE_HEAD. This PR skips every non-clean state: merge, rebase, cherry-pick, revert, bisect andgit am. The check is the same size, and it stops conflict markers from getting into a commit in all of these cases.