2005-10-13 20:36:37 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Johannes Schindelin
|
|
|
|
#
|
|
|
|
|
2006-10-03 02:02:15 +02:00
|
|
|
test_description='A simple turial in the form of a test case'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'blob' '
|
|
|
|
echo "Hello World" > hello &&
|
|
|
|
echo "Silly example" > example &&
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
git update-index --add hello example &&
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test blob = "$(git cat-file -t 557db03)"
|
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'blob 557db03' '
|
|
|
|
test "Hello World" = "$(git cat-file blob 557db03)"
|
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
echo "It's a new day for git" >>hello
|
|
|
|
cat > diff.expect << EOF
|
|
|
|
diff --git a/hello b/hello
|
|
|
|
index 557db03..263414f 100644
|
|
|
|
--- a/hello
|
|
|
|
+++ b/hello
|
|
|
|
@@ -1 +1,2 @@
|
|
|
|
Hello World
|
|
|
|
+It's a new day for git
|
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git diff-files -p' '
|
|
|
|
git diff-files -p > diff.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp diff.expect diff.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git diff' '
|
|
|
|
git diff > diff.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp diff.expect diff.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'tree' '
|
2010-10-31 02:46:54 +01:00
|
|
|
tree=$(git write-tree 2>/dev/null) &&
|
2009-11-05 07:33:52 +01:00
|
|
|
test 8988da15d077d4829fc51d8544c097def6644dbb = $tree
|
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git diff-index -p HEAD' '
|
2009-11-25 00:08:08 +01:00
|
|
|
test_tick &&
|
|
|
|
tree=$(git write-tree) &&
|
2009-11-05 07:33:53 +01:00
|
|
|
commit=$(echo "Initial commit" | git commit-tree $tree) &&
|
|
|
|
git update-ref HEAD $commit &&
|
2009-11-05 07:33:52 +01:00
|
|
|
git diff-index -p HEAD > diff.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp diff.expect diff.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git diff HEAD' '
|
|
|
|
git diff HEAD > diff.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp diff.expect diff.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
cat > whatchanged.expect << EOF
|
Log message printout cleanups
On Sun, 16 Apr 2006, Junio C Hamano wrote:
>
> In the mid-term, I am hoping we can drop the generate_header()
> callchain _and_ the custom code that formats commit log in-core,
> found in cmd_log_wc().
Ok, this was nastier than expected, just because the dependencies between
the different log-printing stuff were absolutely _everywhere_, but here's
a patch that does exactly that.
The patch is not very easy to read, and the "--patch-with-stat" thing is
still broken (it does not call the "show_log()" thing properly for
merges). That's not a new bug. In the new world order it _should_ do
something like
if (rev->logopt)
show_log(rev, rev->logopt, "---\n");
but it doesn't. I haven't looked at the --with-stat logic, so I left it
alone.
That said, this patch removes more lines than it adds, and in particular,
the "cmd_log_wc()" loop is now a very clean:
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
commit->buffer = NULL;
}
so it doesn't get much prettier than this. All the complexity is entirely
hidden in log-tree.c, and any code that needs to flush the log literally
just needs to do the "if (rev->logopt) show_log(...)" incantation.
I had to make the combined_diff() logic take a "struct rev_info" instead
of just a "struct diff_options", but that part is pretty clean.
This does change "git whatchanged" from using "diff-tree" as the commit
descriptor to "commit", and I changed one of the tests to reflect that new
reality. Otherwise everything still passes, and my other tests look fine
too.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-17 20:59:32 +02:00
|
|
|
commit VARIABLE
|
2005-10-13 20:36:37 +02:00
|
|
|
Author: VARIABLE
|
|
|
|
Date: VARIABLE
|
|
|
|
|
|
|
|
Initial commit
|
|
|
|
|
|
|
|
diff --git a/example b/example
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..f24c74a
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/example
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Silly example
|
|
|
|
diff --git a/hello b/hello
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..557db03
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/hello
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Hello World
|
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git whatchanged -p --root' '
|
2009-11-07 07:47:37 +01:00
|
|
|
git whatchanged -p --root |
|
2009-11-05 07:33:52 +01:00
|
|
|
sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
|
2005-10-13 20:36:37 +02:00
|
|
|
-e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
|
2009-11-05 07:33:52 +01:00
|
|
|
> whatchanged.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp whatchanged.expect whatchanged.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git tag my-first-tag' '
|
|
|
|
git tag my-first-tag &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp .git/refs/heads/master .git/refs/tags/my-first-tag
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git checkout -b mybranch' '
|
|
|
|
git checkout -b mybranch &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp .git/refs/heads/master .git/refs/heads/mybranch
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
cat > branch.expect <<EOF
|
|
|
|
master
|
|
|
|
* mybranch
|
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git branch' '
|
|
|
|
git branch > branch.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp branch.expect branch.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git resolve now fails' '
|
|
|
|
git checkout mybranch &&
|
|
|
|
echo "Work, work, work" >>hello &&
|
2009-11-25 00:08:08 +01:00
|
|
|
test_tick &&
|
2009-11-05 07:33:52 +01:00
|
|
|
git commit -m "Some work." -i hello &&
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
git checkout master &&
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
echo "Play, play, play" >>hello &&
|
|
|
|
echo "Lots of fun" >>example &&
|
2009-11-25 00:08:08 +01:00
|
|
|
test_tick &&
|
2009-11-05 07:33:52 +01:00
|
|
|
git commit -m "Some fun." -i hello example &&
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2008-07-12 17:47:52 +02:00
|
|
|
test_must_fail git merge -m "Merge work in mybranch" mybranch
|
2007-02-07 19:37:03 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
cat > hello << EOF
|
|
|
|
Hello World
|
|
|
|
It's a new day for git
|
|
|
|
Play, play, play
|
|
|
|
Work, work, work
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > show-branch.expect << EOF
|
2009-11-05 07:33:53 +01:00
|
|
|
* [master] Merge work in mybranch
|
2005-10-13 20:36:37 +02:00
|
|
|
! [mybranch] Some work.
|
|
|
|
--
|
2009-11-05 07:33:53 +01:00
|
|
|
- [master] Merge work in mybranch
|
2006-01-11 23:02:38 +01:00
|
|
|
*+ [mybranch] Some work.
|
2009-11-05 07:33:53 +01:00
|
|
|
* [master^] Some fun.
|
2005-10-13 20:36:37 +02:00
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git show-branch' '
|
2009-11-25 00:08:08 +01:00
|
|
|
test_tick &&
|
2009-11-05 07:33:53 +01:00
|
|
|
git commit -m "Merge work in mybranch" -i hello &&
|
|
|
|
git show-branch --topo-order --more=1 master mybranch \
|
|
|
|
> show-branch.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp show-branch.expect show-branch.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
cat > resolve.expect << EOF
|
2009-11-05 07:33:52 +01:00
|
|
|
Updating VARIABLE..VARIABLE
|
2009-11-07 07:58:14 +01:00
|
|
|
FASTFORWARD (no commit created; -m option ignored)
|
2005-10-13 20:36:37 +02:00
|
|
|
example | 1 +
|
|
|
|
hello | 1 +
|
|
|
|
2 files changed, 2 insertions(+), 0 deletions(-)
|
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git resolve' '
|
|
|
|
git checkout mybranch &&
|
2009-11-07 07:47:37 +01:00
|
|
|
git merge -m "Merge upstream changes." master |
|
2009-11-07 07:58:14 +01:00
|
|
|
sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" \
|
|
|
|
-e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp resolve.expect resolve.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
cat > show-branch2.expect << EOF
|
2009-11-05 07:33:53 +01:00
|
|
|
! [master] Merge work in mybranch
|
|
|
|
* [mybranch] Merge work in mybranch
|
2005-10-13 20:36:37 +02:00
|
|
|
--
|
2009-11-05 07:33:53 +01:00
|
|
|
-- [master] Merge work in mybranch
|
2005-10-13 20:36:37 +02:00
|
|
|
EOF
|
|
|
|
|
2009-11-05 07:33:52 +01:00
|
|
|
test_expect_success 'git show-branch (part 2)' '
|
|
|
|
git show-branch --topo-order master mybranch > show-branch2.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp show-branch2.expect show-branch2.output
|
2009-11-05 07:33:52 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
2009-11-05 07:33:53 +01:00
|
|
|
cat > show-branch3.expect << EOF
|
|
|
|
! [master] Merge work in mybranch
|
|
|
|
* [mybranch] Merge work in mybranch
|
|
|
|
--
|
|
|
|
-- [master] Merge work in mybranch
|
|
|
|
+* [master^2] Some work.
|
|
|
|
+* [master^] Some fun.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'git show-branch (part 3)' '
|
|
|
|
git show-branch --topo-order --more=2 master mybranch \
|
|
|
|
> show-branch3.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp show-branch3.expect show-branch3.output
|
2009-11-05 07:33:53 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rewind to "Some fun." and "Some work."' '
|
|
|
|
git checkout mybranch &&
|
|
|
|
git reset --hard master^2 &&
|
|
|
|
git checkout master &&
|
|
|
|
git reset --hard master^
|
|
|
|
'
|
|
|
|
|
|
|
|
cat > show-branch4.expect << EOF
|
|
|
|
* [master] Some fun.
|
|
|
|
! [mybranch] Some work.
|
|
|
|
--
|
|
|
|
* [master] Some fun.
|
2009-11-25 00:08:08 +01:00
|
|
|
+ [mybranch] Some work.
|
|
|
|
*+ [master^] Initial commit
|
2009-11-05 07:33:53 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'git show-branch (part 4)' '
|
|
|
|
git show-branch --topo-order > show-branch4.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp show-branch4.expect show-branch4.output
|
2009-11-05 07:33:53 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'manual merge' '
|
|
|
|
mb=$(git merge-base HEAD mybranch) &&
|
|
|
|
git name-rev --name-only --tags $mb > name-rev.output &&
|
|
|
|
test "my-first-tag" = $(cat name-rev.output) &&
|
|
|
|
|
|
|
|
git read-tree -m -u $mb HEAD mybranch
|
|
|
|
'
|
|
|
|
|
|
|
|
cat > ls-files.expect << EOF
|
|
|
|
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
|
|
|
|
100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
|
|
|
|
100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
|
|
|
|
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'git ls-files --stage' '
|
|
|
|
git ls-files --stage > ls-files.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp ls-files.expect ls-files.output
|
2009-11-05 07:33:53 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
cat > ls-files-unmerged.expect << EOF
|
|
|
|
100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
|
|
|
|
100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
|
|
|
|
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'git ls-files --unmerged' '
|
|
|
|
git ls-files --unmerged > ls-files-unmerged.output &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp ls-files-unmerged.expect ls-files-unmerged.output
|
2009-11-05 07:33:53 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git-merge-index' '
|
|
|
|
test_must_fail git merge-index git-merge-one-file hello
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git ls-files --stage (part 2)' '
|
|
|
|
git ls-files --stage > ls-files.output2 &&
|
2009-11-07 07:47:37 +01:00
|
|
|
test_cmp ls-files.expect ls-files.output2
|
2009-11-05 07:33:53 +01:00
|
|
|
'
|
|
|
|
|
2005-10-13 20:36:37 +02:00
|
|
|
test_expect_success 'git repack' 'git repack'
|
|
|
|
test_expect_success 'git prune-packed' 'git prune-packed'
|
2008-02-01 10:50:53 +01:00
|
|
|
test_expect_success '-> only packed objects' '
|
2009-11-05 07:33:52 +01:00
|
|
|
git prune && # Remove conflict marked blobs
|
2009-12-26 22:53:45 +01:00
|
|
|
test $(find .git/objects/[0-9a-f][0-9a-f] -type f -print 2>/dev/null | wc -l) = 0
|
2008-02-01 10:50:53 +01:00
|
|
|
'
|
2005-10-13 20:36:37 +02:00
|
|
|
|
|
|
|
test_done
|