aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-02 03:21:23 -0500
committerJunio C Hamano <gitster@pobox.com>2017-03-02 11:05:03 -0800
commite322b60d65a14578995839caa5f48f5426236fdf (patch)
tree27b09fd5d1e06593d4c407862339be3b257859b4 /cache.h
parent13228c30a6476456ee64eb7cefb7786d82fd2ca7 (diff)
downloadgit-e322b60d65a14578995839caa5f48f5426236fdf.tar.gz
git-e322b60d65a14578995839caa5f48f5426236fdf.tar.xz
interpret_branch_name: move docstring to header file
We generally put docstrings with function declarations, because it's the callers who need to know how the function works. Let's do so for interpret_branch_name(). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index 5c035dae5..81c59d4af 100644
--- a/cache.h
+++ b/cache.h
@@ -1292,6 +1292,27 @@ extern char *oid_to_hex_r(char *out, const struct object_id *oid);
extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ * places the name of the branch in the given buf and returns the
+ * number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ * <branch> is configured to merge with (missing <branch> defaults
+ * to the current branch), and places the name of the branch in the
+ * given buf and returns the number of characters parsed if
+ * successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
extern int interpret_branch_name(const char *str, int len, struct strbuf *);
extern int get_oid_mb(const char *str, struct object_id *oid);