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

[PATCH 08/19] fixing typo

From
Paul Campbell <pcampbell@kemitix.net>
Date
Mar 9, 2013, 19:26 UTC
Message-ID
<CALeLG_kcJy4ksL5YVRpUoOvCTkS9J2WvDeT64fnb668H+X6pAA@mail.gmail.com>
>From 8f6eb2ddfcaef888dc3d3ea4d089aa2e9cad5d0f Mon Sep 17 00:00:00 2001
From: Paul Campbell <pcampbell@kemitix.net>
Date: Sat, 9 Mar 2013 18:32:53 +0000
Subject: [PATCH 08/19] fixing typo
Conflicts:
	git-subtree.sh
Add diff command
Original-Author: mhoffman <matt.hoffman@quantumretail.com>
Conflicts-resolved-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index ae9f87f..4c3f3c0 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -16,6 +16,7 @@ git subtree pull-all
 git subtree push-all
 git subtree push  --prefix=<prefix> <repository> <refspec...>
 git subtree split --prefix=<prefix> <commit...>
+git subtree diff  --prefix=<prefix> [<repository> [<refspec>...]]
 git subtree from-submodule --prefix=<prefix>
 --
 h,help        show the help
@@ -105,8 +106,8 @@ command="$1"
 shift
 case "$command" in
 	add|merge|pull|from-submodule|pull-all|push-all) default= ;;
-	split|push) default="--default HEAD" ;;
 	*) die "Unknown command '$command'" ;;
+    split|push|diff) default="--default HEAD" ;;
 esac

 if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" !=
"push-all" ]; then
@@ -737,6 +738,37 @@ cmd_pull()
 	fi
 }

+cmd_diff()
+{
+    if [ -e "$dir" ]; then
+        if [ $# -eq 1 ]; then
+            repository=$(git config -f .gittrees subtree.$prefix.url)
+            refspec=$1
+        elif [ $# -eq 2 ]; then
+            repository=$1
+            refspec=$2
+        else
+            repository=$(git config -f .gittrees subtree.$prefix.url)
+            refspec=$(git config -f .gittrees subtree.$prefix.branch)
+        fi
+        # this is ugly, but I don't know of a better way to do it. My
git-fu is weak.
+        # git diff-tree expects a treeish, but I have only a
repository and branch name.
+        # I don't know how to turn that into a treeish without
creating a remote.
+        # Please change this if you know a better way!
+        tmp_remote=__diff-tmp
+        git remote rm $tmp_remote > /dev/null 2>&1
+        git remote add -t $refspec $tmp_remote $repository > /dev/null
+        # we fetch as a separate step so we can pass -q (quiet),
which isn't an option for "git remote"
+        # could this instead be "git fetch -q $repository $refspec"
and leave aside creating the remote?
+        # Still need a treeish for the diff-tree command...
+        git fetch -q $tmp_remote
+        git diff-tree -p refs/remotes/$tmp_remote/$refspec
+        git remote rm $tmp_remote > /dev/null 2>&1
+    else
+        die "Cannot resolve directory '$dir'. Please point to an
existing subtree directory to diff. Try 'git subtree add' to add a
subtree."
+    fi
+}
+
 cmd_push()
 {
 	if [ $# -gt 2 ]; then
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
Message 1 of 1 in “fixing typo”
  1. 08/19 fixing typoPaul Campbell, Mar 9, 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.