diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-08-24 09:12:53 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-24 11:18:59 -0700 |
commit | 25b763ba7a544d05fc46ad601f3f9c50a4cea8b0 (patch) | |
tree | af6b22fc2b3422382f38173ac7f4538553398d6f /submodule.c | |
parent | b5e823594cff190bc18361207a89b08d57b038d7 (diff) | |
download | git-25b763ba7a544d05fc46ad601f3f9c50a4cea8b0.tar.gz |
builtin/am: introduce write_state_*() helper functions
There are many calls to write_file() that repeat the same pattern in
the implementation of the builtin version of "am". They all share
the same traits, i.e they
- produce a text file with a single string in it;
- have enough information to produce the entire contents of that
file;
- generate the pathname of the file by making a call to am_path(); and
- they ask write_file() to die() upon failure.
The slight differences among the call sites throw them into roughly
three categories:
- many write either "t" or "f" based on a boolean value to a file;
- some write the integer value in decimal text;
- some others write more general string, e.g. an object name in
hex, an empty string (i.e. the presense of the file itself serves
as a flag), etc.
Introduce three helpers, write_state_bool(), write_state_count() and
write_state_text(), to reduce direct calls to write_file().
This is a preparatory step for the next step to ensure that no
"state" file this command leaves in $GIT_DIR is with an incomplete
line at the end.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
0 files changed, 0 insertions, 0 deletions