Skip to content

Instantly share code, notes, and snippets.

@ckoppelman
Last active February 19, 2020 18:27
Show Gist options
  • Save ckoppelman/c83525f497ae60c67709d283a0da0a55 to your computer and use it in GitHub Desktop.
Save ckoppelman/c83525f497ae60c67709d283a0da0a55 to your computer and use it in GitHub Desktop.
#!/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
#!/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