[RFD] subtree status - comparing subtree with a remote

From: Paul Campbell <hidden>
Date: 2016-06-15 22:56:14

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help