Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pmolodo/3949531594fa590cb2c2bce0ee7e7230 to your computer and use it in GitHub Desktop.
Save pmolodo/3949531594fa590cb2c2bce0ee7e7230 to your computer and use it in GitHub Desktop.
git --ancestry-path behavior with multiple negations
#!/bin/bash
set -e
mkdir ancestry_path_test
cd ancestry_path_test
git init
git checkout -b root
echo "R1" > root_file
git add root_file
git commit -m "R1"
git tag R1
git checkout -b featureB R1
echo "B1" > featureB_file
git add featureB_file
git commit -m "B1"
git tag B1
git checkout -b featureA R1
echo "A1" > featureA_file
git add featureA_file
git commit -m "A1"
git tag A1
git checkout -b merge_branch
git merge --no-edit B1
git tag M1
git checkout root
echo "R2" >> root_file
git commit -m "R2" root_file
git tag R2
git checkout featureB
git merge --no-edit R2
git tag B2
git checkout featureA
git merge --no-edit R2
git tag A2
git checkout merge_branch
git merge B2 --no-edit
git tag MB2
git merge A2 --no-edit
git tag MA2
git checkout root
echo "R3" >> root_file
git commit -m "R3" root_file
git tag R3
git checkout featureB
git merge --no-edit R3
git tag B3
git checkout featureA
git merge --no-edit R3
git tag A3
git checkout merge_branch
git merge B3 --no-edit
git tag MB3
git merge A3 --no-edit
git tag MA3
gitk --all &
echo "--ancestry-path ^R2 merge_branch"
git rev-list --ancestry-path ^R2 merge_branch | xargs -i git tag --points-at '{}'
gitk --ancestry-path ^R2 merge_branch &
echo "--ancestry-path ^R2 ^featureB merge_branch"
git rev-list --ancestry-path ^R2 ^featureB merge_branch | xargs -i git tag --points-at '{}'
gitk --ancestry-path ^R2 ^featureB merge_branch &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment