Thread (12 messages) flat view 12 messages, 3 authors, 2016-06-15

Re: [PATCH 1/2] add basic branch display tests

From: Jeff King <hidden>
Date: 2016-06-15 22:46:14

On Wed, Feb 18, 2009 at 10:34:44PM -0500, Jeff King wrote:
We were not testing the output of "git branch" anywhere.
There is one thing that occurred to me while writing these tests that I
wanted to mention.

When we show a remote symref with "git branch -r", it looks like this:
+cat >expect <<'EOF'
+  origin/HEAD -> origin/branch-one
+  origin/branch-one
+  origin/branch-two
+EOF
+test_expect_success 'git branch -r shows remote branches' '
+	git branch -r >actual &&
+	test_cmp expect actual
+'
which makes sense. <remote>/<symref> -> <remote>/<branch>
+cat >expect <<'EOF'
+  branch-one
+  branch-two
+* master
+  remotes/origin/HEAD -> origin/branch-one
+  remotes/origin/branch-one
+  remotes/origin/branch-two
+EOF
+test_expect_success 'git branch -a shows local and remote branches' '
+	git branch -a >actual &&
+	test_cmp expect actual
+'
But here we stick the "remotes/" head on, since we are showing both
types. But the right hand side of the symref doesn't get the same
treatment.

I don't think it's a big deal, but I wasn't sure if it was intentional,
a bug, or simply that nobody cares (and since I have now codified it in
a test script, it seems like we should make sure it is intentional).

I also had a brief thought that reprinting the <remote> is pointless.
That is, printing

  origin/HEAD -> master

shows what is happening with less text due to the context (i.e., we
already know we are talking about remote "origin" -- and if it isn't in
origin, we already show more). But that is probably a bad idea; that
context is missing if you were to try to do something like "git show";
<remote>/<branch> would work, but <branch> wouldn't.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help