Great post. However the preferred approach suggested in the article has some shortcomings — mainly, the diff will include files that changed in master, relative to your branch. Not the end of the world, but there may be a better way.
I found a way to deepen the shallow clone depth until the merge-base commit is found. Posted in a comment here: github.com/hasura/smooth-checkout-...
#!/bin/bashset-euo pipefail
# From: https://stackoverflow.com/a/56113247/2696867echo"--- git fetching shallow merge base"# TODO: Consider using PR base branch $BUILDKITE_PULL_REQUEST_BASE_BRANCH, and default to master if no PR.echo"Fetching commits until we find the merge-base / fork-point between current commit and master"while[-z$( git merge-base master $BUILDKITE_COMMIT)];do
echo"git fetch --deepen=50 origin master $BUILDKITE_COMMIT"
git fetch --deepen=50 origin master $BUILDKITE_COMMITdone
echo"Done."
This allows you to have a shallow clone but still have it go as deep as you need to be able to git diff between current branch and base branch:
git --no-pager diff master... --name-only
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great post. However the preferred approach suggested in the article has some shortcomings — mainly, the diff will include files that changed in master, relative to your branch. Not the end of the world, but there may be a better way.
I found a way to
deepen
the shallow clone depth until the merge-base commit is found. Posted in a comment here: github.com/hasura/smooth-checkout-...This allows you to have a shallow clone but still have it go as deep as you need to be able to git diff between current branch and base branch: