Skip to content

Commit 260adc8

Browse files
committed
Merge branch 'dg/subtree-fixes'
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
2 parents 5bf72ed + 8165be0 commit 260adc8

File tree

4 files changed

+40
-66
lines changed

4 files changed

+40
-66
lines changed

contrib/subtree/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ $(GIT_SUBTREE): $(GIT_SUBTREE_SH)
3030
doc: $(GIT_SUBTREE_DOC)
3131

3232
install: $(GIT_SUBTREE)
33-
$(INSTALL) -m 755 $(GIT_SUBTREE) $(libexecdir)
33+
$(INSTALL) -m 755 $(GIT_SUBTREE) $(DESTDIR)$(libexecdir)
3434

3535
install-doc: install-man
3636

3737
install-man: $(GIT_SUBTREE_DOC)
38-
$(INSTALL) -m 644 $^ $(man1dir)
38+
$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
39+
$(INSTALL) -m 644 $^ $(DESTDIR)$(man1dir)
3940

4041
$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
4142
xmlto -m $(MANPAGE_NORMAL_XSL) man $^

contrib/subtree/git-subtree.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if [ $# -eq 0 ]; then
99
fi
1010
OPTS_SPEC="\
1111
git subtree add --prefix=<prefix> <commit>
12+
git subtree add --prefix=<prefix> <repository> <commit>
1213
git subtree merge --prefix=<prefix> <commit>
1314
git subtree pull --prefix=<prefix> <repository> <refspec...>
1415
git subtree push --prefix=<prefix> <repository> <refspec...>
@@ -296,7 +297,7 @@ copy_commit()
296297
# We're going to set some environment vars here, so
297298
# do it in a subshell to get rid of them safely later
298299
debug copy_commit "{$1}" "{$2}" "{$3}"
299-
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
300+
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
300301
(
301302
read GIT_AUTHOR_NAME
302303
read GIT_AUTHOR_EMAIL
@@ -497,12 +498,23 @@ cmd_add()
497498
ensure_clean
498499

499500
if [ $# -eq 1 ]; then
500-
"cmd_add_commit" "$@"
501+
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
502+
die "'$1' does not refer to a commit"
503+
504+
"cmd_add_commit" "$@"
501505
elif [ $# -eq 2 ]; then
502-
"cmd_add_repository" "$@"
506+
# Technically we could accept a refspec here but we're
507+
# just going to turn around and add FETCH_HEAD under the
508+
# specified directory. Allowing a refspec might be
509+
# misleading because we won't do anything with any other
510+
# branches fetched via the refspec.
511+
git rev-parse -q --verify "$2^{commit}" >/dev/null ||
512+
die "'$2' does not refer to a commit"
513+
514+
"cmd_add_repository" "$@"
503515
else
504516
say "error: parameters were '$@'"
505-
die "Provide either a refspec or a repository and refspec."
517+
die "Provide either a commit or a repository and commit."
506518
fi
507519
}
508520

contrib/subtree/git-subtree.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ git-subtree - Merge subtrees together and split repository into subtrees
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git subtree' add -P <prefix> <commit>
12+
'git subtree' add -P <prefix> <refspec>
13+
'git subtree' add -P <prefix> <repository> <refspec>
1314
'git subtree' pull -P <prefix> <repository> <refspec...>
1415
'git subtree' push -P <prefix> <repository> <refspec...>
1516
'git subtree' merge -P <prefix> <commit>

0 commit comments

Comments
 (0)