Skip to content

Instantly share code, notes, and snippets.

@ckoppelman
Last active February 19, 2020 18:27
Embed
What would you like to do?
#!/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