* [RFD] subtree status - comparing subtree with a remote
@ 2013-02-23 0:19 Paul Campbell
0 siblings, 0 replies; only message in thread
From: Paul Campbell @ 2013-02-23 0:19 UTC (permalink / raw)
To: git
Cc: Jonathan Nieder, Adam Tkac, David A. Greene, Jesper L. Nielsen,
Michael Schubert, Techlive Zheng
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-02-23 0:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-23 0:19 [RFD] subtree status - comparing subtree with a remote Paul Campbell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.