Skip to contentSkip to conversation

Annotate updates

PATCH New Ryan Anderson 1 participant 6 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Annotate updates

The following changes since commit 2b74cffa9179eed274be2a38c59b7e323c813737 are found in the git repository at:

http://h4x0r5.com/~ryan/git/ryan.git annotate-upstream

and will follow this email as replies in patch format.

Ryan Anderson:
Handle \No newline at end of file.
annotate: Add a basic set of test cases.
annotate: --rev-file (-S) is not a boolean parameter

 git-annotate.perl   |    8 ++++-
 t/t8001-annotate.sh |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletions(-)
 create mode 100755 t/t8001-annotate.sh
#1 lore raw

PATCH 1/1 Add git-annotate, a tool for assigning blame.

---

(Pull from http://h4x0r5.com/~ryan/git/ryan.git/ annotate-upstream )

I'm pretty sure this version (finally) gets the edge cases correct.

I would appreciate some other testing on this, as I can't find a case where it falls down, but the files with a lot of history tend to have a lot of lines, making them hard to spotcheck without having been an intimate part of that history.

Oh, this is the "functional" version, but it might not qualify as "nice looking" yet, pleaes, feel free to complain.

 Makefile          |    1 
 git-annotate.perl |  321 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 322 insertions(+), 0 deletions(-)
 create mode 100755 git-annotate.perl

107045e8abb674a66ee7c682dd85a3d303f26e3c

Makefile +1 -0
index 317be3c..86ffcf4 100644
@@ -119,6 +119,7 @@ SCRIPT_SH = \
 SCRIPT_PERL = \
 	git-archimport.perl git-cvsimport.perl git-relink.perl \
 	git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \
+	git-annotate.perl \
 	git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
 
 SCRIPT_PYTHON = \
git-annotate.perl new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
1.2.2.gb342
#2 lore raw

Re: [PATCH] Add git-annotate, a tool for assigning blame.

Sorry about this - I was in the wrong directory (apparently) when running git-send-email. Actual patches in a second.

Signature · 2 lines
Ryan Anderson
  sometimes Pug Majere
#3 lore raw

PATCH 1/3 Handle \No newline at end of file.

In reply to Ryan Anderson

---

 git-annotate.perl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

e30d9ddd62cf016124dd9f32e14809d0a38c69e2

git-annotate.perl +6 -0
index f9c2c6c..d6028c9 100755
@@ -304,6 +304,12 @@ sub _git_diff_parse {
 			}
 			$ri++;
 
+		} elsif (m/^\\/) {
+			;
+			# Skip \No newline at end of file.
+			# But this can be internationalized, so only look
+			# for an initial \
+
 		} else {
 			if (substr($_,1) ne get_line($slines,$ri) ) {
 				die sprintf("Line %d (%d) does not match:\n|%s\n|%s\n%s => %s\n",
Signature · 1 line
1.2.2.g1070
#4 lore raw

PATCH 2/3 annotate: Add a basic set of test cases.

---

 t/t8001-annotate.sh |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 t/t8001-annotate.sh

7df39590a44352626c8d83a2b94d1ba11b24a118

t/t8001-annotate.sh new file +89 -0
new file mode 100755
index 0000000..cae1794
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+test_description='git-annotate'
+. ./test-lib.sh
+
+test_expect_success \
+    'prepare reference tree' \
+    'echo "1A quick brown fox jumps over the" >file &&
+     echo "lazy dog" >>file &&
+     git add file
+     GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
+
+test_expect_success \
+    'check all lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
+
+test_expect_success \
+    'Setup new lines blamed on B' \
+    'echo "2A quick brown fox jumps over the" >>file &&
+     echo "lazy dog" >> file &&
+     GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "B") == 2 ]'
+
+test_expect_success \
+    'merge-setup part 1' \
+    'git checkout -b branch1 master &&
+     echo "3A slow green fox jumps into the" >> file &&
+     echo "well." >> file &&
+     GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B1' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+
+test_expect_success \
+    'merge-setup part 2' \
+    'git checkout -b branch2 master &&
+     sed -i -e "s/2A quick brown/4A quick brown lazy dog/" file &&
+     GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
+
+test_expect_success \
+    'One line blamed on B2' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
+
+
+test_expect_success \
+    'merge-setup part 3' \
+    'git pull . branch1'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
+
+test_expect_success \
+    'Two lines blamed on B1' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B2' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
+
+test_done
Signature · 1 line
1.2.2.g1070
#5 lore raw

PATCH 3/3 annotate: --rev-file (-S) is not a boolean parameter

---

 git-annotate.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

75846f79f31c9833303ff7d44b87b53c39f4bf9a

git-annotate.perl +1 -1
index d6028c9..30f9a71 100755
@@ -31,7 +31,7 @@ our ($help, $longrev, $rename, $starting
 my $rc = GetOptions(	"long|l" => \$longrev,
 			"help|h" => \$help,
 			"rename|r" => \$rename,
-			"rev-file|S" => \$rev_file);
+			"rev-file|S=s" => \$rev_file);
 if (!$rc or $help) {
 	usage();
 }
Signature · 1 line
1.2.2.g1070