git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFD] subtree status - comparing subtree with a remote

From
Paul Campbell <pcampbell@kemitix.net>
Date
Feb 23, 2013, 00:19 UTC
Message-ID
<CALeLG_mF2Fucf=A2Dzn_KFgim8Z3vFpdWR84FYpu5gqKv=S64g@mail.gmail.com>
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
Message 1 of 1 in “[RFD] subtree status - comparing subtree with a remote”
  1. Paul CampbellFeb 23, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.