commit - d4efa91b5a0b6d8d90ff1f847518ff59c17682e3
commit + 562580bce8d701d318471fe7601bc614a00c94ef
blob - 4b74c056672711e1ebae75fd3d7c79da18c35d82
blob + 2cffd8930319c67ebe5df79af4777c16a6e6b836
--- got/got.c
+++ got/got.c
}
got_object_tag_close(tag);
return err;
- } else if (err->code != GOT_ERR_NO_OBJ)
+ } else if (err->code != GOT_ERR_OBJ_TYPE &&
+ err->code != GOT_ERR_NO_OBJ)
return err;
}
blob - 43a0f3a840e30d3749f4690d900e34f9cc447465
blob + 5df3441a4dead2afbdacad91ebb4e819f7814a6d
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
local commit_id2=`git_show_head $testroot/repo`
(cd $testroot/repo && git tag -m "test" $tag2)
+
+ echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
+ echo -n 'blob - ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
+ cut -d' ' -f 1 >> $testroot/stdout.expected
+ echo -n 'blob + ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
+ >> $testroot/stdout.expected
+ echo '--- alpha' >> $testroot/stdout.expected
+ echo '+++ alpha' >> $testroot/stdout.expected
+ echo '@@ -1 +1 @@' >> $testroot/stdout.expected
+ echo '-alpha' >> $testroot/stdout.expected
+ echo '+modified alpha' >> $testroot/stdout.expected
+
+ got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
+ echo "blob - /dev/null" >> $testroot/stdout.expected
+ echo -n 'blob + ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
+ cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
+ echo " (mode 644)" >> $testroot/stdout.expected
+ echo '--- /dev/null' >> $testroot/stdout.expected
+ echo '+++ new' >> $testroot/stdout.expected
+ echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
+ echo '+new file' >> $testroot/stdout.expected
+ got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+function test_diff_lightweight_tag {
+ local testroot=`test_init diff_tag`
+ local commit_id0=`git_show_head $testroot/repo`
+ local tag1=1.0.0
+ local tag2=2.0.0
+
+ echo "modified alpha" > $testroot/repo/alpha
+ git_commit $testroot/repo -m "changed alpha"
+ local commit_id1=`git_show_head $testroot/repo`
+
+ (cd $testroot/repo && git tag $tag1)
+
+ echo "new file" > $testroot/repo/new
+ (cd $testroot/repo && git add new)
+ git_commit $testroot/repo -m "new file"
+ local commit_id2=`git_show_head $testroot/repo`
+
+ (cd $testroot/repo && git tag $tag2)
+
echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
echo -n 'blob - ' >> $testroot/stdout.expected
got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
run_test test_diff_basic
run_test test_diff_shows_conflict
run_test test_diff_tag
+run_test test_diff_lightweight_tag
run_test test_diff_ignore_whitespace