git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] t: switch "branch -l" to "branch --create-reflog"

From
Jeff King <peff@peff.net>
Date
Mar 26, 2018, 07:26 UTC
Message-ID
<20180326072649.GB12530@sigill.intra.peff.net>
In-Reply-To
<20180326072505.GA12436@sigill.intra.peff.net>

In preparation for deprecating "-l", let's make sure we're using the recommended option ourselves.

This patch just mechanically converts "branch -l" to "branch --create-reflog". Note that with the exception of the actual "--create-reflog" test, we could actually remove "-l" entirely from most of these callers. That's because these days core.logallrefupdates defaults to true in a non-bare repository.

I've left them in place, though, since they serve to document the expectation of the test, even if they are technically noops.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t1410-reflog.sh |  4 ++--
 t/t3200-branch.sh | 34 +++++++++++++++++-----------------
 2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 553e26d9ce..8293131001 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -339,8 +339,8 @@ test_expect_failure 'reflog with non-commit entries displays all entries' '
 '
 
 test_expect_success 'reflog expire operates on symref not referrent' '
-	git branch -l the_symref &&
-	git branch -l referrent &&
+	git branch --create-reflog the_symref &&
+	git branch --create-reflog referrent &&
 	git update-ref referrent HEAD &&
 	git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
 	test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index e0c316b71a..da97b8a62b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -48,9 +48,9 @@ test_expect_success 'git branch HEAD should fail' '
 cat >expect <<EOF
 $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000	branch: Created from master
 EOF
-test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' '
 	GIT_COMMITTER_DATE="2005-05-26 23:30" \
-	git -c core.logallrefupdates=false branch -l d/e/f &&
+	git -c core.logallrefupdates=false branch --create-reflog d/e/f &&
 	test_path_is_file .git/refs/heads/d/e/f &&
 	test_path_is_file .git/logs/refs/heads/d/e/f &&
 	test_cmp expect .git/logs/refs/heads/d/e/f
@@ -81,7 +81,7 @@ test_expect_success 'git branch -m dumps usage' '
 
 test_expect_success 'git branch -m m broken_symref should work' '
 	test_when_finished "git branch -D broken_symref" &&
-	git branch -l m &&
+	git branch --create-reflog m &&
 	git symbolic-ref refs/heads/broken_symref refs/heads/i_am_broken &&
 	git branch -m m broken_symref &&
 	git reflog exists refs/heads/broken_symref &&
@@ -89,13 +89,13 @@ test_expect_success 'git branch -m m broken_symref should work' '
 '
 
 test_expect_success 'git branch -m m m/m should work' '
-	git branch -l m &&
+	git branch --create-reflog m &&
 	git branch -m m m/m &&
 	git reflog exists refs/heads/m/m
 '
 
 test_expect_success 'git branch -m n/n n should work' '
-	git branch -l n/n &&
+	git branch --create-reflog n/n &&
 	git branch -m n/n n &&
 	git reflog exists refs/heads/n
 '
@@ -377,9 +377,9 @@ mv .git/config-saved .git/config
 git config branch.s/s.dummy Hello
 
 test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
-	git branch -l s/s &&
+	git branch --create-reflog s/s &&
 	git reflog exists refs/heads/s/s &&
-	git branch -l s/t &&
+	git branch --create-reflog s/t &&
 	git reflog exists refs/heads/s/t &&
 	git branch -d s/t &&
 	git branch -m s/s s &&
@@ -443,7 +443,7 @@ test_expect_success 'git branch --copy dumps usage' '
 '
 
 test_expect_success 'git branch -c d e should work' '
-	git branch -l d &&
+	git branch --create-reflog d &&
 	git reflog exists refs/heads/d &&
 	git config branch.d.dummy Hello &&
 	git branch -c d e &&
@@ -458,7 +458,7 @@ test_expect_success 'git branch -c d e should work' '
 '
 
 test_expect_success 'git branch --copy is a synonym for -c' '
-	git branch -l copy &&
+	git branch --create-reflog copy &&
 	git reflog exists refs/heads/copy &&
 	git config branch.copy.dummy Hello &&
 	git branch --copy copy copy-to &&
@@ -485,7 +485,7 @@ test_expect_success 'git branch -c ee ef should copy ee to create branch ef' '
 '
 
 test_expect_success 'git branch -c f/f g/g should work' '
-	git branch -l f/f &&
+	git branch --create-reflog f/f &&
 	git reflog exists refs/heads/f/f &&
 	git config branch.f/f.dummy Hello &&
 	git branch -c f/f g/g &&
@@ -496,7 +496,7 @@ test_expect_success 'git branch -c f/f g/g should work' '
 '
 
 test_expect_success 'git branch -c m2 m2 should work' '
-	git branch -l m2 &&
+	git branch --create-reflog m2 &&
 	git reflog exists refs/heads/m2 &&
 	git config branch.m2.dummy Hello &&
 	git branch -c m2 m2 &&
@@ -505,18 +505,18 @@ test_expect_success 'git branch -c m2 m2 should work' '
 '
 
 test_expect_success 'git branch -c zz zz/zz should fail' '
-	git branch -l zz &&
+	git branch --create-reflog zz &&
 	git reflog exists refs/heads/zz &&
 	test_must_fail git branch -c zz zz/zz
 '
 
 test_expect_success 'git branch -c b/b b should fail' '
-	git branch -l b/b &&
+	git branch --create-reflog b/b &&
 	test_must_fail git branch -c b/b b
 '
 
 test_expect_success 'git branch -C o/q o/p should work when o/p exists' '
-	git branch -l o/q &&
+	git branch --create-reflog o/q &&
 	git reflog exists refs/heads/o/q &&
 	git reflog exists refs/heads/o/p &&
 	git branch -C o/q o/p
@@ -569,10 +569,10 @@ test_expect_success 'git branch -C master5 master5 should work when master is ch
 '
 
 test_expect_success 'git branch -C ab cd should overwrite existing config for cd' '
-	git branch -l cd &&
+	git branch --create-reflog cd &&
 	git reflog exists refs/heads/cd &&
 	git config branch.cd.dummy CD &&
-	git branch -l ab &&
+	git branch --create-reflog ab &&
 	git reflog exists refs/heads/ab &&
 	git config branch.ab.dummy AB &&
 	git branch -C ab cd &&
@@ -684,7 +684,7 @@ test_expect_success 'renaming a symref is not allowed' '
 '
 
 test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
-	git branch -l u &&
+	git branch --create-reflog u &&
 	mv .git/logs/refs/heads/u real-u &&
 	ln -s real-u .git/logs/refs/heads/u &&
 	test_must_fail git branch -m u v
-- 
2.17.0.rc1.509.g060626845b
Previous: Jeff KingNext: Jeff King
Message 12 of 27 in “branch -l: print useful info whilst rebasing a non-local branch”
  1. branch -l: print useful info whilst rebasing a non-local branchKaartic Sivaraam, Mar 24, 2018
  2. Eric SunshineMar 25, 2018
  3. Kaartic SivaraamMar 25, 2018
  4. Jeff KingMar 25, 2018
  5. Eric SunshineMar 25, 2018
  6. Eric SunshineMar 25, 2018
  7. Jeff KingMar 25, 2018
  8. Kaartic SivaraamMar 25, 2018
  9. Jacob KellerMar 25, 2018
  10. Jeff KingMar 26, 2018
  11. 1/5 t3200: unset core.logallrefupdates when testing reflog creationJeff King, Mar 26, 2018
  12. 2/5 t: switch "branch -l" to "branch --create-reflog"Jeff King, Mar 26, 2018
  13. 3/5 branch: deprecate "-l" optionJeff King, Mar 26, 2018
  14. 4/5 branch: drop deprecated "-l" optionJeff King, Mar 26, 2018
  15. 5/5 branch: make "-l" a synonym for "--list"Jeff King, Mar 26, 2018
  16. Eric SunshineMar 26, 2018
  17. Jacob KellerMar 26, 2018
  18. Junio C HamanoMar 25, 2018
  19. Eric SunshineMar 25, 2018
  20. Kaartic SivaraamMar 25, 2018
  21. 1/2 branch --list: print useful info whilst interactive rebasing a detached HEADKaartic Sivaraam, Apr 3, 2018
  22. 2/2 t3200: verify "branch --list" sanity when rebasing from detached HEADKaartic Sivaraam, Apr 3, 2018
  23. Eric SunshineApr 3, 2018
  24. Kaartic SivaraamApr 3, 2018
  25. 2/2 t3200: verify "branch --list" sanity when rebasing from detached HEADKaartic Sivaraam, Apr 3, 2018
  26. Eric SunshineApr 4, 2018
  27. 0/2 branch --list: print useful info whilst interactive rebasing a detached HEADKaartic Sivaraam, Apr 3, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.