aboutsummaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-10-23 10:52:42 -0700
committerJunio C Hamano <gitster@pobox.com>2013-10-24 14:59:39 -0700
commitaf2a651d2ecb3967244c9a44a5813a0cf9977df5 (patch)
treeb2516b618c3bb919a571eded2da72198e1370ed0 /entry.c
parentfd356f6aa8bb75ebef56fbc61caf7e02517fa6d3 (diff)
downloadgit-af2a651d2ecb3967244c9a44a5813a0cf9977df5.tar.gz
git-af2a651d2ecb3967244c9a44a5813a0cf9977df5.tar.xz
checkout_entry(): clarify the use of topath[] parameter
The said function has this signature: extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); At first glance, it might appear that the caller of checkout_entry() can specify to which path the contents are written out by the last parameter, and it is tempting to add "const" in front of its type. In reality, however, topath[] is to point at a buffer to store the temporary path generated by the callchain originating from this function, and the temporary path is always short, much shorter than the buffer prepared by its only caller in builtin/checkout-index.c. Document the code a bit to clarify so that future callers know how to use the function better. Noticed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/entry.c b/entry.c
index fbb486310..7b7aa8167 100644
--- a/entry.c
+++ b/entry.c
@@ -234,6 +234,14 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)
return lstat(path, st);
}
+/*
+ * Write the contents from ce out to the working tree.
+ *
+ * When topath[] is not NULL, instead of writing to the working tree
+ * file named by ce, a temporary file is created by this function and
+ * its name is returned in topath[], which must be able to hold at
+ * least TEMPORARY_FILENAME_LENGTH bytes long.
+ */
int checkout_entry(struct cache_entry *ce,
const struct checkout *state, char *topath)
{