From ae00dc191a8da2309a6d7c68a254ede1357d877d Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 3 May 2010 21:57:36 -0500 Subject: t4201 (shortlog): guard setup with test_expect_success Follow the current prevailing style. This also has the benefit of capturing any stray output and noticing if any of the setup commands start failing. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t4201-shortlog.sh | 68 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 't') diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index a01e55bf6b..438a826473 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -8,30 +8,38 @@ test_description='git shortlog . ./test-lib.sh -echo 1 > a1 -git add a1 -tree=$(git write-tree) -commit=$( (echo "Test"; echo) | git commit-tree $tree ) -git update-ref HEAD $commit - -echo 2 > a1 -git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 - -# test if the wrapping is still valid when replacing all i's by treble clefs. -echo 3 > a1 -git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\360\235\204\236')" a1 - -# now fsck up the utf8 -git config i18n.commitencoding non-utf-8 -echo 4 > a1 -git commit --quiet -m "$(echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | sed "s/i/1234/g" | tr 1234 '\370\235\204\236')" a1 - -echo 5 > a1 -git commit --quiet -m "a 12 34 56 78" a1 - -git shortlog -w HEAD > out +test_expect_success 'setup' ' + echo 1 >a1 && + git add a1 && + tree=$(git write-tree) && + commit=$(printf "%s\n" "Test" "" | git commit-tree "$tree") && + git update-ref HEAD "$commit" && + + echo 2 >a1 && + git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 && + + # test if the wrapping is still valid + # when replacing all is by treble clefs. + echo 3 >a1 && + git commit --quiet -m "$( + echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | + sed "s/i/1234/g" | + tr 1234 "\360\235\204\236")" a1 && + + # now fsck up the utf8 + git config i18n.commitencoding non-utf-8 && + echo 4 >a1 && + git commit --quiet -m "$( + echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" | + sed "s/i/1234/g" | + tr 1234 "\370\235\204\236")" a1 && + + echo 5 >a1 && + git commit --quiet -m "a 12 34 56 78" a1 +' -cat > expect << EOF +test_expect_success 'shortlog wrapping' ' + cat >expect <<\EOF && A U Thor (5): Test This is a very, very long first line for the commit message to see if @@ -44,13 +52,15 @@ A U Thor (5): 56 78 EOF + git shortlog -w HEAD >out && + test_cmp expect out +' -test_expect_success 'shortlog wrapping' 'test_cmp expect out' - -git log HEAD > log -GIT_DIR=non-existing git shortlog -w < log > out - -test_expect_success 'shortlog from non-git directory' 'test_cmp expect out' +test_expect_success 'shortlog from non-git directory' ' + git log HEAD >log && + GIT_DIR=non-existing git shortlog -w out && + test_cmp expect out +' iconvfromutf8toiso88591() { printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1 -- cgit v1.2.3 From ed715b5e393f922b7726460c348c8cb7eb7de49b Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 3 May 2010 21:58:04 -0500 Subject: t4201 (shortlog): Test output format with multiple authors Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t4201-shortlog.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't') diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 438a826473..6bfd0c0582 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -36,6 +36,10 @@ test_expect_success 'setup' ' echo 5 >a1 && git commit --quiet -m "a 12 34 56 78" a1 + + echo 6 >a1 && + git commit --quiet -m "Commit by someone else" \ + --author="Someone else " a1 ' test_expect_success 'shortlog wrapping' ' @@ -51,6 +55,9 @@ A U Thor (5): a 12 34 56 78 +Someone else (1): + Commit by someone else + EOF git shortlog -w HEAD >out && test_cmp expect out -- cgit v1.2.3 From 600372497c668045a365b9eab76987ee19405f7a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 3 May 2010 21:59:55 -0500 Subject: shortlog: Document and test --format option Do not document the --pretty synonym, since it takes too long to explain the name to people. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t4201-shortlog.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 6bfd0c0582..13fdeb2653 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -39,7 +39,58 @@ test_expect_success 'setup' ' echo 6 >a1 && git commit --quiet -m "Commit by someone else" \ - --author="Someone else " a1 + --author="Someone else " a1 && + + cat >expect.template <<-\EOF + A U Thor (5): + SUBJECT + SUBJECT + SUBJECT + SUBJECT + SUBJECT + + Someone else (1): + SUBJECT + + EOF +' + +fuzz() { + file=$1 && + sed " + s/$_x40/OBJECT_NAME/g + s/$_x05/OBJID/g + s/^ \{6\}[CTa].*/ SUBJECT/g + s/^ \{8\}[^ ].*/ CONTINUATION/g + " <"$file" >"$file.fuzzy" && + sed "/CONTINUATION/ d" <"$file.fuzzy" +} + +test_expect_success 'default output format' ' + git shortlog HEAD >log && + fuzz log >log.predictable && + test_cmp expect.template log.predictable +' + +test_expect_success 'pretty format' ' + sed s/SUBJECT/OBJECT_NAME/ expect.template >expect && + git shortlog --format="%H" HEAD >log && + fuzz log >log.predictable && + test_cmp expect log.predictable +' + +test_expect_failure '--abbrev' ' + sed s/SUBJECT/OBJID/ expect.template >expect && + git shortlog --format="%h" --abbrev=5 HEAD >log && + fuzz log >log.predictable && + test_cmp expect log.predictable +' + +test_expect_success 'output from user-defined format is re-wrapped' ' + sed "s/SUBJECT/two lines/" expect.template >expect && + git shortlog --format="two%nlines" HEAD >log && + fuzz log >log.predictable && + test_cmp expect log.predictable ' test_expect_success 'shortlog wrapping' ' -- cgit v1.2.3 From c197702156e2164074327f5e870ab0d3021977fc Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Mon, 3 May 2010 22:18:57 -0500 Subject: pretty: Respect --abbrev option Prior to this, the output of git log -1 --format=%h was always 7 characters long, without regard to whether --abbrev had been passed. Signed-off-by: Will Palmer Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t4201-shortlog.sh | 2 +- t/t6006-rev-list-format.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh index 13fdeb2653..cdb70b4b33 100755 --- a/t/t4201-shortlog.sh +++ b/t/t4201-shortlog.sh @@ -79,7 +79,7 @@ test_expect_success 'pretty format' ' test_cmp expect log.predictable ' -test_expect_failure '--abbrev' ' +test_expect_success '--abbrev' ' sed s/SUBJECT/OBJID/ expect.template >expect && git shortlog --format="%h" --abbrev=5 HEAD >log && fuzz log >log.predictable && diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index d24ca5c077..313897bbc0 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -191,6 +191,31 @@ test_expect_success 'add LF before non-empty (2)' ' grep "^$" actual ' +test_expect_success '--abbrev' ' + echo SHORT SHORT SHORT >expect2 && + echo LONG LONG LONG >expect3 && + git log -1 --format="%h %h %h" HEAD >actual1 && + git log -1 --abbrev=5 --format="%h %h %h" HEAD >actual2 && + git log -1 --abbrev=5 --format="%H %H %H" HEAD >actual3 && + sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" fuzzy2 && + sed -e "s/$_x40/LONG/g" -e "s/$_x05/SHORT/g" fuzzy3 && + test_cmp expect2 fuzzy2 && + test_cmp expect3 fuzzy3 && + ! test_cmp actual1 actual2 +' + +test_expect_success '%H is not affected by --abbrev-commit' ' + git log -1 --format=%H --abbrev-commit --abbrev=20 HEAD >actual && + len=$(wc -c actual && + len=$(wc -c expect && git log -g --format="%h %gD: %gs" >actual && @@ -203,6 +228,12 @@ test_expect_success '"%h %gD: %gs" is same as git-reflog (with date)' ' test_cmp expect actual ' +test_expect_success '"%h %gD: %gs" is same as git-reflog (with --abbrev)' ' + git reflog --abbrev=13 --date=raw >expect && + git log -g --abbrev=13 --format="%h %gD: %gs" --date=raw >actual && + test_cmp expect actual +' + test_expect_success '%gd shortens ref name' ' echo "master@{0}" >expect.gd-short && git log -g -1 --format=%gd refs/heads/master >actual.gd-short && -- cgit v1.2.3