* omitted the check for options, none of them made sense.
* use of --reverse
* an additional test asked for by Jonathan

previous discussion
https://public-inbox.org/git/20171102194148.2124-1-sbel...@google.com/
interdiff to current queued patches below.

Thanks,
Stefan

Stefan Beller (7):
  t6120: fix typo in test name
  list-objects.c: factor out traverse_trees_and_blobs
  revision.h: introduce blob/tree walking in order of the commits
  builtin/describe.c: rename `oid` to avoid variable shadowing
  builtin/describe.c: print debug statements earlier
  builtin/describe.c: factor out describe_commit
  builtin/describe.c: describe a blob

 Documentation/git-describe.txt     |  13 +++-
 Documentation/rev-list-options.txt |   5 ++
 builtin/describe.c                 | 126 ++++++++++++++++++++++++++++---------
 list-objects.c                     |  52 +++++++++------
 revision.c                         |   2 +
 revision.h                         |   3 +-
 t/t6100-rev-list-in-order.sh       |  77 +++++++++++++++++++++++
 t/t6120-describe.sh                |  21 ++++++-
 8 files changed, 249 insertions(+), 50 deletions(-)
 create mode 100755 t/t6100-rev-list-in-order.sh

-- 
2.15.0.128.gcadd42da22

diff --git c/builtin/describe.c w/builtin/describe.c
index acfd853a30..a2a5fdc48d 100644
--- c/builtin/describe.c
+++ w/builtin/describe.c
@@ -473,6 +473,7 @@ static void describe_blob(struct object_id oid, struct 
strbuf *dst)
                "--single-worktree",
                "--objects",
                "--in-commit-order",
+               "--reverse",
                NULL);
 
        init_revisions(&revs, NULL);
@@ -501,13 +502,9 @@ static void describe(const char *arg, int last_one)
 
        if (cmit)
                describe_commit(&oid, &sb);
-       else if (lookup_blob(&oid)) {
-               if (all || tags || longformat || first_parent ||
-                   patterns.nr || exclude_patterns.nr ||
-                   always || dirty || broken)
-                       die(_("options not available for describing blobs"));
+       else if (lookup_blob(&oid))
                describe_blob(oid, &sb);
-       } else
+       else
                die(_("%s is neither a commit nor blob"), arg);
 
        puts(sb.buf);
diff --git c/t/t6100-rev-list-in-order.sh w/t/t6100-rev-list-in-order.sh
index d4d539b0da..b2bb0a7f61 100755
--- c/t/t6100-rev-list-in-order.sh
+++ w/t/t6100-rev-list-in-order.sh
@@ -4,7 +4,7 @@ test_description='rev-list testing in-commit-order'
 
 . ./test-lib.sh
 
-test_expect_success 'rev-list --in-commit-order' '
+test_expect_success 'setup a commit history with trees, blobs' '
        for x in one two three four
        do
                echo $x >$x &&
@@ -17,7 +17,10 @@ test_expect_success 'rev-list --in-commit-order' '
                git rm $x &&
                git commit -m "remove $x" ||
                return 1
-       done &&
+       done
+'
+
+test_expect_success 'rev-list --in-commit-order' '
        git rev-list --in-commit-order --objects HEAD >actual.raw &&
        cut -c 1-40 >actual <actual.raw &&
 
@@ -44,4 +47,31 @@ test_expect_success 'rev-list --in-commit-order' '
        test_cmp expect actual
 '
 
+test_expect_success 'rev-list lists blobs and trees after commits' '
+       git rev-list --objects HEAD >actual.raw &&
+       cut -c 1-40 >actual <actual.raw &&
+
+       git cat-file --batch-check="%(objectname)" >expect.raw <<-\EOF &&
+               HEAD^{commit}
+               HEAD~1^{commit}
+               HEAD~2^{commit}
+               HEAD~3^{commit}
+               HEAD~4^{commit}
+               HEAD~5^{commit}
+               HEAD^{tree}
+               HEAD^{tree}:one
+               HEAD^{tree}:two
+               HEAD~1^{tree}
+               HEAD~1^{tree}:three
+               HEAD~2^{tree}
+               HEAD~2^{tree}:four
+               # HEAD~3^{tree} skipped, same as HEAD~1^{tree}
+               # HEAD~4^{tree} skipped, same as HEAD^{tree}
+               HEAD~5^{tree}
+       EOF
+       grep -v "#" >expect <expect.raw &&
+
+       test_cmp expect actual
+'
+
 test_done
diff --git c/t/t6120-describe.sh w/t/t6120-describe.sh
index aec6ed192d..ec4f25d009 100755
--- c/t/t6120-describe.sh
+++ w/t/t6120-describe.sh
@@ -319,10 +319,14 @@ test_expect_success 'describe a blob at a tag' '
        test_cmp expect actual
 '
 
-test_expect_success 'describe a blob with commit-ish' '
+test_expect_success 'describe a blob with its last introduction' '
+       git commit --allow-empty -m "empty commit" &&
+       git rm file &&
+       git commit -m "delete blob" &&
+       git revert HEAD &&
        git commit --allow-empty -m "empty commit" &&
        git describe HEAD:file >actual &&
-       grep unique-file-1-g actual
+       grep unique-file-3-g actual
 '
 
 test_expect_failure ULIMIT_STACK_SIZE 'name-rev works in a deep repo' '

Reply via email to