Skip to content

Instantly share code, notes, and snippets.

@dimasmiftah
Last active January 28, 2023 15:53
Show Gist options
  • Save dimasmiftah/5a6ad48e46e27ff7885d653959df78de to your computer and use it in GitHub Desktop.
Save dimasmiftah/5a6ad48e46e27ff7885d653959df78de to your computer and use it in GitHub Desktop.

Arcanist diff dependent on another diff

Simulation

1. Create branch for part1 (on top of master branch)

git checkout master
git checkout -b part1
echo "some changes" >> part1.txt
git add -A
git commit -m 'part 1'

arc diff --reviewers '#project_athena'

2. Create branch for part2 (on top of part1)

git checkout part1
git checkout -b part2
echo "some other changes" >> part2.txt
git add -A
git commit -m 'part 2'

arc diff --reviewers '#project_athena' part1 # <-- This is how we tell Arcanist to use part1 as the base

3. Performing some changes in the part1

git checkout part1
echo "additional changes" >> part1.txt
git add -A
git commit --amend -m 'part 1'

arc diff --reviewers '#project_athena'

4. If part 2 needs the above update, we need to rebase first

git checkout part2
git rebase -i part1

remember to take out all commits that are not part of part2.

After rebasing, we can diff with

arc diff --reviewers '#project_athena' part1 # <-- We also specify the base when updating

Optional

1. Configure an arcanist shortcut

Open ~/.bashrc or ~/.zshrc and add the following line

alias arcathena="arc diff --reviewers '#project_athena'"

Now we can reduce the amount of typings

arcathena
arcathena part1

2. If you prefer to use vim instead of nano.

Run the following command

export EDITOR="vim"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment