Last active
February 19, 2020 18:27
-
-
Save ckoppelman/c83525f497ae60c67709d283a0da0a55 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# Stages modified hunks matching passed in regex | |
SEARCH=$1 | |
PATHS_DIVIDER=$2 | |
PATHS=$3 | |
if [ -z "$PATHS" ] | |
then | |
git diff -U1 | grepdiff "$SEARCH" --output-matching=hunk | git apply --cached | |
else | |
if [ "--" = "$PATHS_DIVIDER" ] | |
then | |
git diff -U1 -- $PATHS | grepdiff "$SEARCH" --output-matching=hunk | git apply --cached | |
fi | |
fi |
This file contains 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
#!/bin/bash | |
# Stages modified hunks matching passed in regex | |
SEARCH=$1 | |
PATHS_DIVIDER=$2 | |
PATHS=$3 | |
if [ -z "$PATHS" ] | |
then | |
git diff -U1 | grepdiff "$SEARCH" --output-matching=hunk | git apply --cached | |
else | |
if [ "--" = "$PATHS_DIVIDER" ] | |
then | |
git diff -U1 -- $PATHS | grepdiff "$SEARCH" --output-matching=hunk | git apply --cached | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment