Hi,

I'm looking at adding a "git subtree status" command that will tell if
a subtree is up-to-date, ahead of, behind, divergant with or unrelated
to a remote repo.

I just wanted to check that I'm working this out correctly before
writing the code.

1) perform a synthetic subtree split

  mine=$(git subtree split --prefix=subtree/path)

This outputs the SHA1 for this subtree in isolation to the superproject.

2) fetch latest branch HEAD from remote repository we're comparing with

  git fetch $repo $branch
  theirs=$(git rev-parse FETCH_HEAD)

3) Find common ancestor

  base=$(git merge-base $mine $theirs)

Where:

* $base == $mine && $base == $theirs : up-to-date

* $base == $mine && $base != $theirs : behind remote - can pull

* $base != $mine && $base == $theirs : ahead of remote - can push

* $base != $mine && $base != $theirs : divergent

* $base == null : no common ancestor - wrong repo?

Comments?

-- 
Paul [W] Campbell
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to