Skip to content

Commit

Permalink
Merge branch 'dg/subtree-fixes'
Browse files Browse the repository at this point in the history
contrib/subtree updates, but here are only the ones that looked
ready.  The remainder of the patches will have another day.

* dg/subtree-fixes:
  contrib/subtree: make the manual directory if needed
  contrib/subtree: honor DESTDIR
  contrib/subtree: fix synopsis
  contrib/subtree: better error handling for 'subtree add'
  contrib/subtree: use %B for split subject/body
  contrib/subtree: remove test number comments
  • Loading branch information
Junio C Hamano committed Feb 14, 2013
2 parents 5bf72ed + 8165be0 commit 260adc8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 66 deletions.
5 changes: 3 additions & 2 deletions contrib/subtree/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ $(GIT_SUBTREE): $(GIT_SUBTREE_SH)
doc: $(GIT_SUBTREE_DOC)

install: $(GIT_SUBTREE)
$(INSTALL) -m 755 $(GIT_SUBTREE) $(libexecdir)
$(INSTALL) -m 755 $(GIT_SUBTREE) $(DESTDIR)$(libexecdir)

install-doc: install-man

install-man: $(GIT_SUBTREE_DOC)
$(INSTALL) -m 644 $^ $(man1dir)
$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
$(INSTALL) -m 644 $^ $(DESTDIR)$(man1dir)

$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
xmlto -m $(MANPAGE_NORMAL_XSL) man $^
Expand Down
20 changes: 16 additions & 4 deletions contrib/subtree/git-subtree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [ $# -eq 0 ]; then
fi
OPTS_SPEC="\
git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <commit>
git subtree merge --prefix=<prefix> <commit>
git subtree pull --prefix=<prefix> <repository> <refspec...>
git subtree push --prefix=<prefix> <repository> <refspec...>
Expand Down Expand Up @@ -296,7 +297,7 @@ copy_commit()
# We're going to set some environment vars here, so
# do it in a subshell to get rid of them safely later
debug copy_commit "{$1}" "{$2}" "{$3}"
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
(
read GIT_AUTHOR_NAME
read GIT_AUTHOR_EMAIL
Expand Down Expand Up @@ -497,12 +498,23 @@ cmd_add()
ensure_clean

if [ $# -eq 1 ]; then
"cmd_add_commit" "$@"
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
die "'$1' does not refer to a commit"

"cmd_add_commit" "$@"
elif [ $# -eq 2 ]; then
"cmd_add_repository" "$@"
# Technically we could accept a refspec here but we're
# just going to turn around and add FETCH_HEAD under the
# specified directory. Allowing a refspec might be
# misleading because we won't do anything with any other
# branches fetched via the refspec.
git rev-parse -q --verify "$2^{commit}" >/dev/null ||
die "'$2' does not refer to a commit"

"cmd_add_repository" "$@"
else
say "error: parameters were '$@'"
die "Provide either a refspec or a repository and refspec."
die "Provide either a commit or a repository and commit."
fi
}

Expand Down
3 changes: 2 additions & 1 deletion contrib/subtree/git-subtree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ git-subtree - Merge subtrees together and split repository into subtrees
SYNOPSIS
--------
[verse]
'git subtree' add -P <prefix> <commit>
'git subtree' add -P <prefix> <refspec>
'git subtree' add -P <prefix> <repository> <refspec>
'git subtree' pull -P <prefix> <repository> <refspec...>
'git subtree' push -P <prefix> <repository> <refspec...>
'git subtree' merge -P <prefix> <commit>
Expand Down
Loading

0 comments on commit 260adc8

Please sign in to comment.