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

[PATCH 0/3] bring some tests to newer style.

From
Stefan Beller <sbeller@google.com>
Date
Sep 21, 2018, 23:58 UTC
Message-ID
<20180921235833.99045-1-sbeller@google.com>

The old formatting style is a real hindrance of getting people up to speed contributing as they use existing code as an example and follow that style. So let's get rid of the old style and reformat it in our current style.

This was reported off list by Derrick and Jeff as both of them followed outdated formatting style for their first patches only to have a long discussion on the mailing list on style.

The tests changed are not modified in origin/master..origin/pu,
and they were changed using a hacky script:
--8<--
#!/usr/bin/python
import sys
def applyformat(fname):
	with open(fname, 'r') as f:
		lines = f.readlines()
		state = "lookingforstart"
		outlines = []
		for line in lines:
			if state == "lookingforstart":
				if line == "test_expect_success \\\n":
					print "AHA!"
					state = "firstlinefound"
				else:
					outlines += [line]
			elif state == "firstlinefound":
				l = line.strip()
				must_strip = False
				if l.endswith("\\"):
					l = l[:-1]
					must_strip=True
				if l.endswith("'"):
					l = l[:-1].strip()
				if l.startswith("'"):
					line = "test_expect_success " + l + " '\n"
					outlines += [line]
					state = "re-indent-until-done"
				else:
					print "what?"
					exit(1)
			elif state == "re-indent-until-done":
				l = line.strip()
				if must_strip:
					if l.startswith("'"):
						l = l[1:]
						must_strip = False
					else:
						print "what 1?"
						exit(1)
				if l.endswith("'"):
					l = l[:-1]
					state = "lookingforstart"
				if len(l):
					line = "	" + l + "\n"
					outlines += [line]
				elif state == "lookingforstart":
					# skip an empty line before test is done
					pass
				else:
					outlines += ["\n"]
				if state == "lookingforstart":
					outlines += ["'\n"]
			else:
				print "what?"
				exit(1)
	with open(fname, 'w') as f:
		f.write(''.join(outlines))
for n in sys.argv[1:]:
	print n
	applyformat(n)
--8<--

Thanks, Stefan

Stefan Beller (3):
  t7001: reformat to newer style
  t7004: reformat style
  t0030: reformat style
 t/t0030-stripspace.sh | 525 ++++++++++++++++++++----------------------
 t/t7001-mv.sh         | 268 ++++++++++-----------
 t/t7004-tag.sh        | 149 +++++-------
 3 files changed, 444 insertions(+), 498 deletions(-)
-- 
2.19.0.444.g18242da7ef-goog
Next: Stefan Beller
Message 1 of 8 in “bring some tests to newer style.”
  1. 0/3 bring some tests to newer style.Stefan Beller, Sep 21, 2018
  2. 1/3 t7001: reformat to newer styleStefan Beller, Sep 21, 2018
  3. Derrick StoleeSep 24, 2018
  4. Junio C HamanoSep 24, 2018
  5. Stefan BellerSep 24, 2018
  6. Junio C HamanoSep 25, 2018
  7. 2/3 t7004: reformat styleStefan Beller, Sep 21, 2018
  8. 3/3 t0030: reformat styleStefan Beller, Sep 21, 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.