Skip to content

"am" state file fix with write_file() clean-up

Junio C Hamano git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5builtin/am: introduce write_state_*() helper functionsbuiltin/am.c+41 -270 replies
2/5builtin/am: make sure state files are textbuiltin/am.c+2 -20 replies
3/5write_file(): introduce an explicit WRITE_FILE_GENTLY requestcache.h setup.c transport.c +1 more+18 -45 replies
4/5write_file(): do not leave incomplete line at the endcache.h wrapper.c+4 -00 replies
5/5write_file(): clean up transitional mess of flag words and terminating LFbuiltin/am.c builtin/init-db.c builtin/worktree.c +5 more+18 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] "am" state file fix with write_file() clean-up

So here is an solution based on the "write_file() is primarily to produce text, so it should be able to correct the incomplete line at the end" approach.

The first one is Peff's idea to consolidate callers in "am", in a more concrete form.

The second is the fix to $gmane/276238.

The remainder is to clean up write_file() helper function. All callers except for two were passing 1 as one parameter, whose meaning was not all obvious to a casual reader.

In patch 3/5, we flip the default behaviour of write_file() to die upon error unless explicitly asked not to with WRITE_FILE_GENTLY flag, and change the two oddball callers to pass this new flag.

In patch 4/5, we enhance the default behaviour of write_file() to complete an incomplete line at the end, unless asked not to with WRITE_FILE_BINARY flag; nobody passes this because all existing callers want to produce a text file.

In patch 5/5, the transitional noise left by patches 3 and 4 are cleaned up by updating the non-binary callers not to add LF themselves and by changing the callers that pass 1 as flags parameter to pass 0 (as bit (1<<0) is a no-op since patch 3/5).

The series is built on top of b5e8235, the current tip of the pt/am-builtin-options topic.

Junio C Hamano (5):
builtin/am: introduce write_state_*() helper functions builtin/am: make sure state files are text
write_file(): introduce an explicit WRITE_FILE_GENTLY request write_file(): do not leave incomplete line at the end write_file(): clean up transitional mess of flag words and terminating LF

 builtin/am.c       | 68 ++++++++++++++++++++++++++++++++----------------------
 builtin/init-db.c  |  2 +-
 builtin/worktree.c | 10 ++++----
 cache.h            | 16 ++++++++++++-
 daemon.c           |  2 +-
 setup.c            |  2 +-
 submodule.c        |  2 +-
 transport.c        |  2 +-
 wrapper.c          | 13 +++++++++--
 9 files changed, 77 insertions(+), 40 deletions(-)
Signature · 1 line
2.5.0-568-g53a3e28