* [PATCH 05/13] contrib/subtree: Honor DESTDIR
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: Adam Tkac, David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: Adam Tkac <atkac@redhat.com>
Teach git-subtree's Makefile to honor DESTDIR.
Signed-off-by: Adam Tkac <atkac@redhat.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/Makefile b/contrib/subtree/Makefile
index 05cdd5c..36ae3e4 100644
--- a/contrib/subtree/Makefile
+++ b/contrib/subtree/Makefile
@@ -30,12 +30,12 @@ $(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) -m 644 $^ $(DESTDIR)$(man1dir)
$(GIT_SUBTREE_DOC): $(GIT_SUBTREE_XML)
xmlto -m $(MANPAGE_NORMAL_XSL) man $^
--
1.7.10.4
^ permalink raw reply related
* [PATCH 07/13] contrib/subtree: Fix whitespaces
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng, David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Previous code does not fulfill Git's whitespace policy.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 68 ++++----
contrib/subtree/git-subtree.txt | 42 ++---
contrib/subtree/t/t7900-subtree.sh | 314 ++++++++++++++++++------------------
3 files changed, 212 insertions(+), 212 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..6c3929b 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -5,7 +5,7 @@
# Copyright (C) 2009 Avery Pennarun <apenwarr@gmail.com>
#
if [ $# -eq 0 ]; then
- set -- -h
+ set -- -h
fi
OPTS_SPEC="\
git subtree add --prefix=<prefix> <commit>
@@ -111,9 +111,9 @@ if [ -z "$prefix" ]; then
fi
case "$command" in
- add) [ -e "$prefix" ] &&
+ add) [ -e "$prefix" ] &&
die "prefix '$prefix' already exists." ;;
- *) [ -e "$prefix" ] ||
+ *) [ -e "$prefix" ] ||
die "'$prefix' does not exist; use 'git subtree add'" ;;
esac
@@ -182,8 +182,8 @@ cache_set()
oldrev="$1"
newrev="$2"
if [ "$oldrev" != "latest_old" \
- -a "$oldrev" != "latest_new" \
- -a -e "$cachedir/$oldrev" ]; then
+ -a "$oldrev" != "latest_new" \
+ -a -e "$cachedir/$oldrev" ]; then
die "cache for $oldrev already exists!"
fi
echo "$newrev" >"$cachedir/$oldrev"
@@ -305,7 +305,7 @@ copy_commit()
read GIT_COMMITTER_NAME
read GIT_COMMITTER_EMAIL
read GIT_COMMITTER_DATE
- export GIT_AUTHOR_NAME \
+ export GIT_AUTHOR_NAME \
GIT_AUTHOR_EMAIL \
GIT_AUTHOR_DATE \
GIT_COMMITTER_NAME \
@@ -328,7 +328,7 @@ add_msg()
fi
cat <<-EOF
$commit_message
-
+
git-subtree-dir: $dir
git-subtree-mainline: $latest_old
git-subtree-split: $latest_new
@@ -356,7 +356,7 @@ rejoin_msg()
fi
cat <<-EOF
$commit_message
-
+
git-subtree-dir: $dir
git-subtree-mainline: $latest_old
git-subtree-split: $latest_new
@@ -369,7 +369,7 @@ squash_msg()
oldsub="$2"
newsub="$3"
newsub_short=$(git rev-parse --short "$newsub")
-
+
if [ -n "$oldsub" ]; then
oldsub_short=$(git rev-parse --short "$oldsub")
echo "Squashed '$dir/' changes from $oldsub_short..$newsub_short"
@@ -379,7 +379,7 @@ squash_msg()
else
echo "Squashed '$dir/' content from commit $newsub_short"
fi
-
+
echo
echo "git-subtree-dir: $dir"
echo "git-subtree-split: $newsub"
@@ -428,7 +428,7 @@ new_squash_commit()
newsub="$3"
tree=$(toptree_for_commit $newsub) || exit $?
if [ -n "$old" ]; then
- squash_msg "$dir" "$oldsub" "$newsub" |
+ squash_msg "$dir" "$oldsub" "$newsub" |
git commit-tree "$tree" -p "$old" || exit $?
else
squash_msg "$dir" "" "$newsub" |
@@ -456,7 +456,7 @@ copy_or_skip()
else
nonidentical="$parent"
fi
-
+
# sometimes both old parents map to the same newparent;
# eliminate duplicates
is_new=1
@@ -471,7 +471,7 @@ copy_or_skip()
p="$p -p $parent"
fi
done
-
+
if [ -n "$identical" ]; then
echo $identical
else
@@ -496,7 +496,7 @@ cmd_add()
fi
ensure_clean
-
+
if [ $# -eq 1 ]; then
git rev-parse -q --verify "$1^{commit}" >/dev/null ||
die "'$1' does not refer to a commit"
@@ -513,8 +513,8 @@ cmd_add()
"cmd_add_repository" "$@"
else
- say "error: parameters were '$@'"
- die "Provide either a commit or a repository and commit."
+ say "error: parameters were '$@'"
+ die "Provide either a commit or a repository and commit."
fi
}
@@ -534,19 +534,19 @@ cmd_add_commit()
revs=$(git rev-parse $default --revs-only "$@") || exit $?
set -- $revs
rev="$1"
-
+
debug "Adding $dir as '$rev'..."
git read-tree --prefix="$dir" $rev || exit $?
git checkout -- "$dir" || exit $?
tree=$(git write-tree) || exit $?
-
+
headrev=$(git rev-parse HEAD) || exit $?
if [ -n "$headrev" -a "$headrev" != "$rev" ]; then
headp="-p $headrev"
else
headp=
fi
-
+
if [ -n "$squash" ]; then
rev=$(new_squash_commit "" "" "$rev") || exit $?
commit=$(add_squashed_msg "$rev" "$dir" |
@@ -556,7 +556,7 @@ cmd_add_commit()
git commit-tree $tree $headp -p "$rev") || exit $?
fi
git reset "$commit" || exit $?
-
+
say "Added dir '$dir'"
}
@@ -564,7 +564,7 @@ cmd_split()
{
debug "Splitting $dir..."
cache_setup || exit $?
-
+
if [ -n "$onto" ]; then
debug "Reading history for --onto=$onto..."
git rev-list $onto |
@@ -575,13 +575,13 @@ cmd_split()
cache_set $rev $rev
done
fi
-
+
if [ -n "$ignore_joins" ]; then
unrevs=
else
unrevs="$(find_existing_splits "$dir" "$revs")"
fi
-
+
# We can't restrict rev-list to only $dir here, because some of our
# parents have the $dir contents the root, and those won't match.
# (and rev-list --follow doesn't seem to solve this)
@@ -603,12 +603,12 @@ cmd_split()
debug " parents: $parents"
newparents=$(cache_get $parents)
debug " newparents: $newparents"
-
+
tree=$(subtree_for_commit $rev "$dir")
debug " tree is: $tree"
check_parents $parents
-
+
# ugly. is there no better way to tell if this is a subtree
# vs. a mainline commit? Does it matter?
if [ -z $tree ]; then
@@ -629,7 +629,7 @@ cmd_split()
if [ -z "$latest_new" ]; then
die "No new revisions were found"
fi
-
+
if [ -n "$rejoin" ]; then
debug "Merging split branch into HEAD..."
latest_old=$(cache_get latest_old)
@@ -657,13 +657,13 @@ cmd_merge()
{
revs=$(git rev-parse $default --revs-only "$@") || exit $?
ensure_clean
-
+
set -- $revs
if [ $# -ne 1 ]; then
die "You must provide exactly one revision. Got: '$revs'"
fi
rev="$1"
-
+
if [ -n "$squash" ]; then
first_split="$(find_latest_squash "$dir")"
if [ -z "$first_split" ]; then
@@ -709,15 +709,15 @@ cmd_pull()
cmd_push()
{
if [ $# -ne 2 ]; then
- die "You must provide <repository> <refspec>"
+ die "You must provide <repository> <refspec>"
fi
if [ -e "$dir" ]; then
- repository=$1
- refspec=$2
- echo "git push using: " $repository $refspec
- git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
+ repository=$1
+ refspec=$2
+ echo "git push using: " $repository $refspec
+ git push $repository $(git subtree split --prefix=$prefix):refs/heads/$refspec
else
- die "'$dir' must already exist. Try 'git subtree add'."
+ die "'$dir' must already exist. Try 'git subtree add'."
fi
}
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 7ba853e..aae9d19 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -87,15 +87,15 @@ merge::
go back in time from v2.5 to v2.4, for example. If your
merge introduces a conflict, you can resolve it in the
usual ways.
-
+
pull::
Exactly like 'merge', but parallels 'git pull' in that
it fetches the given commit from the specified remote
repository.
-
+
push::
Does a 'split' (see below) using the <prefix> supplied
- and then does a 'git push' to push the result to the
+ and then does a 'git push' to push the result to the
repository and refspec. This can be used to push your
subtree to different branches of the remote repository.
@@ -107,19 +107,19 @@ split::
contents of <prefix> at the root of the project instead
of in a subdirectory. Thus, the newly created history
is suitable for export as a separate git repository.
-
+
After splitting successfully, a single commit id is
printed to stdout. This corresponds to the HEAD of the
newly created tree, which you can manipulate however you
want.
-
+
Repeated splits of exactly the same history are
guaranteed to be identical (ie. to produce the same
commit ids). Because of this, if you add new commits
and then re-split, the new commits will be attached as
commits on top of the history you generated last time,
so 'git merge' and friends will work as expected.
-
+
Note that if you use '--squash' when you merge, you
should usually not just '--rejoin' when you split.
@@ -156,26 +156,26 @@ OPTIONS FOR add, merge, push, pull
project, produce only a single commit that contains all
the differences you want to merge, and then merge that
new commit into your project.
-
+
Using this option helps to reduce log clutter. People
rarely want to see every change that happened between
v1.0 and v1.1 of the library they're using, since none of the
interim versions were ever included in their application.
-
+
Using '--squash' also helps avoid problems when the same
subproject is included multiple times in the same
project, or is removed and then re-added. In such a
case, it doesn't make sense to combine the histories
anyway, since it's unclear which part of the history
belongs to which subtree.
-
+
Furthermore, with '--squash', you can switch back and
forth between different versions of a subtree, rather
than strictly forward. 'git subtree merge --squash'
always adjusts the subtree to match the exactly
specified commit, even if getting to that commit would
require undoing some changes that were added earlier.
-
+
Whether or not you use '--squash', changes made in your
local repository remain intact and can be later split
and send upstream to the subproject.
@@ -191,11 +191,11 @@ OPTIONS FOR split
commits with the same commit message, but possibly
different content, from the original commits, this can help
to differentiate them and avoid confusion.
-
+
Whenever you split, you need to use the same
<annotation>, or else you don't have a guarantee that
the new re-created history will be identical to the old
- one. That will prevent merging from working correctly.
+ one. That will prevent merging from working correctly.
git subtree tries to make it work anyway, particularly
if you use --rejoin, but it may not always be effective.
@@ -204,8 +204,8 @@ OPTIONS FOR split
This option is only valid for the split command.
After generating the synthetic history, create a new
- branch called <branch> that contains the new history.
- This is suitable for immediate pushing upstream.
+ branch called <branch> that contains the new history.
+ This is suitable for immediate pushing upstream.
<branch> must not already exist.
--ignore-joins::
@@ -228,7 +228,7 @@ OPTIONS FOR split
revision of the subproject's history that was imported
into your project, and git subtree will attempt to build
its history from there.
-
+
If you used 'git subtree add', you should never need
this option.
@@ -239,18 +239,18 @@ OPTIONS FOR split
history back into your main project. That way, future
splits can search only the part of history that has
been added since the most recent --rejoin.
-
+
If your split commits end up merged into the upstream
subproject, and then you want to get the latest upstream
version, this will allow git's merge algorithm to more
intelligently avoid conflicts (since it knows these
synthetic commits are already part of the upstream
repository).
-
+
Unfortunately, using this option results in 'git log'
showing an extra copy of every new commit that was
created (the original, and the synthetic one).
-
+
If you do all your merges with '--squash', don't use
'--rejoin' when you split, because you don't want the
subproject's history to be part of your project anyway.
@@ -285,7 +285,7 @@ First, get your own copy of the git.git repository:
$ cd test-git
gitweb (commit 1130ef3) was merged into git as of commit
-0a8f4f0, after which it was no longer maintained separately.
+0a8f4f0, after which it was no longer maintained separately.
But imagine it had been maintained separately, and we wanted to
extract git's changes to gitweb since that time, to share with
the upstream. You could do this:
@@ -295,7 +295,7 @@ the upstream. You could do this:
--branch gitweb-latest
$ gitk gitweb-latest
$ git push git@github.com:whatever/gitweb.git gitweb-latest:master
-
+
(We use '0a8f4f0^..' because that means "all the changes from
0a8f4f0 to the current version, including 0a8f4f0 itself.")
@@ -329,7 +329,7 @@ And fast forward again:
$ git subtree merge --prefix=gitweb --squash gitweb-latest
And notice that your change is still intact:
-
+
$ ls -l gitweb/myfile
And you can split it out and look at your changes versus
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 3f17f55..e6a3702 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -23,7 +23,7 @@ check_equal()
{
test_debug 'echo'
test_debug "echo \"check a:\" \"{$1}\""
- test_debug "echo \" b:\" \"{$2}\""
+ test_debug "echo \" b:\" \"{$2}\""
if [ "$1" = "$2" ]; then
return 0
else
@@ -61,17 +61,17 @@ last_commit_message()
}
test_expect_success 'init subproj' '
- test_create_repo subproj
+ test_create_repo subproj
'
# To the subproject!
cd subproj
test_expect_success 'add sub1' '
- create sub1 &&
- git commit -m "sub1" &&
- git branch sub1 &&
- git branch -m master subproj
+ create sub1 &&
+ git commit -m "sub1" &&
+ git branch sub1 &&
+ git branch -m master subproj
'
# Save this hash for testing later.
@@ -79,140 +79,140 @@ test_expect_success 'add sub1' '
subdir_hash=`git rev-parse HEAD`
test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2" &&
- git branch sub2
+ create sub2 &&
+ git commit -m "sub2" &&
+ git branch sub2
'
test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3" &&
- git branch sub3
+ create sub3 &&
+ git commit -m "sub3" &&
+ git branch sub3
'
# Back to mainline
cd ..
test_expect_success 'add main4' '
- create main4 &&
- git commit -m "main4" &&
- git branch -m master mainline &&
- git branch subdir
+ create main4 &&
+ git commit -m "main4" &&
+ git branch -m master mainline &&
+ git branch subdir
'
test_expect_success 'fetch subproj history' '
- git fetch ./subproj sub1 &&
- git branch sub1 FETCH_HEAD
+ git fetch ./subproj sub1 &&
+ git branch sub1 FETCH_HEAD
'
test_expect_success 'no subtree exists in main tree' '
- test_must_fail git subtree merge --prefix=subdir sub1
+ test_must_fail git subtree merge --prefix=subdir sub1
'
test_expect_success 'no pull from non-existant subtree' '
- test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+ test_must_fail git subtree pull --prefix=subdir ./subproj sub1
'
test_expect_success 'check if --message works for add' '
- git subtree add --prefix=subdir --message="Added subproject" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject" &&
- undo
+ git subtree add --prefix=subdir --message="Added subproject" sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject" &&
+ undo
'
test_expect_success 'check if --message works as -m and --prefix as -P' '
- git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
- undo
+ git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
+ undo
'
test_expect_success 'check if --message works with squash too' '
- git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
- undo
+ git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
+ check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
+ undo
'
test_expect_success 'add subproj to mainline' '
- git subtree add --prefix=subdir/ FETCH_HEAD &&
- check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
+ git subtree add --prefix=subdir/ FETCH_HEAD &&
+ check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
'
# this shouldn't actually do anything, since FETCH_HEAD is already a parent
test_expect_success 'merge fetched subproj' '
- git merge -m "merge -s -ours" -s ours FETCH_HEAD
+ git merge -m "merge -s -ours" -s ours FETCH_HEAD
'
test_expect_success 'add main-sub5' '
- create subdir/main-sub5 &&
- git commit -m "main-sub5"
+ create subdir/main-sub5 &&
+ git commit -m "subproj: main-sub5"
'
test_expect_success 'add main6' '
- create main6 &&
- git commit -m "main6 boring"
+ create main6 &&
+ git commit -m "main6 boring"
'
test_expect_success 'add main-sub7' '
- create subdir/main-sub7 &&
- git commit -m "main-sub7"
+ create subdir/main-sub7 &&
+ git commit -m "subproj: main-sub7"
'
test_expect_success 'fetch new subproj history' '
- git fetch ./subproj sub2 &&
- git branch sub2 FETCH_HEAD
+ git fetch ./subproj sub2 &&
+ git branch sub2 FETCH_HEAD
'
test_expect_success 'check if --message works for merge' '
- git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
- undo
+ git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
+ check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
+ undo
'
test_expect_success 'check if --message for merge works with squash too' '
- git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
- undo
+ git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
+ check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
+ undo
'
test_expect_success 'merge new subproj history into subdir' '
- git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split &&
- check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git branch pre-split &&
+ check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
'
test_expect_success 'Check that prefix argument is required for split' '
- echo "You must provide the --prefix option." > expected &&
- test_must_fail git subtree split > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ echo "You must provide the --prefix option." > expected &&
+ test_must_fail git subtree split > actual 2>&1 &&
+ test_debug "echo -n expected: " &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual &&
+ rm -f expected actual
'
test_expect_success 'Check that the <prefix> exists for a split' '
- echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
- test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
- test_debug "echo -n expected: " &&
- test_debug "cat expected" &&
- test_debug "echo -n actual: " &&
- test_debug "cat actual" &&
- test_cmp expected actual
-# rm -f expected actual
+ echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
+ test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
+ test_debug "echo -n expected: " &&
+ test_debug "cat expected" &&
+ test_debug "echo -n actual: " &&
+ test_debug "cat actual" &&
+ test_cmp expected actual
+# rm -f expected actual
'
test_expect_success 'check if --message works for split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- git branch spl1 "$spl1" &&
- check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
- undo
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ git branch spl1 "$spl1" &&
+ check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
+ undo
'
test_expect_success 'check split with --branch' '
- spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
- check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
+ spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
+ undo &&
+ git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
+ check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
'
test_expect_success 'check hash of split' '
@@ -227,69 +227,69 @@ test_expect_success 'check hash of split' '
'
test_expect_success 'check split with --branch for an existing branch' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git branch splitbr2 sub1 &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
- check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ undo &&
+ git branch splitbr2 sub1 &&
+ git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
+ check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
'
test_expect_success 'check split with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
+ test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
'
test_expect_success 'check split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
- check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
+ spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+ undo &&
+ git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
+ check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
'
test_expect_success 'add main-sub8' '
- create subdir/main-sub8 &&
- git commit -m "main-sub8"
+ create subdir/main-sub8 &&
+ git commit -m "main-sub8"
'
# To the subproject!
cd ./subproj
test_expect_success 'merge split into subproj' '
- git fetch .. spl1 &&
- git branch spl1 FETCH_HEAD &&
- git merge FETCH_HEAD
+ git fetch .. spl1 &&
+ git branch spl1 FETCH_HEAD &&
+ git merge FETCH_HEAD
'
test_expect_success 'add sub9' '
- create sub9 &&
- git commit -m "sub9"
+ create sub9 &&
+ git commit -m "sub9"
'
# Back to mainline
cd ..
test_expect_success 'split for sub8' '
- split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
- git branch split2 "$split2"
+ split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
+ git branch split2 "$split2"
'
test_expect_success 'add main-sub10' '
- create subdir/main-sub10 &&
- git commit -m "main-sub10"
+ create subdir/main-sub10 &&
+ git commit -m "main-sub10"
'
test_expect_success 'split for sub10' '
- spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
- git branch spl3 "$spl3"
+ spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
+ git branch spl3 "$spl3"
'
# To the subproject!
cd ./subproj
test_expect_success 'merge split into subproj' '
- git fetch .. spl3 &&
- git branch spl3 FETCH_HEAD &&
- git merge FETCH_HEAD &&
- git branch subproj-merge-spl3
+ git fetch .. spl3 &&
+ git branch spl3 FETCH_HEAD &&
+ git merge FETCH_HEAD &&
+ git branch subproj-merge-spl3
'
chkm="main4 main6"
@@ -299,44 +299,44 @@ chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$subfiles" "$chkms $chks"
+ subfiles=''"$(git ls-files | fixnl)"'' &&
+ check_equal "$subfiles" "$chkms $chks"
'
test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" "$chkms $chks"
+ allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
+ check_equal "$allchanges" "$chkms $chks"
'
# Back to mainline
cd ..
test_expect_success 'pull from subproj' '
- git fetch ./subproj subproj-merge-spl3 &&
- git branch subproj-merge-spl3 FETCH_HEAD &&
- git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
+ git fetch ./subproj subproj-merge-spl3 &&
+ git branch subproj-merge-spl3 FETCH_HEAD &&
+ git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
'
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ mainfiles=''"$(git ls-files | fixnl)"'' &&
+ check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
test_expect_success 'make sure each filename changed exactly once in the entire history' '
- # main-sub?? and /subdir/main-sub?? both change, because those are the
- # changes that were split into their own history. And subdir/sub?? never
- # change, since they were *only* changed in the subtree branch.
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
+ # main-sub?? and /subdir/main-sub?? both change, because those are the
+ # changes that were split into their own history. And subdir/sub?? never
+ # change, since they were *only* changed in the subtree branch.
+ allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
+ check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
'
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
+ check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
'
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
- # They are meaningless to subproj since one side of the merge refers to the mainline
- check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
+ # They are meaningless to subproj since one side of the merge refers to the mainline
+ check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
'
# prepare second pair of repositories
@@ -344,27 +344,27 @@ mkdir test2
cd test2
test_expect_success 'init main' '
- test_create_repo main
+ test_create_repo main
'
cd main
test_expect_success 'add main1' '
- create main1 &&
- git commit -m "main1"
+ create main1 &&
+ git commit -m "main1"
'
cd ..
test_expect_success 'init sub' '
- test_create_repo sub
+ test_create_repo sub
'
cd sub
test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2"
+ create sub2 &&
+ git commit -m "sub2"
'
cd ../main
@@ -372,33 +372,33 @@ cd ../main
# check if split can find proper base without --onto
test_expect_success 'add sub as subdir in main' '
- git fetch ../sub master &&
- git branch sub2 FETCH_HEAD &&
- git subtree add --prefix subdir sub2
+ git fetch ../sub master &&
+ git branch sub2 FETCH_HEAD &&
+ git subtree add --prefix subdir sub2
'
cd ../sub
test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3"
+ create sub3 &&
+ git commit -m "sub3"
'
cd ../main
test_expect_success 'merge from sub' '
- git fetch ../sub master &&
- git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix subdir sub3
+ git fetch ../sub master &&
+ git branch sub3 FETCH_HEAD &&
+ git subtree merge --prefix subdir sub3
'
test_expect_success 'add main-sub4' '
- create subdir/main-sub4 &&
- git commit -m "main-sub4"
+ create subdir/main-sub4 &&
+ git commit -m "main-sub4"
'
test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix subdir --branch mainsub4
+ git subtree split --prefix subdir --branch mainsub4
'
# at this point, the new commit parent should be sub3 if it is not,
@@ -407,21 +407,21 @@ test_expect_success 'split for main-sub4 without --onto' '
# itself)
test_expect_success 'check that the commit parent is sub3' '
- check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
+ check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
'
test_expect_success 'add main-sub5' '
- mkdir subdir2 &&
- create subdir2/main-sub5 &&
- git commit -m "main-sub5"
+ mkdir subdir2 &&
+ create subdir2/main-sub5 &&
+ git commit -m "main-sub5"
'
test_expect_success 'split for main-sub5 without --onto' '
- # also test that we still can split out an entirely new subtree
- # if the parent of the first commit in the tree is not empty,
- # then the new subtree has accidently been attached to something
- git subtree split --prefix subdir2 --branch mainsub5 &&
- check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
+ # also test that we still can split out an entirely new subtree
+ # if the parent of the first commit in the tree is not empty,
+ # then the new subtree has accidently been attached to something
+ git subtree split --prefix subdir2 --branch mainsub5 &&
+ check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
'
# make sure no patch changes more than one file. The original set of commits
@@ -449,20 +449,20 @@ joincommits()
}
test_expect_success 'verify one file change per commit' '
- x= &&
- list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
-# test_debug "echo HERE" &&
-# test_debug "echo ''"$list"''" &&
- (git log --pretty=format:'"'commit: %H'"' | joincommits |
- ( while read commit a b; do
- test_debug "echo Verifying commit "''"$commit"''
- test_debug "echo a: "''"$a"''
- test_debug "echo b: "''"$b"''
- check_equal "$b" ""
- x=1
- done
- check_equal "$x" 1
- ))
+ x= &&
+ list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
+# test_debug "echo HERE" &&
+# test_debug "echo ''"$list"''" &&
+ (git log --pretty=format:'"'commit: %H'"' | joincommits |
+ ( while read commit a b; do
+ test_debug "echo Verifying commit "''"$commit"''
+ test_debug "echo a: "''"$a"''
+ test_debug "echo b: "''"$b"''
+ check_equal "$b" ""
+ x=1
+ done
+ check_equal "$x" 1
+ ))
'
test_done
--
1.7.10.4
^ permalink raw reply related
* Re: Rebased git-subtree changes
From: greened @ 2013-02-05 11:52 UTC (permalink / raw)
To: git
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
"David A. Greene" <greened@obbligato.org> writes:
> Here's a re-send of the git-subtree patches after rebasing onto
> master. Hopefully Junio will have better luck applying these.
Damn. Sorry, I sent this before getting all of the feedback. Just
ignore this sequence and I'll send a fixed version in the future.
-David
^ permalink raw reply
* [PATCH 13/13] contrib/subtree: Remove --annotate
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: "David A. Greene" <greened@obbligato.org>
Remove --annotate. This obviates the need for an --unannotate
command. We really want a more generalized commit message rewrite
mechanism.
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 6 +----
contrib/subtree/t/t7900-subtree.sh | 50 ++++++++++++++++++------------------
2 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 0493e47..888a191 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -21,7 +21,6 @@ d show debug messages
P,prefix= the name of the subdir to split out
m,message= use the given message as the commit message for the merge commit
options for 'split'
-annotate= add a prefix to commit message of new commits
b,branch= create a new branch from the split subtree
ignore-joins ignore prior --rejoin commits
onto= try connecting new tree to an existing one
@@ -43,7 +42,6 @@ command=
onto=
rejoin=
ignore_joins=
-annotate=
squash=
message=
@@ -79,8 +77,6 @@ while [ $# -gt 0 ]; do
case "$opt" in
-q) quiet=1 ;;
-d) debug=1 ;;
- --annotate) annotate="$1"; shift ;;
- --no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
-P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
@@ -311,7 +307,7 @@ copy_commit()
GIT_COMMITTER_NAME \
GIT_COMMITTER_EMAIL \
GIT_COMMITTER_DATE
- (echo -n "$annotate"; cat ) |
+ (echo -n ""; cat ) |
git commit-tree "$2" $3 # reads the rest of stdin
) || die "Can't copy commit $1"
}
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 1afd544..59889f1 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -318,8 +318,8 @@ test_expect_success 'split subdir/ with --rejoin' '
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --rejoin &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --rejoin &&
test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$split_hash'\''"
)
'
@@ -342,7 +342,7 @@ test_expect_success 'split subdir/ with --rejoin and --message' '
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
+ git subtree split --prefix=subdir --message="Split & rejoin" --rejoin &&
test_equal "$(last_commit_message)" "Split & rejoin"
)
'
@@ -365,8 +365,8 @@ test_expect_success 'split subdir/ with --branch' '
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --branch subproj-br &&
test_equal "$(git rev-parse subproj-br)" "$split_hash"
)
'
@@ -390,8 +390,8 @@ test_expect_success 'split subdir/ with --branch for an existing branch' '
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ split_hash=$(git subtree split --prefix=subdir) &&
+ git subtree split --prefix=subdir --branch subproj-br &&
test_equal "$(git rev-parse subproj-br)" "$split_hash"
)
'
@@ -441,7 +441,7 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -452,12 +452,12 @@ test_expect_success 'make sure exactly the right set of files ends up in the sub
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
@@ -491,7 +491,7 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -502,12 +502,12 @@ test_expect_success 'make sure the subproj *only* contains commits that affect t
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
@@ -541,7 +541,7 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -552,12 +552,12 @@ test_expect_success 'make sure exactly the right set of files ends up in the mai
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
@@ -595,7 +595,7 @@ test_expect_success 'make sure each filename changed exactly once in the entire
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -606,12 +606,12 @@ test_expect_success 'make sure each filename changed exactly once in the entire
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
@@ -653,7 +653,7 @@ test_expect_success 'make sure the --rejoin commits never make it into subproj'
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -664,12 +664,12 @@ test_expect_success 'make sure the --rejoin commits never make it into subproj'
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
@@ -701,7 +701,7 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count/subproj" sub3 &&
test_create_commit "$test_count" subdir/main-sub3 &&
@@ -712,12 +712,12 @@ test_expect_success 'make sure no "git subtree" tagged commits make it into subp
test_create_commit "$test_count/subproj" sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
test_create_commit "$test_count" subdir/main-sub4 &&
(
cd "$test_count" &&
- git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ git subtree split --prefix=subdir --branch subproj-br --rejoin
) &&
(
cd "$test_count/subproj" &&
--
1.7.10.4
^ permalink raw reply related
* [PATCH 12/13] contrib/subtree: Handle '--prefix' argument with a slash appended
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng, David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
'git subtree merge' will fail if the argument of '--prefix' has a slash
appended.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/git-subtree.sh | 2 +-
contrib/subtree/t/t7900-subtree.sh | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index c72af95..0493e47 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -82,7 +82,7 @@ while [ $# -gt 0 ]; do
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
- -P) prefix="$1"; shift ;;
+ -P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 769b116..1afd544 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -239,6 +239,25 @@ test_expect_success 'merge new subproj history into subdir/ with --squash and --
)
'
+test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir/ FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir/ FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
+'
+
#
# Tests for 'git subtree split'
#
--
1.7.10.4
^ permalink raw reply related
* [PATCH 10/13] contrib/subtree: Code cleaning and refactoring
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng, David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Mostly prepare for the later tests refactoring.
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/t/t7900-subtree.sh | 270 ++++++++++++++++++------------------
1 file changed, 136 insertions(+), 134 deletions(-)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index e6bcd50..9cfaaf9 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -4,7 +4,7 @@
#
test_description='Basic porcelain support for subtrees
-This test verifies the basic operation of the merge, pull, add
+This test verifies the basic operation of the add, pull, merge
and split subcommands of git subtree.
'
@@ -18,19 +18,6 @@ create()
git add "$1"
}
-
-check_equal()
-{
- test_debug 'echo'
- test_debug "echo \"check a:\" \"{$1}\""
- test_debug "echo \" b:\" \"{$2}\""
- if [ "$1" = "$2" ]; then
- return 0
- else
- return 1
- fi
-}
-
fixnl()
{
t=""
@@ -55,6 +42,42 @@ undo()
git reset --hard HEAD~
}
+test_equal()
+{
+ test_debug 'echo'
+ test_debug "echo \"check a:\" \"{$1}\""
+ test_debug "echo \" b:\" \"{$2}\""
+ if [ "$1" = "$2" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# Make sure no patch changes more than one file.
+# The original set of commits changed only one file each.
+# A multi-file change would imply that we pruned commits
+# too aggressively.
+join_commits()
+{
+ commit=
+ all=
+ while read x y; do
+ if [ -z "$x" ]; then
+ continue
+ elif [ "$x" = "commit:" ]; then
+ if [ -n "$commit" ]; then
+ echo "$commit $all"
+ all=
+ fi
+ commit="$y"
+ else
+ all="$all $y"
+ fi
+ done
+ echo "$commit $all"
+}
+
last_commit_message()
{
git log --pretty=format:%s -1
@@ -97,7 +120,7 @@ test_expect_success 'add main4' '
create main4 &&
git commit -m "main4" &&
git branch -m master mainline &&
- git branch subdir
+ git branch init
'
test_expect_success 'fetch subproj history' '
@@ -105,40 +128,43 @@ test_expect_success 'fetch subproj history' '
git branch sub1 FETCH_HEAD
'
-test_expect_success 'no subtree exists in main tree' '
- test_must_fail git subtree merge --prefix=subdir sub1
-'
-
test_expect_success 'no pull from non-existant subtree' '
test_must_fail git subtree pull --prefix=subdir ./subproj sub1
'
-test_expect_success 'check if --message works for add' '
- git subtree add --prefix=subdir --message="Added subproject" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject" &&
+test_expect_success 'no merge from non-existant subtree' '
+ test_must_fail git subtree merge --prefix=subdir FETCH_HEAD
+'
+
+test_expect_success 'add subproj as subtree into subdir/ with --prefix' '
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''" &&
undo
'
-test_expect_success 'check if --message works as -m and --prefix as -P' '
- git subtree add -P subdir -m "Added subproject using git subtree" sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject using git subtree" &&
+test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '
+ git subtree add --prefix=subdir --message="Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject" &&
undo
'
-test_expect_success 'check if --message works with squash too' '
- git subtree add -P subdir -m "Added subproject with squash" --squash sub1 &&
- check_equal ''"$(last_commit_message)"'' "Added subproject with squash" &&
+test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '
+ git subtree add -P subdir -m "Added subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject" &&
undo
'
-test_expect_success 'add subproj to mainline' '
- git subtree add --prefix=subdir/ FETCH_HEAD &&
- check_equal ''"$(last_commit_message)"'' "Add '"'subdir/'"' from commit '"'"'''"$(git rev-parse sub1)"'''"'"'"
+test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '
+ git subtree add --prefix=subdir --message="Added subproject with squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Added subproject with squash" &&
+ undo
'
-# this shouldn't actually do anything, since FETCH_HEAD is already a parent
-test_expect_success 'merge fetched subproj' '
- git merge -m "merge -s -ours" -s ours FETCH_HEAD
+test_expect_success 'merge the added subproj again, should do nothing' '
+ git subtree add --prefix=subdir FETCH_HEAD &&
+ # this shouldn not actually do anything, since FETCH_HEAD
+ # is already a parent
+ git merge -s ours -m "merge -s -ours" FETCH_HEAD
'
test_expect_success 'add main-sub5' '
@@ -161,25 +187,30 @@ test_expect_success 'fetch new subproj history' '
git branch sub2 FETCH_HEAD
'
-test_expect_success 'check if --message works for merge' '
- git subtree merge --prefix=subdir -m "Merged changes from subproject" sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject" &&
+test_expect_success 'merge new subproj history into subdir/ with --prefix' '
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\'' into mainline" &&
undo
'
-test_expect_success 'check if --message for merge works with squash too' '
- git subtree merge --prefix subdir -m "Merged changes from subproject using squash" --squash sub2 &&
- check_equal ''"$(last_commit_message)"'' "Merged changes from subproject using squash" &&
+test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '
+ git subtree merge --prefix=subdir --message="Merged changes from subproject" FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject" &&
undo
'
-test_expect_success 'merge new subproj history into subdir' '
+test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '
+ git subtree merge --prefix=subdir --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
+ test_equal "$(last_commit_message)" "Merged changes from subproject using squash" &&
+ undo
+'
+
+test_expect_success 'merge new subproj history into subdir/' '
git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split &&
- check_equal ''"$(last_commit_message)"'' "Merge commit '"'"'"$(git rev-parse sub2)"'"'"' into mainline"
+ git branch pre-split
'
-test_expect_success 'Check that prefix argument is required for split' '
+test_expect_success 'split requires option --prefix' '
echo "You must provide the --prefix option." > expected &&
test_must_fail git subtree split > actual 2>&1 &&
test_debug "echo -n expected: " &&
@@ -190,59 +221,56 @@ test_expect_success 'Check that prefix argument is required for split' '
rm -f expected actual
'
-test_expect_success 'Check that the <prefix> exists for a split' '
- echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
+test_expect_success 'split requires path given by option --prefix must exist' '
+ echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
test_debug "echo -n expected: " &&
test_debug "cat expected" &&
test_debug "echo -n actual: " &&
test_debug "cat actual" &&
- test_cmp expected actual
-# rm -f expected actual
+ test_cmp expected actual &&
+ rm -f expected actual
'
-test_expect_success 'check if --message works for split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
- git branch spl1 "$spl1" &&
- check_equal ''"$(last_commit_message)"'' "Split & rejoin" &&
- undo
-'
+test_expect_success 'split subdir/ with --rejoin' '
+ spl1=$(git subtree split --prefix=subdir --annotate="*") &&
+ git branch spl1 "$spl1" &&
+ git subtree split --prefix=subdir --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$spl1'\''" &&
+ undo
+ '
-test_expect_success 'check split with --branch' '
- spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
- check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
+test_expect_success 'split subdir/ with --rejoin and --message' '
+ git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
+ test_equal "$(last_commit_message)" "Split & rejoin" &&
+ undo
'
-test_expect_success 'check hash of split' '
- spl1=$(git subtree split --prefix subdir) &&
- undo &&
- git subtree split --prefix subdir --branch splitbr1test &&
- check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
- git checkout splitbr1test &&
- new_hash=$(git rev-parse HEAD~2) &&
- git checkout mainline &&
- check_equal ''"$new_hash"'' "$subdir_hash"
-'
+test_expect_success 'split subdir/ with --branch' '
+ spl1=$(git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin) &&
+ undo &&
+ git subtree split --prefix=subdir --annotate="*" --branch splitbr1 &&
+ test_equal "$(git rev-parse splitbr1)" "$spl1"
+ '
-test_expect_success 'check split with --branch for an existing branch' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+test_expect_success 'split subdir/ with --branch for an existing branch' '
+ spl1=$(git subtree split --prefix=subdir --annotate="*" --message="Split & rejoin" --rejoin) &&
undo &&
git branch splitbr2 sub1 &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr2 &&
- check_equal ''"$(git rev-parse splitbr2)"'' "$spl1"
+ git subtree split --prefix=subdir --annotate="*" --branch splitbr2 &&
+ test_equal "$(git rev-parse splitbr2)" "$spl1"
'
-test_expect_success 'check split with --branch for an incompatible branch' '
- test_must_fail git subtree split --prefix subdir --onto FETCH_HEAD --branch subdir
+test_expect_success 'split subdir/ with --branch for an incompatible branch' '
+ test_must_fail git subtree split --prefix=subdir --branch init
'
-test_expect_success 'check split+rejoin' '
- spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
+test_expect_success 'check --unannotate' '
+ spl1=$(git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
undo &&
- git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --rejoin &&
- check_equal ''"$(last_commit_message)"'' "Split '"'"'subdir/'"'"' into commit '"'"'"$spl1"'"'"'"
+ git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --branch splitunann &&
+ test_equal "$(git rev-parse splitunann)" "$spl1" &&
+ test_equal "$(git log splitunann | grep subproj)" ""
'
test_expect_success 'add main-sub8' '
@@ -268,8 +296,8 @@ test_expect_success 'add sub9' '
cd ..
test_expect_success 'split for sub8' '
- split2=''"$(git subtree split --annotate='"'*'"' --prefix subdir/ --rejoin)"''
- git branch split2 "$split2"
+ spl2=$(git subtree split --prefix=subdir/ --annotate="*" --rejoin) &&
+ git branch spl2 "$spl2"
'
test_expect_success 'add main-sub10' '
@@ -278,7 +306,7 @@ test_expect_success 'add main-sub10' '
'
test_expect_success 'split for sub10' '
- spl3=''"$(git subtree split --annotate='"'*'"' --prefix subdir --rejoin)"'' &&
+ spl3=$(git subtree split --prefix=subdir --annotate="*" --rejoin) &&
git branch spl3 "$spl3"
'
@@ -299,13 +327,13 @@ chks="sub1 sub2 sub3 sub9"
chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
- subfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$subfiles" "$chkms $chks"
+ subfiles=$(git ls-files | fixnl) &&
+ test_equal "$subfiles" "$chkms $chks"
'
-test_expect_success 'make sure the subproj history *only* contains commits that affect the subdir' '
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" "$chkms $chks"
+test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$chkms $chks"
'
# Back to mainline
@@ -318,25 +346,25 @@ test_expect_success 'pull from subproj' '
'
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
- mainfiles=''"$(git ls-files | fixnl)"'' &&
- check_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ mainfiles=$(git ls-files | fixnl) &&
+ test_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
'
test_expect_success 'make sure each filename changed exactly once in the entire history' '
# main-sub?? and /subdir/main-sub?? both change, because those are the
# changes that were split into their own history. And subdir/sub?? never
# change, since they were *only* changed in the subtree branch.
- allchanges=''"$(git log --name-only --pretty=format:'"''"' | sort | fixnl)"'' &&
- check_equal "$allchanges" ''"$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"''
+ allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
+ test_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
'
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
- check_equal ''"$(git log --pretty=format:'"'%s'"' HEAD^2 | grep -i split)"'' ""
+ test_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
'
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
# They are meaningless to subproj since one side of the merge refers to the mainline
- check_equal ''"$(git log --pretty=format:'"'%s%n%b'"' HEAD^2 | grep "git-subtree.*:")"'' ""
+ test_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
'
# prepare second pair of repositories
@@ -374,7 +402,7 @@ cd ../main
test_expect_success 'add sub as subdir in main' '
git fetch ../sub master &&
git branch sub2 FETCH_HEAD &&
- git subtree add --prefix subdir sub2
+ git subtree add --prefix=subdir sub2
'
cd ../sub
@@ -389,7 +417,7 @@ cd ../main
test_expect_success 'merge from sub' '
git fetch ../sub master &&
git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix subdir sub3
+ git subtree merge --prefix=subdir sub3
'
test_expect_success 'add main-sub4' '
@@ -398,7 +426,7 @@ test_expect_success 'add main-sub4' '
'
test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix subdir --branch mainsub4
+ git subtree split --prefix=subdir --branch mainsub4
'
# at this point, the new commit parent should be sub3 if it is not,
@@ -407,7 +435,7 @@ test_expect_success 'split for main-sub4 without --onto' '
# itself)
test_expect_success 'check that the commit parent is sub3' '
- check_equal ''"$(git log --pretty=format:%P -1 mainsub4)"'' ''"$(git rev-parse sub3)"''
+ test_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
'
test_expect_success 'add main-sub5' '
@@ -420,49 +448,23 @@ test_expect_success 'split for main-sub5 without --onto' '
# also test that we still can split out an entirely new subtree
# if the parent of the first commit in the tree is not empty,
# then the new subtree has accidently been attached to something
- git subtree split --prefix subdir2 --branch mainsub5 &&
- check_equal ''"$(git log --pretty=format:%P -1 mainsub5)"'' ""
+ git subtree split --prefix=subdir2 --branch mainsub5 &&
+ test_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
'
-# make sure no patch changes more than one file. The original set of commits
-# changed only one file each. A multi-file change would imply that we pruned
-# commits too aggressively.
-joincommits()
-{
- commit=
- all=
- while read x y; do
- #echo "{$x}" >&2
- if [ -z "$x" ]; then
- continue
- elif [ "$x" = "commit:" ]; then
- if [ -n "$commit" ]; then
- echo "$commit $all"
- all=
- fi
- commit="$y"
- else
- all="$all $y"
- fi
- done
- echo "$commit $all"
-}
-
test_expect_success 'verify one file change per commit' '
x= &&
- list=''"$(git log --pretty=format:'"'commit: %H'"' | joincommits)"'' &&
-# test_debug "echo HERE" &&
-# test_debug "echo ''"$list"''" &&
- (git log --pretty=format:'"'commit: %H'"' | joincommits |
- ( while read commit a b; do
- test_debug "echo Verifying commit "''"$commit"''
- test_debug "echo a: "''"$a"''
- test_debug "echo b: "''"$b"''
- check_equal "$b" ""
+ git log --pretty=format:"commit: %H" | join_commits |
+ (
+ while read commit a b; do
+ test_debug "echo Verifying commit $commit"
+ test_debug "echo a: $a"
+ test_debug "echo b: $b"
+ test_equal "$b" ""
x=1
done
- check_equal "$x" 1
- ))
+ test_equal "$x" 1
+ )
'
test_done
--
1.7.10.4
^ permalink raw reply related
* [PATCH 11/13] contrib/subtree: Make each test self-contained
From: David A. Greene @ 2013-02-05 11:36 UTC (permalink / raw)
To: git; +Cc: Techlive Zheng, David A. Greene
In-Reply-To: <1360064219-28789-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
---
contrib/subtree/t/t7900-subtree.sh | 871 +++++++++++++++++++++++++-----------
1 file changed, 613 insertions(+), 258 deletions(-)
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 9cfaaf9..769b116 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -12,12 +12,6 @@ export TEST_DIRECTORY=$(pwd)/../../../t
. ../../../t/test-lib.sh
-create()
-{
- echo "$1" >"$1"
- git add "$1"
-}
-
fixnl()
{
t=""
@@ -37,11 +31,6 @@ multiline()
done
}
-undo()
-{
- git reset --hard HEAD~
-}
-
test_equal()
{
test_debug 'echo'
@@ -78,381 +67,746 @@ join_commits()
echo "$commit $all"
}
+test_create_commit() (
+ repo=$1
+ commit=$2
+ cd "$repo"
+ mkdir -p "$(dirname "$commit")"
+ echo "$commit" > "$commit"
+ git add "$commit"
+ git commit -m "$commit"
+)
+
last_commit_message()
{
git log --pretty=format:%s -1
}
-test_expect_success 'init subproj' '
- test_create_repo subproj
-'
-
-# To the subproject!
-cd subproj
-
-test_expect_success 'add sub1' '
- create sub1 &&
- git commit -m "sub1" &&
- git branch sub1 &&
- git branch -m master subproj
-'
-
-# Save this hash for testing later.
-
-subdir_hash=`git rev-parse HEAD`
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2" &&
- git branch sub2
-'
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3" &&
- git branch sub3
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'add main4' '
- create main4 &&
- git commit -m "main4" &&
- git branch -m master mainline &&
- git branch init
-'
+#
+# Tests for 'git subtree add'
+#
-test_expect_success 'fetch subproj history' '
- git fetch ./subproj sub1 &&
- git branch sub1 FETCH_HEAD
-'
test_expect_success 'no pull from non-existant subtree' '
- test_must_fail git subtree pull --prefix=subdir ./subproj sub1
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ test_must_fail git subtree pull --prefix=subdir ./subproj master
+ )
'
test_expect_success 'no merge from non-existant subtree' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
test_must_fail git subtree merge --prefix=subdir FETCH_HEAD
+ )
'
test_expect_success 'add subproj as subtree into subdir/ with --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree add --prefix=subdir FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''" &&
- undo
+ test_equal "$(last_commit_message)" "Add '\''subdir/'\'' from commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
'
test_expect_success 'add subproj as subtree into subdir/ with --prefix and --message' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree add --prefix=subdir --message="Added subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject" &&
- undo
+ test_equal "$(last_commit_message)" "Added subproject"
+ )
'
test_expect_success 'add subproj as subtree into subdir/ with --prefix as -P and --message as -m' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree add -P subdir -m "Added subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject" &&
- undo
+ test_equal "$(last_commit_message)" "Added subproject"
+ )
'
test_expect_success 'add subproj as subtree into subdir/ with --squash and --prefix and --message' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree add --prefix=subdir --message="Added subproject with squash" --squash FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Added subproject with squash" &&
- undo
+ test_equal "$(last_commit_message)" "Added subproject with squash"
+ )
'
test_expect_success 'merge the added subproj again, should do nothing' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree add --prefix=subdir FETCH_HEAD &&
# this shouldn not actually do anything, since FETCH_HEAD
# is already a parent
git merge -s ours -m "merge -s -ours" FETCH_HEAD
+ )
'
-test_expect_success 'add main-sub5' '
- create subdir/main-sub5 &&
- git commit -m "subproj: main-sub5"
-'
-
-test_expect_success 'add main6' '
- create main6 &&
- git commit -m "main6 boring"
-'
-
-test_expect_success 'add main-sub7' '
- create subdir/main-sub7 &&
- git commit -m "subproj: main-sub7"
-'
-
-test_expect_success 'fetch new subproj history' '
- git fetch ./subproj sub2 &&
- git branch sub2 FETCH_HEAD
-'
+#
+# Tests for 'git subtree merge'
+#
test_expect_success 'merge new subproj history into subdir/ with --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree merge --prefix=subdir FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\'' into mainline" &&
- undo
+ test_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
+ )
'
test_expect_success 'merge new subproj history into subdir/ with --prefix and --message' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree merge --prefix=subdir --message="Merged changes from subproject" FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merged changes from subproject" &&
- undo
+ test_equal "$(last_commit_message)" "Merged changes from subproject"
+ )
'
test_expect_success 'merge new subproj history into subdir/ with --squash and --prefix and --message' '
+ test_create_repo "$test_count/subproj" &&
+ test_create_repo "$test_count" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
git subtree merge --prefix=subdir --message="Merged changes from subproject using squash" --squash FETCH_HEAD &&
- test_equal "$(last_commit_message)" "Merged changes from subproject using squash" &&
- undo
+ test_equal "$(last_commit_message)" "Merged changes from subproject using squash"
+ )
'
-test_expect_success 'merge new subproj history into subdir/' '
- git subtree merge --prefix=subdir FETCH_HEAD &&
- git branch pre-split
-'
+#
+# Tests for 'git subtree split'
+#
test_expect_success 'split requires option --prefix' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
echo "You must provide the --prefix option." > expected &&
test_must_fail git subtree split > actual 2>&1 &&
test_debug "echo -n expected: " &&
test_debug "cat expected" &&
test_debug "echo -n actual: " &&
test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ test_cmp expected actual
+ )
'
test_expect_success 'split requires path given by option --prefix must exist' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD &&
echo "'\''non-existent-directory'\'' does not exist; use '\''git subtree add'\''" > expected &&
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
test_debug "echo -n expected: " &&
test_debug "cat expected" &&
test_debug "echo -n actual: " &&
test_debug "cat actual" &&
- test_cmp expected actual &&
- rm -f expected actual
+ test_cmp expected actual
+ )
'
test_expect_success 'split subdir/ with --rejoin' '
- spl1=$(git subtree split --prefix=subdir --annotate="*") &&
- git branch spl1 "$spl1" &&
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
git subtree split --prefix=subdir --annotate="*" --rejoin &&
- test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$spl1'\''" &&
- undo
+ test_equal "$(last_commit_message)" "Split '\''subdir/'\'' into commit '\''$split_hash'\''"
+ )
'
test_expect_success 'split subdir/ with --rejoin and --message' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin &&
- test_equal "$(last_commit_message)" "Split & rejoin" &&
- undo
+ test_equal "$(last_commit_message)" "Split & rejoin"
+ )
'
test_expect_success 'split subdir/ with --branch' '
- spl1=$(git subtree split --prefix=subdir --message="Split & rejoin" --annotate="*" --rejoin) &&
- undo &&
- git subtree split --prefix=subdir --annotate="*" --branch splitbr1 &&
- test_equal "$(git rev-parse splitbr1)" "$spl1"
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ test_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
'
test_expect_success 'split subdir/ with --branch for an existing branch' '
- spl1=$(git subtree split --prefix=subdir --annotate="*" --message="Split & rejoin" --rejoin) &&
- undo &&
- git branch splitbr2 sub1 &&
- git subtree split --prefix=subdir --annotate="*" --branch splitbr2 &&
- test_equal "$(git rev-parse splitbr2)" "$spl1"
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git branch subproj-br FETCH_HEAD &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ split_hash=$(git subtree split --prefix=subdir --annotate="*") &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br &&
+ test_equal "$(git rev-parse subproj-br)" "$split_hash"
+ )
'
test_expect_success 'split subdir/ with --branch for an incompatible branch' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git branch init HEAD &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
test_must_fail git subtree split --prefix=subdir --branch init
+ )
'
-test_expect_success 'check --unannotate' '
- spl1=$(git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
- undo &&
- git subtree split --unannotate="subproj:" --prefix subdir --onto FETCH_HEAD --branch splitunann &&
- test_equal "$(git rev-parse splitunann)" "$spl1" &&
- test_equal "$(git log splitunann | grep subproj)" ""
-'
-
-test_expect_success 'add main-sub8' '
- create subdir/main-sub8 &&
- git commit -m "main-sub8"
-'
-
-# To the subproject!
-cd ./subproj
-
-test_expect_success 'merge split into subproj' '
- git fetch .. spl1 &&
- git branch spl1 FETCH_HEAD &&
- git merge FETCH_HEAD
-'
-
-test_expect_success 'add sub9' '
- create sub9 &&
- git commit -m "sub9"
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'split for sub8' '
- spl2=$(git subtree split --prefix=subdir/ --annotate="*" --rejoin) &&
- git branch spl2 "$spl2"
-'
-
-test_expect_success 'add main-sub10' '
- create subdir/main-sub10 &&
- git commit -m "main-sub10"
-'
-
-test_expect_success 'split for sub10' '
- spl3=$(git subtree split --prefix=subdir --annotate="*" --rejoin) &&
- git branch spl3 "$spl3"
-'
-
-# To the subproject!
-cd ./subproj
-
-test_expect_success 'merge split into subproj' '
- git fetch .. spl3 &&
- git branch spl3 FETCH_HEAD &&
- git merge FETCH_HEAD &&
- git branch subproj-merge-spl3
-'
-
-chkm="main4 main6"
-chkms="main-sub10 main-sub5 main-sub7 main-sub8"
-chkms_sub=$(echo $chkms | multiline | sed 's,^,subdir/,' | fixnl)
-chks="sub1 sub2 sub3 sub9"
-chks_sub=$(echo $chks | multiline | sed 's,^,subdir/,' | fixnl)
+#
+# Validity checking
+#
test_expect_success 'make sure exactly the right set of files ends up in the subproj' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD &&
+
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+
subfiles=$(git ls-files | fixnl) &&
test_equal "$subfiles" "$chkms $chks"
+ )
'
test_expect_success 'make sure the subproj *only* contains commits that affect the subdir' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD &&
+
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+
allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
test_equal "$allchanges" "$chkms $chks"
-'
-
-# Back to mainline
-cd ..
-
-test_expect_success 'pull from subproj' '
- git fetch ./subproj subproj-merge-spl3 &&
- git branch subproj-merge-spl3 FETCH_HEAD &&
- git subtree pull --prefix=subdir ./subproj subproj-merge-spl3
+ )
'
test_expect_success 'make sure exactly the right set of files ends up in the mainline' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
+ chkm="main1 main2" &&
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
mainfiles=$(git ls-files | fixnl) &&
test_equal "$mainfiles" "$chkm $chkms_sub $chks_sub"
+ )
'
test_expect_success 'make sure each filename changed exactly once in the entire history' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
+ chkm="main1 main2" &&
+ chks="sub1 sub2 sub3 sub4" &&
+ chks_sub=$(echo $chks | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+ chkms="main-sub1 main-sub2 main-sub3 main-sub4" &&
+ chkms_sub=$(echo $chkms | multiline | sed '\''s,^,subdir/,'\'' | fixnl) &&
+
# main-sub?? and /subdir/main-sub?? both change, because those are the
# changes that were split into their own history. And subdir/sub?? never
# change, since they were *only* changed in the subtree branch.
allchanges=$(git log --name-only --pretty=format:"" | sort | fixnl) &&
test_equal "$allchanges" "$(echo $chkms $chkm $chks $chkms_sub | multiline | sort | fixnl)"
+ )
'
test_expect_success 'make sure the --rejoin commits never make it into subproj' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
test_equal "$(git log --pretty=format:"%s" HEAD^2 | grep -i split)" ""
+ )
'
test_expect_success 'make sure no "git subtree" tagged commits make it into subproj' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ test_create_commit "$test_count" main2 &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ test_create_commit "$test_count" subdir/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count/subproj" sub3 &&
+ test_create_commit "$test_count" subdir/main-sub3 &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub4 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --annotate="*" --branch subproj-br --rejoin
+ ) &&
+ (
+ cd "$test_count/subproj" &&
+ git fetch .. subproj-br && git merge FETCH_HEAD
+ ) &&
+ (
+ cd "$test_count" &&
+ git subtree pull --prefix=subdir ./subproj master &&
+
# They are meaningless to subproj since one side of the merge refers to the mainline
test_equal "$(git log --pretty=format:"%s%n%b" HEAD^2 | grep "git-subtree.*:")" ""
+ )
'
-# prepare second pair of repositories
-mkdir test2
-cd test2
-
-test_expect_success 'init main' '
- test_create_repo main
-'
-
-cd main
-
-test_expect_success 'add main1' '
- create main1 &&
- git commit -m "main1"
-'
-
-cd ..
-
-test_expect_success 'init sub' '
- test_create_repo sub
-'
-
-cd sub
-
-test_expect_success 'add sub2' '
- create sub2 &&
- git commit -m "sub2"
-'
-
-cd ../main
-
-# check if split can find proper base without --onto
-
-test_expect_success 'add sub as subdir in main' '
- git fetch ../sub master &&
- git branch sub2 FETCH_HEAD &&
- git subtree add --prefix=subdir sub2
-'
-
-cd ../sub
-
-test_expect_success 'add sub3' '
- create sub3 &&
- git commit -m "sub3"
-'
-
-cd ../main
-
-test_expect_success 'merge from sub' '
- git fetch ../sub master &&
- git branch sub3 FETCH_HEAD &&
- git subtree merge --prefix=subdir sub3
-'
-
-test_expect_success 'add main-sub4' '
- create subdir/main-sub4 &&
- git commit -m "main-sub4"
-'
-
-test_expect_success 'split for main-sub4 without --onto' '
- git subtree split --prefix=subdir --branch mainsub4
-'
-
-# at this point, the new commit parent should be sub3 if it is not,
-# something went wrong (the "newparent" of "master~" commit should
-# have been sub3, but it was not, because its cache was not set to
-# itself)
-
-test_expect_success 'check that the commit parent is sub3' '
- test_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
-'
+#
+# A new set of tests
+#
-test_expect_success 'add main-sub5' '
- mkdir subdir2 &&
- create subdir2/main-sub5 &&
- git commit -m "main-sub5"
-'
+test_expect_success 'make sure "git subtree split" find the correct parent' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git branch subproj-ref FETCH_HEAD &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br &&
+
+ # at this point, the new commit parent should be subproj-ref, if it is
+ # not, something went wrong (the "newparent" of "master~" commit should
+ # have been sub2, but it was not, because its cache was not set to
+ # itself)
+ test_equal "$(git log --pretty=format:%P -1 subproj-br)" "$(git rev-parse subproj-ref)"
+ )
+'
+
+test_expect_success 'split a new subtree without --onto option' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree add --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br
+ ) &&
+ test_create_commit "$test_count" subdir2/main-sub2 &&
+ (
+ cd "$test_count" &&
-test_expect_success 'split for main-sub5 without --onto' '
# also test that we still can split out an entirely new subtree
# if the parent of the first commit in the tree is not empty,
# then the new subtree has accidently been attached to something
- git subtree split --prefix=subdir2 --branch mainsub5 &&
- test_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
+ git subtree split --prefix=subdir2 --branch subproj2-br &&
+ test_equal "$(git log --pretty=format:%P -1 subproj2-br)" ""
+ )
'
test_expect_success 'verify one file change per commit' '
+ test_create_repo "$test_count" &&
+ test_create_repo "$test_count/subproj" &&
+ test_create_commit "$test_count" main1 &&
+ test_create_commit "$test_count/subproj" sub1 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git branch sub1 FETCH_HEAD &&
+ git subtree add --prefix=subdir sub1
+ ) &&
+ test_create_commit "$test_count/subproj" sub2 &&
+ (
+ cd "$test_count" &&
+ git fetch ./subproj master &&
+ git subtree merge --prefix=subdir FETCH_HEAD
+ ) &&
+ test_create_commit "$test_count" subdir/main-sub1 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir --branch subproj-br
+ ) &&
+ test_create_commit "$test_count" subdir2/main-sub2 &&
+ (
+ cd "$test_count" &&
+ git subtree split --prefix=subdir2 --branch subproj2-br &&
+
x= &&
git log --pretty=format:"commit: %H" | join_commits |
(
@@ -465,6 +819,7 @@ test_expect_success 'verify one file change per commit' '
done
test_equal "$x" 1
)
+ )
'
test_done
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] Get correct column with for options in command usage
From: Duy Nguyen @ 2013-02-05 12:15 UTC (permalink / raw)
To: Jiang Xin; +Cc: Junio C Hamano, Git List
In-Reply-To: <0b035132df6de2cac56ac59d66b04f30e90ad760.1360049671.git.worldhello.net@gmail.com>
On Tue, Feb 05, 2013 at 03:40:32PM +0800, Jiang Xin wrote:
> Command usage would not align well if command options are translated,
> especially to CJK. Call utf8_strwidth in function usage_argh, so that
> the caller will get correct column width.
Yeah, I just noticed a misalignment in Vietnamese translation (just
two spaces to the left, hard to notice unless paying attention).
> static int usage_argh(const struct option *opts, FILE *outfile)
> {
> - const char *s;
> + const char *s, *p;
> int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh;
> if (opts->flags & PARSE_OPT_OPTARG)
> if (opts->long_name)
> @@ -482,7 +482,9 @@ static int usage_argh(const struct option *opts, FILE *outfile)
> s = literal ? "[%s]" : "[<%s>]";
> else
> s = literal ? " %s" : " <%s>";
> - return fprintf(outfile, s, opts->argh ? _(opts->argh) : _("..."));
> + p = opts->argh ? _(opts->argh) : _("...");
> + fprintf(outfile, s, p);
> + return utf8_strwidth(p) + strlen(s) - 2;
> }
First of all, #include "utf8.h" is required for utf8_strwidth().
The "strlen(s) - 2" is quite sensitive to how "s" is written. How
about this? A bit longer but clearer. Your version is OK too with a
comment explaining "strlen(s) - 2".
-- 8< --
diff --git a/parse-options.c b/parse-options.c
index 67e98a6..0f803bd 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -474,6 +474,8 @@ int parse_options(int argc, const char **argv, const char *prefix,
static int usage_argh(const struct option *opts, FILE *outfile)
{
const char *s;
+ struct strbuf sb = STRBUF_INIT;
+ int columns;
int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh;
if (opts->flags & PARSE_OPT_OPTARG)
if (opts->long_name)
@@ -482,7 +484,11 @@ static int usage_argh(const struct option *opts, FILE *outfile)
s = literal ? "[%s]" : "[<%s>]";
else
s = literal ? " %s" : " <%s>";
- return fprintf(outfile, s, opts->argh ? _(opts->argh) : _("..."));
+ strbuf_addf(&sb, s, opts->argh ? _(opts->argh) : _("..."));
+ fprintf(outfile, sb.buf);
+ columns = utf8_strwidth(sb.buf);
+ strbuf_release(&sb);
+ return columns;
}
#define USAGE_OPTS_WIDTH 24
-- 8< --
While looking at parse-options.c, I notice "-NUM" is not marked for
translation. I think you might want to mark it so that you can
translate "NUM" to a similar abbreviation in a local language. A
similar patch like this is required so we get columns for "-NUM"
translation instead of the number of bytes.
--
Duy
^ permalink raw reply related
* Re: [PATCH] Get correct column with for options in command usage
From: Duy Nguyen @ 2013-02-05 12:18 UTC (permalink / raw)
To: Jiang Xin; +Cc: Junio C Hamano, Git List
In-Reply-To: <20130205121552.GA16601@lanh>
On Tue, Feb 5, 2013 at 7:15 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> + fprintf(outfile, sb.buf);
Use fputs instead. I looked up fputs man page but somehow still left
fprintf there.
--
Duy
^ permalink raw reply
* Re: [PATCH v3] status: show the branch name if possible in in-progress info
From: Duy Nguyen @ 2013-02-05 12:20 UTC (permalink / raw)
To: Jonathan Nieder, Junio C Hamano; +Cc: git, Matthieu Moy
In-Reply-To: <20130205063847.GA3240@elie.Belkin>
On Tue, Feb 5, 2013 at 1:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Missing description. Stealing from the link you sent:
>
> The typical use-case is starting a rebase, do something else, come back
> the day after, run "git status" or make a new commit and wonder what
> in the world's going on. Which branch is being rebased is probably the
> most useful tidbit to help, but the target may help too.
>
> Ideally, I would have loved to see "rebasing master on origin/master",
> but the target ref name is not stored during rebase, so this patch
> writes "rebasing master on a78c8c98b" as a half-measure to remind
> future users of that potential improvement.
>
> Signed-off-by: <...>
Looking good. Junio, do you need a new patch mail or can you just
amend the commit message?
--
Duy
^ permalink raw reply
* Re: [PATCH 13/13] contrib/subtree: Remove --annotate
From: James Nylen @ 2013-02-05 13:27 UTC (permalink / raw)
To: greened
Cc: Junio C Hamano, git, Techlive Zheng, Wayne Walter,
Avery Pennarun "
In-Reply-To: <87pq0frnmb.fsf@waller.obbligato.org>
On Tue, Feb 5, 2013 at 6:44 AM, <greened@obbligato.org> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>>> Remove --annotate. This obviates the need for an --unannotate
>>> command. We really want a more generalized commit message rewrite
>>> mechanism.
>>
>> That may be a good goal as the end result, but wouldn't it be a bit
>> unhelpful to remove these before adding such a "more generalized"
>> mechanism to replace them?
>
> I did think about that. I sent out an e-mail some time ago asking for
> opinions on this. No one responded. Since this is in contrib/ I feel
> comfortable getting rid of this option early so that people don't get
> too attached to it. :)
I don't agree that removing `--annotate` obviates the need for `--unannotate`.
I responded on 1/17 with what I think is a typical and normal use case
for that option:
- add "fancylib" as a subtree of "myprog"
- commit to "myprog" repo: "fancylib: don't crash as much"
- split these commits back out to "fancylib" main repo, and remove
the "fancylib: " prefix
In my opinion this is a pretty normal workflow. Commits to "fancylib"
in the "myprog" repo are prefixed with "fancylib: ", and that prefix
becomes redundant and should be removed if those commits are split
back out into the "fancylib" main repo.
I also tried to come up with another situation that would justify a
more general commit message rewriting facility, and I couldn't think
of any other good use cases that don't involve removing a prefix. But
that doesn't mean there aren't any.
`--unannotate` is a clunky name, but I think this functionality is
worth taking another look at. Maybe it could be called
`--remove-prefix` ?
^ permalink raw reply
* Re: [PATCH] Add contrib/credentials/netrc with GPG support, try #2
From: Ted Zlatanov @ 2013-02-05 13:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, git
In-Reply-To: <7vmwvjzkcs.fsf@alter.siamese.dyndns.org>
On Mon, 04 Feb 2013 16:15:47 -0800 Junio C Hamano <gitster@pobox.com> wrote:
JCH> Ted Zlatanov <tzz@lifelogs.com> writes:
>> - do you want to support backslashed newlines?
JCH> What for? netrc/authinfo is not a line oriented file format at all,
JCH> and
JCH> machine k.org
JCH> login me
JCH> password mysecret
JCH> is a single entry; you do not need backslash at the end of any line.
Hmm. The parser I implemented only does single-line parsing, and I
misunderstood the format to be single-line (partly because I have never
seen anyone using the multi-line format you show). Looking at
Net::Netrc more carefully, it seems that the "machine" token is what
defines an entry, so a new entry starts with a new line that contains a
"machine" token. Is that acceptable and does it match your
understanding of the format? It matches Net::Netrc, at least.
I'll add this change to PATCHv4 with the assumption you agree.
>> - should all die() calls just print to STDERR and exit(0)?
JCH> Where "when unhandled, the helper should silently exit with 0" is
JCH> expected by the invoker, we shouldn't say anything to error stream,
JCH> and exit with zero. Please leave a comment to make it easy to
JCH> understand to the readers that is what is going on there.
JCH> If on the other hand it diagnosed an error (not a bug in the
JCH> implementation but a misconfiguration on the user's side), I _think_
JCH> it should loudly die() so that the user can notice and take
JCH> corrective action.
OK, I'll review these for PATCHv4 (also see below). Thanks.
>> - do you want to support multiple netrc files, as you and Peff suggested?
JCH> I didn't even suggest such thing IIRC---I expected it to iterate
JCH> from the most desirable (.authinfo.gpg) to the least (.netrc) and
JCH> stop at the first found one. There may be use cases people use more
JCH> than one and expect an entry to be found in any file, but I suspect
JCH> that might be more confusing than it is worth. But I do not care
JCH> very deeply myself either way.
After thinking about it, I agree with Peff multiple sources make sense
and will simplify the code flow (especially the default case, which
won't need to be handled separately). And the functionality doesn't
have to be confusing with the right debugging messages. So I'll add
them in PATCHv4.
The debugging messages will be fewer and simpler with this approach,
which makes it feel like the right track :)
Thanks
Ted
^ permalink raw reply
* Re: [RFC] Should "log --cc" imply "log --cc -p"?
From: Ævar Arnfjörð Bjarmason @ 2013-02-05 14:27 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Michael J Gruber, git
In-Reply-To: <20130205112249.GE24973@sigill.intra.peff.net>
On Tue, Feb 5, 2013 at 12:22 PM, Jeff King <peff@peff.net> wrote:
> On Tue, Feb 05, 2013 at 11:16:52AM +0100, Ævar Arnfjörð Bjarmason wrote:
>
>> On Mon, Feb 4, 2013 at 5:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> > "git log/diff-files -U8" do not need "-p" to enable textual patches,
>> > for example. It is "I already told you that I want 8-line context.
>> > For what else, other than showing textual diff, do you think I told
>> > you that for?" and replacing "8-line context" with various other
>> > options that affect patch generation will give us a variety of end
>> > user complaints that would tell us that C) is more intuitive to
>> > them.
>>
>> On a related note I think "--full-diff" should imply "-p" too.
>
> I don't think that is in the same class. --full-diff is quite useful for
> many other diff formats. E.g.:
>
> git log --full-diff --raw Makefile
>
> If you are proposing to default to "-p" when "--full-diff" is used but
> no format is given, that is a slightly different thing. The --full-diff
> in such a case is indeed useless, but I do not think it necessarily
> follows that "-p" was what the user wanted.
You're right. I didn't notice that it could work with other things besides -p.
On a related note then, it's a bit confusing that it's called
"--full-diff" when it doesn't actually show a diff.
^ permalink raw reply
* Re: Feature request: Allow extracting revisions into directories
From: Phil Hord @ 2013-02-05 15:11 UTC (permalink / raw)
To: Sitaram Chamarty; +Cc: Robert Clausecker, git@vger.kernel.org
In-Reply-To: <510F03FC.6080501@gmail.com>
On Sun, Feb 3, 2013 at 7:42 PM, Sitaram Chamarty <sitaramc@gmail.com> wrote:
> On 02/03/2013 11:41 PM, Robert Clausecker wrote:
>>
>> Am Sonntag, den 03.02.2013, 21:55 +0530 schrieb Sitaram Chamarty:
>>> Could you help me understand why piping it to tar (actually 'tar -C
>>> /dest/dir -x') is not sufficient to achieve what you want?
>>
>> Piping the output of git archive into tar is of course a possible
>> solution; I just don't like the fact that you need to pipe the output
>> into a separate program to do something that should be possible with a
>> simple switch and not an extra command. It feels unintuitive and like a
>> workaround to make an archive just to unpack it on-the-fly. Also, adding
>> such a command (or at least documenting the way to do this using a pipe
>> to tar somewhere in the man pages) is a small and simple change that
>> improves usability.
>
> I realise it appears to be the fashion these days to get away from the
> Unix philosophy of having different tools do different things and
> combining them as needed.
>
> Ignoring the option-heavy GNU, and looking at the more traditional BSD
> tar manpage [1], I notice the following flags that could still be
> potentially needed by someone running 'git archive': '-t' (instead of
> '-x'), '-C dir', '--exclude/include', '-k', '-m', '--numeric-owner', -o,
> -P, -p, -q, -s, -T, -U, -v, -w, and -X.
OP did not ask about tar so I do not see why any of these tar options
are relevant. It seems like what he really wants is 'git archive
--format=native' , maybe. You can almost create this option by
saying
git config tar.native.command "tar -x"
except that you do not get the opportunity to specify a target directory.
But maybe he really wants a form of 'git checkout' instead.
> And I'm ignoring the esoteric ones like "--chroot" and "-S" (sparse mode).
>
> How many of these options would you like included in git? And if you
> say "I don't need any of those; I just need '-x'", that's not relevant.
> Someone else may need any or all of those flags, and if you accept "-x"
> you have to accept some of the others too.
This is only true if you cannot stop yourself from thinking about
'tar'. What about zip, for example?
I think none of these options is relevant.
> Also, I often want to deploy to a different host, and I might do that
> like so:
>
> git archive ... | ssh host tar -C /deploy/dir -x
>
> Why not put that ssh functionality into git also?
This slippery-slope argument is growing tiresome.
Phil
p.s. Conceded: OP set off this avalanche by disparaging the vaunted
PIPE operation.
^ permalink raw reply
* Re: [PATCH 11/13] contrib/subtree: Make each test self-contained
From: Junio C Hamano @ 2013-02-05 15:18 UTC (permalink / raw)
To: greened
Cc: James Nylen, git, Techlive Zheng, Wayne Walter, Avery Pennarun,
Jakub Suder, John Yani, David A. Greene
In-Reply-To: <87d2wfrnbe.fsf@waller.obbligato.org>
greened@obbligato.org writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> "David A. Greene" <greened@obbligato.org> writes:
>>
>>> +test_create_commit() (
>>> + repo=$1
>>> + commit=$2
>>> + cd "$repo"
>>> + mkdir -p "$(dirname "$commit")"
>>> + echo "$commit" > "$commit"
>>
>> Style.
>
> I need a little more explanation. :) Is there a style guide somewhere?
Documentation/CodingGuidelines?
>
>>> + git add "$commit"
>>> + git commit -m "$commit"
>>> +)
>>
>> Very nice, but don't we want to check for possible errors in any of
>> the above commands?
>
> I'll fix that. :)
> ...
> Ok. I'll rework this.
Thanks.
I also think it would be a good idea for you to learn to push back
to the original authors; fixing problems in patches by others, while
is a good way to learn how their thinking process went, is not
necessarily fun.
^ permalink raw reply
* Re: [PATCH v3 3/8] upload/receive-pack: allow hiding ref hierarchies
From: Junio C Hamano @ 2013-02-05 15:45 UTC (permalink / raw)
To: Jeff King; +Cc: git, Shawn Pearce
In-Reply-To: <20130205085047.GA24973@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Wed, Jan 30, 2013 at 10:45:37AM -0800, Junio C Hamano wrote:
>
>> Teach upload-pack and receive-pack to omit some refs from their
>> initial advertisements by paying attention to the transfer.hiderefs
>> multi-valued configuration variable. Any ref that is under the
>> hierarchies listed on the value of this variable is excluded from
>> responses to requests made by "ls-remote", "fetch", "clone", "push",
>> etc.
>>
>> A typical use case may be
>>
>> [transfer]
>> hiderefs = refs/pull
>>
>> to hide the refs that are internally used by the hosting site and
>> should not be exposed over the network.
>
> In the earlier review, I mentioned making this per-service, but I see
> that is not the case here. Do you have an argument against doing so?
Perhaps then I misunderstood your intention. By reminding me of the
receive-pack side, I thought you were hinting to unify these two
into one, which I did. There is no argument against it.
> And I
> have not seen complaints about the current system.
Immediately after I added github to the set of places I push into,
which I think is long before you joined GitHub, I noticed that _my_
repository gets contaminated by second rate commits called pull
requests, and I may even have complained, but most likely I didn't,
as I could easily tell that, even though I know it is _not_ the only
way, nor even the best way [*1*], to implement the GitHub's pull
request workflow, I perfectly well understood that it would be the
most expedient way for GitHub folks to implement this feature.
I think you should take lack of complaints with a huge grain of
salt. It does not suggest much.
> Gerrit's refs/changes may be a different story, if they have a large
> enough number of them to make upload-pack's ref advertisement
> overwhelming.
This is probably a stale count, but platform/frameworks/base part of
AOSP has 3200+ refs; the corresponding repository internal to Google
has 60k+ refs (this is because there are many in-between states
recorded in the internal repository, even though the end result
published to the open source repository may be the same) and results
in ~4MB advertisement. Which is fairly significant when all you are
interested in doing is an "Am I up to date?" poll.
[Footnote]
*1* From the ownership point of view, objects that are only
reachable from these refs/pull/* refs do *not* belong to the
requestee, until the requestee chooses to accept the changes.
A malicious requestor can fork your repository, add an objectionable
blob to it, and throw a pull request at you. GitHub shows that the
blob now belongs to your repository, so the requestor turns around
and file a DMCA takedown complaint against your repository. A
clueful judge would then agree with the complaint after running a
"clone --mirror" and seeing the blob in your repository. Oops?
A funny thing is that you cannot "push :refs/pull/1/head" to remove
it anymore (I think in the early days, I took them out by doing this
a few times, but I may be misremembering), so you cannot make
yourself into compliance, even though you are not the offending
party. Your repository is held responsible for whatever the rogue
requestor added. That is not very nice, is it?
In an ideal world, I would have chosen to create a dedicated fork
managed by the hosting company (i.e. GitHub) for your repository
whose only purpose is to house these refs/pull/ refs (the hosting
site is ultimately who has to respond to DMCA notices anyway, and an
arrangement like this makes it clear who is reponsible for what).
The e-mail sent to you to let you know about outstanding pull
requests and the web UI could just point at that forked repository,
not your own (you also could choose to leave the outging pull
requests in the requestor's repository, but that is only OK if you
do not worry about (1) a requestor sending a pull request, then
updating the branch the pull request talks about later, to trick you
with bait-and-switch, or (2) a requestor sending a pull request,
thinks he is done with the topic and removes the repository).
^ permalink raw reply
* Re: [RFC] Should "log --cc" imply "log --cc -p"?
From: Junio C Hamano @ 2013-02-05 15:46 UTC (permalink / raw)
To: Jeff King; +Cc: Michael J Gruber, git
In-Reply-To: <20130205093307.GC24973@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> git log --cc --stat
>
> the "--cc" is significant. So I don't think it is right for "--cc" to
> always imply "-p". But if the rule kicked in only when no other format
> had been specified, that might make sense.
Yes, it was my mistake that I left it unsaid. Obviously the
description of the "minor irritation" must be qualified with "unless
no other output options like --raw, --stat, etc. are given".
Thanks.
^ permalink raw reply
* Re: [RFC] Should "log --cc" imply "log --cc -p"?
From: Junio C Hamano @ 2013-02-05 15:51 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: Jeff King, Michael J Gruber, git
In-Reply-To: <CACBZZX7JNwZYHn--Cp4g1rLPratJ9nEa-Q8HsYk65jjDYAkFqA@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> On a related note then, it's a bit confusing that it's called
> "--full-diff" when it doesn't actually show a diff.
It is too late to change the name of the option, but we could add a
synonym if it makes easier to understand what the option is for. It
is about saying "my pathspec are only to limit the commits to be
shown and do not limit the diff output". In that sense, the current
name that asks to give me the diff output fully is not that wrong,
but I wouldn't be surprised if other people can come up with better
names.
^ permalink raw reply
* Re: [PATCH v3 7/8] fetch: fetch objects by their exact SHA-1 object names
From: Junio C Hamano @ 2013-02-05 15:55 UTC (permalink / raw)
To: Jeff King; +Cc: git, Shawn Pearce
In-Reply-To: <20130205091938.GB24973@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Wed, Jan 30, 2013 at 10:45:41AM -0800, Junio C Hamano wrote:
>
>> Teach "git fetch" to accept an exact SHA-1 object name the user may
>> obtain out of band on the LHS of a pathspec, and send it on a "want"
>> message when the server side advertises the allow-tip-sha1-in-want
>> capability.
>
> Hmm. The UI on this is a little less nice than I would have hoped.
Naming with unadvertised *refname*, not object name, needs protocol
extension for the serving side to expand the name to object name;
otherwise the receiving end wouldn't know what tip what it asked
resulted in.
And that belongs to a separate "expand refs" extension (aka
"delaying ref advertisement") that is outside the scope of this
series but can be built on top, as I said in the cover letter.
^ permalink raw reply
* Re: Is anyone working on a next-gen Git protocol (Re: [PATCH v3 0/8] Hiding refs)
From: Junio C Hamano @ 2013-02-05 16:03 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason
Cc: git, Jeff King, Shawn Pearce, Johannes Schindelin
In-Reply-To: <CACBZZX7G=V9L+zEA2MQFjQW8tRA0i1Gk3nUYdg5dDy35v74SEw@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Do you have any plans for something that *does* have the reduction of
> network bandwidth as a primary goal?
Uncluttering gives reduction of bandwidth anyway, so I do not see
much point in the distinction you seem to be making.
> Is this what you've been working on? Because if so I misunderstood you
> thinking you were going to work on something that gave clients the
> ability specify what they wanted before the initial ref advertisement.
> ...
> 4. http://thread.gmane.org/gmane.comp.version-control.git/207190
"Who speaks first" mentioned in 4. above, was primarily about
"delaying ref advertisement", which would be a larger protocol
change. Nobody seems to have attacked it since it was discussed,
and I was tired of hearing nothing but complaints and whines. This
"hiding refs" series was done as a cheaper way to solve a related
issue, without having to wait for the solution of "delaying
advertisement", which is an orthogonal issue.
^ permalink raw reply
* Re: [PATCH] Add contrib/credentials/netrc with GPG support, try #2
From: Junio C Hamano @ 2013-02-05 16:07 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: Jeff King, git
In-Reply-To: <87sj5ariar.fsf@lifelogs.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
> On Mon, 04 Feb 2013 16:15:47 -0800 Junio C Hamano <gitster@pobox.com> wrote:
>
> JCH> Ted Zlatanov <tzz@lifelogs.com> writes:
>
>>> - do you want to support backslashed newlines?
>
> JCH> What for? netrc/authinfo is not a line oriented file format at all,
> JCH> and
>
> JCH> machine k.org
> JCH> login me
> JCH> password mysecret
>
> JCH> is a single entry; you do not need backslash at the end of any line.
>
> Hmm. The parser I implemented only does single-line parsing, and I
> misunderstood the format to be single-line (partly because I have never
> seen anyone using the multi-line format you show). Looking at
> Net::Netrc more carefully, it seems that the "machine" token is what
> defines an entry, so a new entry starts with a new line that contains a
> "machine" token. Is that acceptable and does it match your
> understanding of the format? It matches Net::Netrc, at least.
I thought I've given a more concrete outline than "I'll read
Net::Netrc and do whatever I think it does" in a separate message.
It would be better to read "man netrc" carefully at least once ;-)
^ permalink raw reply
* Re: [PATCH v3 2/8] git_remote_helpers: fix input when running under Python 3
From: Erik Faye-Lund @ 2013-02-05 16:07 UTC (permalink / raw)
To: Brandon Casey
Cc: Junio C Hamano, Sverre Rabbelier, Dennis Kaarsemaker,
John Keeping, Git List
In-Reply-To: <CA+sFfMf2R6+qzrLR9rwhtcM=ABZ8aWUJw-3riF98B3XWVGm54w@mail.gmail.com>
On Fri, Jan 25, 2013 at 9:23 PM, Brandon Casey <drafnel@gmail.com> wrote:
> On Wed, Jan 23, 2013 at 12:36 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Sverre Rabbelier <srabbelier@gmail.com> writes:
>>
>>> On Wed, Jan 23, 2013 at 11:47 AM, John Keeping <john@keeping.me.uk> wrote:
>>>>> When did we last revisit what minimal python version we are ok with requiring?
>>>>
>>>> I was wondering if people would weigh in discussing that in response to
>>>> [1] but no one has commented on that part of it. As another datapoint,
>>>> Brandon Casey was suggesting patching git-p4.py to support Python 2.4
>>>> [2].
>>>>
>>>> [1] http://article.gmane.org/gmane.comp.version-control.git/213920
>>>> [2] http://article.gmane.org/gmane.comp.version-control.git/214048
>>>
>>> I for one would be happy to kill off support for anything older than
>>> 2.6 (which had it's latest release on October 1st, 2008).
>>>
>>> Junio, how have we decided in the past which version of x to support?
>>
>> I do not think there was any conclusion. $gmane/212215 claiming 2.4
>> support matters for RHEL 5.x users was the last on the topic as far
>> as I can tell, so it boils down to another question: do users on
>> RHEL 5.x matter?
>>
>> I can read from $gmane/212215 that users of the said platform can
>> safely keep using Python 2.4 under their vendor support contract
>> until 2017. But let's focus on what do these users expect of their
>> system and software they run on it a bit.
>>
>> When they want to run a piece software that is not shipped with
>> RHEL, either by writing their own or by importing from elsewhere,
>> that needs 2.6 features, what are their options?
>>
>> (a) The platform vendor optionally supplies 2.6 with or without
>> support;
>>
>> (b) The users can and do install 2.6 as /usr/local/bin/python2.6,
>> which may even be community-supported, but the vendor does not
>> support it; or
>>
>> (c) The vendor terminates the support contract for users who choose
>> to go (b).
>>
>> I think we can safely discard (c); if that is the case, the users on
>> the said platform will not choose to update Git either, so it does
>> not matter where the future versions of Git sets the lower bound of
>> Python version at.
>>
>> If we are not talking about the situation (c), then the users can
>> choose to use 2.6, and more importantly, Python being a popular
>> software, I would imagine that there are reputable sources of
>> prepackaged RPMs for them to do so without going too much hassle of
>> configuring, compiling and installing.
>>
>> Now how does the decision we make today for releases of Git that
>> haven't yet happened will affect these users? As these versions of
>> newer Git were not shipped with RHEL 5.x, and also I am assuming
>> that Git is a more niche product than Python is, I would imagine
>> that it is very unlikely that the vendor gives it the users as an
>> optional package. The users will have to do the same thing to be
>> able to use such versions of Git as whatever they do in order to use
>> Python 2.6.
>>
>> Given that, what the vendor originally shipped and officially
>> supports does not affect the choices we would make today for newer
>> versions of Git. The users in a shop where additional third-party
>> software in /usr/local/bin is strictly forbidden, they are stuck
>> with the version of Git that the vendor shipped anyway, because they
>> won't be able to install an updated Git in /usr/local/bin, either.
>>
>> That is, unless installing 2.6 as /usr/local/bin/python2.6 (or if
>> you are really paranoid, /usr/local/only-for-git/bin/python2.6 where
>> nobody's $PATH points at) is impossible.
>>
>> So personally I do not think dropping 2.4 is a huge problem for
>> future versions of Git, but I'd like to hear from those working in
>> IT support for large and slow-moving organizations (aka RHEL 5
>> customers).
>
> I'm not really in the demographic that you asked to hear from, but
> I'll give my 2 cents anyway. :)
>
> Firstly, I defer to those with more knowledge and experience with
> python to decide which version should be the minimum version
> supported. Python 2.6 seems to be the consensus and that's fine with
> me.
>
> With respect to older platforms like RHEL 5.X that don't ship with
> Python 2.6 or later, I suspect most people who work in an organization
> with a dedicated IT staff can request that a more recent version of
> python be installed. So, I don't think a python 2.6 requirement (if
> there was one) would be a blocker for them, and I don't think it would
> be a major pain for the sysadmin to install.
>
Just a datapoint: I'm working with customers on RHEL 5.X that
unfortunately has an extremely lengthy (>3 months) process of
approving non-standard packages for install. Yeah, it's horrible, but
some times that's reality.
We are currently not using Git with that client, but we are in the
process of changing that. Said customer already have an exception for
all versions of Git.
I doubt this will end up being a problem in reality or not, but if it
will be, I'm sure it can be worked around out. I'm just pointing out
that the above suspicion might not be accurate.
^ permalink raw reply
* Re: [PATCH] Get correct column with for options in command usage
From: Junio C Hamano @ 2013-02-05 16:09 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Jiang Xin, Git List
In-Reply-To: <CACsJy8Ci05C1mKDGp_YzP0H6G0Y40K8MUUq+D6NzjtPGRNms0g@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> On Tue, Feb 5, 2013 at 7:15 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> + fprintf(outfile, sb.buf);
>
> Use fputs instead. I looked up fputs man page but somehow still left
> fprintf there.
Once the streams of "oops that was wrong" comments are done, I'd
appreciate if one of you guys send a finished patch for application,
instead of forcing me to follow all the messages in the discussion
and picking up pieces.
Thanks.
^ permalink raw reply
* Re: [PATCH] Add contrib/credentials/netrc with GPG support, try #2
From: Junio C Hamano @ 2013-02-05 16:15 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: Jeff King, git
In-Reply-To: <87mwvjsqjc.fsf_-_@lifelogs.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
> +# build reverse token map
> +my %rmap;
> +foreach my $k (keys %{$options{tmap}}) {
> + push @{$rmap{$options{tmap}->{$k}}}, $k;
> +}
Mental note: "$rmap{foo} -eq 'bar'" means that what Git calls 'bar'
is found as 'foo' in the netrc/authinfo file. Keys in %rmap are
what we expect to read from the netrc/authinfo file.
> +# there are CPAN modules to do this better, but we want to avoid
> +# dependencies and generally, complex netrc-style files are rare
> +
> +if ($debug) {
> + printf STDERR "searching for %s = %s\n", $_, $q{$_} || '(any value)'
> + foreach sort keys %q;
> +}
> +
> +LINE: foreach my $line (@data) {
> +
> + print STDERR "line [$line]\n" if $debug;
> + my @tok;
> + # gratefully stolen from Net::Netrc
> + while (length $line &&
> + $line =~ s/^("((?:[^"]+|\\.)*)"|((?:[^\\\s]+|\\.)*))\s*//) {
> + (my $tok = $+) =~ s/\\(.)/$1/g;
> + push(@tok, $tok);
> + }
> +
> + # skip blank lines, comments, etc.
> + next LINE unless scalar @tok;
> +
> + my %tokens;
> + my $num_port;
> + while (@tok) {
> + my ($k, $v) = (shift @tok, shift @tok);
> + next unless defined $v;
> + next unless exists $options{tmap}->{$k};
> + $tokens{$options{tmap}->{$k}} = $v;
> + $num_port = $v if $k eq 'port' && $v =~ m/^\d+$/;
> + }
So you grabbed one line of input, split them into token pairs, and
built %tokens = ('key Git may want to see' => 'value read from file')
mapping.
> + # for "host X port Y" where Y is an integer (captured by
> + # $num_port above), set the host to "X:Y"
> + $tokens{host} = join(':', $tokens{host}, $num_port)
> + if defined $tokens{host} && defined $num_port;
What happens when 'host' does not exist? netrc/authinfo should be a
stream of SP/HT/LF delimited tokens and 'machine' token (or
'default') begins a new entry, so it would mean the input file is
corrupt if we do not have $tokens{host} when we get here, I think.
Oh, another thing. 'default' is like 'machine' followed by any
machine name, so the above while loop that reads two tokens
pair-wise needs to be aware that 'default' is not followed by a
value. I think the loop will fail to parse this:
default login anonymous password me@home
machine k.org login me password mysecret
> + foreach my $check (sort keys %q) {
Hmph, aren't you checking what you read a bit too early? This is a
valid input:
default
login anonymous
password me@home
machine k.org
login me
password mysecret
but does this loop gives mysecret back to me when asked for
host=k.org and user=me?
> + if (exists $tokens{$check} && defined $q{$check}) {
> + print STDERR "comparing [$tokens{$check}] to [$q{$check}] in line [$line]\n" if $debug;
> + next LINE unless $tokens{$check} eq $q{$check};
> + }
> + else {
> + print STDERR "we could not find [$check] but it's OK\n" if $debug;
> + }
> + }
I would probably structure this part like this:
%pending = ();
split the whole input into tokens, regardless of lines;
iterate over the tokens {
peek the token
if (it is not "default") {
take (token, value) pair;
} else {
take "default" as token; value does not matter.
}
if (token is "default" or "machine") {
# finished reading one entry and we are
# at the beginning of the next entry.
# see if this entry matches
if (%pending is not empty &&
%pending matches %q) {
found a match; use %pending;
}
# done with that entry. now start a new one.
%pending = ();
}
$pending{token} = value;
}
^ permalink raw reply
* Re: [PATCH] Add contrib/credentials/netrc with GPG support, try #2
From: Junio C Hamano @ 2013-02-05 16:18 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: Jeff King, git
In-Reply-To: <7v7gmmvj5p.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> I thought I've given a more concrete outline than "I'll read
> Net::Netrc and do whatever I think it does" in a separate message.
And it turns out that the message was sitting in my outbox. Sorry.
I just told the outbox to send it out.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox