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

Re: Simplify '--prett=xyz' options

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Aug 15, 2009, 21:39 UTC
Message-ID
<alpine.LFD.2.01.0908151434250.3162@localhost.localdomain>
In-Reply-To
<alpine.LFD.2.01.0908151236250.3162@localhost.localdomain>
On Sat, 15 Aug 2009, Linus Torvalds wrote:
> 
> I would like to also make "--pretty=oneline" have the same abbrev-commit 
> semantics as "--oneline" has, but I didn't actually do that change.
Here's a patch if anybody cares.
It basically replaces the tests that do
	cut -b42-
or
	sed -e "s/^.\{41\}//"
(to get just the subject) with
	sed -e "s/^[0-9a-f]* //"

instead (which is an already pre-existing pattern that some other tests used).

The patch itself was trivial. The only question is whether the semantic change is ok (it certainly makes _sense_, it's just silly how "--oneline" is different from "--pretty=oneline").

This patch obviously depends on the previous one, since it just removes the special-casing of "--oneline" (it now falls out automatically from the "if you can't recognize the flag, see if it's a format flag" logic, and is no longer a special case).

The 'format/tformat' misdesigns I've not touched.
		Linus
---
 pretty.c                      |    4 +++-
 revision.c                    |    4 ----
 t/t3413-rebase-hook.sh        |    2 +-
 t/t5510-fetch.sh              |    2 +-
 t/t6009-rev-list-parent.sh    |    2 +-
 t/t9108-git-svn-glob.sh       |    4 ++--
 t/t9109-git-svn-multi-glob.sh |    6 +++---
 7 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/pretty.c b/pretty.c
index 1a76320..6d0fa60 100644
--- a/pretty.c
+++ b/pretty.c
@@ -52,8 +52,10 @@ int try_get_commit_format(const char *arg, struct rev_info *rev)
 	for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
 		if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
 		    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
-			if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
+			if (cmt_fmts[i].v == CMIT_FMT_ONELINE) {
 				rev->use_terminator = 1;
+				rev->abbrev_commit = 1;
+			}
 			rev->commit_format = cmt_fmts[i].v;
 			return 1;
 		}
diff --git a/revision.c b/revision.c
index bdace8b..b7f047a 100644
--- a/revision.c
+++ b/revision.c
@@ -1126,10 +1126,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!prefixcmp(arg, "--pretty=")) {
 		revs->verbose_header = 1;
 		get_commit_format(arg+9, revs);
-	} else if (!strcmp(arg, "--oneline")) {
-		revs->verbose_header = 1;
-		get_commit_format("oneline", revs);
-		revs->abbrev_commit = 1;
 	} else if (!strcmp(arg, "--graph")) {
 		revs->topo_order = 1;
 		revs->rewrite_parents = 1;
diff --git a/t/t3413-rebase-hook.sh b/t/t3413-rebase-hook.sh
index 098b755..2f14c5c 100755
--- a/t/t3413-rebase-hook.sh
+++ b/t/t3413-rebase-hook.sh
@@ -19,7 +19,7 @@ test_expect_success setup '
 	test_tick &&
 	git commit -m side &&
 	git checkout master &&
-	git log --pretty=oneline --abbrev-commit --graph --all &&
+	git log --oneline --graph --all &&
 	git branch test side
 '
 
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index d13c806..62a45c0 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -168,7 +168,7 @@ test_expect_success 'bundle 1 has only 3 files ' '
 test_expect_success 'unbundle 2' '
 	cd "$D/bundle" &&
 	git fetch ../bundle2 master:master &&
-	test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
+	test "tip" = "$(git log -1 --pretty=oneline master | sed 's/^[0-9a-f]* //')"
 '
 
 test_expect_success 'bundle does not prerequisite objects' '
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index c8a96a9..9a90ce8 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -24,7 +24,7 @@ test_expect_success setup '
 	commit three &&
 	commit four &&
 
-	git log --pretty=oneline --abbrev-commit
+	git log --oneline
 '
 
 test_expect_success 'one is ancestor of others and should not be shown' '
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index d732d31..4d386f2 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '
 	                 "tags/*/src/a:refs/remotes/tags/*" &&
 	git svn multi-fetch &&
 	git log --pretty=oneline refs/remotes/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.end &&
+	    sed -e "s/^[0-9a-f]* //" > output.end &&
 	test_cmp expect.end output.end &&
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/start`" &&
@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '
 	test `git rev-parse refs/remotes/two/tags/end~3` = \
 	     `git rev-parse refs/remotes/two/branches/start` &&
 	git log --pretty=oneline refs/remotes/two/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.two &&
+	    sed -e "s/^[0-9a-f]* //" > output.two &&
 	test_cmp expect.two output.two
 	'
 
diff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh
index c318f9f..da93cf1 100755
--- a/t/t9109-git-svn-multi-glob.sh
+++ b/t/t9109-git-svn-multi-glob.sh
@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '
 	                 "tags/*/src/a:refs/remotes/tags/*" &&
 	git svn multi-fetch &&
 	git log --pretty=oneline refs/remotes/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.end &&
+	    sed -e "s/^[0-9a-f]* //" > output.end &&
 	test_cmp expect.end output.end &&
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/v1/start`" &&
@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '
 	test `git rev-parse refs/remotes/two/tags/end~3` = \
 	     `git rev-parse refs/remotes/two/branches/v1/start` &&
 	git log --pretty=oneline refs/remotes/two/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.two &&
+	    sed -e "s/^[0-9a-f]* //" > output.two &&
 	test_cmp expect.two output.two
 	'
 cat > expect.four <<EOF
@@ -131,7 +131,7 @@ test_expect_success 'test another branch' '
 	test `git rev-parse refs/remotes/four/tags/next~2` = \
 	     `git rev-parse refs/remotes/four/branches/v2/start` &&
 	git log --pretty=oneline refs/remotes/four/tags/next | \
-	    sed -e "s/^.\{41\}//" > output.four &&
+	    sed -e "s/^[0-9a-f]* //" > output.four &&
 	test_cmp expect.four output.four
 	'
 
Previous: Linus TorvaldsNext: Johannes Schindelin
Message 8 of 9 in “Simplify '--prett=xyz' options”
  1. Linus TorvaldsAug 15, 2009
  2. Thomas RastAug 15, 2009
  3. Linus TorvaldsAug 15, 2009
  4. Junio C HamanoAug 15, 2009
  5. Linus TorvaldsAug 15, 2009
  6. Avery PennarunAug 15, 2009
  7. Linus TorvaldsAug 15, 2009
  8. Linus TorvaldsAug 15, 2009
  9. Johannes SchindelinAug 15, 2009

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.