summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-06-13 12:19:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-13 18:49:41 (GMT)
commita76295da784501f74803053606112f62ccff3828 (patch)
tree5afa51eff09fa537e06151599f01a9e330450eef /builtin/rev-parse.c
parenta0a967568e8de5306d1889583c4dad0ff937f5ef (diff)
downloadgit-a76295da784501f74803053606112f62ccff3828.zip
git-a76295da784501f74803053606112f62ccff3828.tar.gz
git-a76295da784501f74803053606112f62ccff3828.tar.bz2
rev-parse: add --shared-index-path to get shared index path
Normally scripts do not have to be aware about split indexes because all shared indexes are in $GIT_DIR. A simple "mv $tmp_index $GIT_DIR/somewhere" is enough. Scripts that generate temporary indexes and move them across repos must be aware about split index and copy the shared file as well. This option enables that. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1a6122d..8102aaa 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -11,6 +11,7 @@
#include "parse-options.h"
#include "diff.h"
#include "revision.h"
+#include "split-index.h"
#define DO_REVS 1
#define DO_NOREV 2
@@ -775,6 +776,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
: "false");
continue;
}
+ if (!strcmp(arg, "--shared-index-path")) {
+ if (read_cache() < 0)
+ die(_("Could not read the index"));
+ if (the_index.split_index) {
+ const unsigned char *sha1 = the_index.split_index->base_sha1;
+ puts(git_path("sharedindex.%s", sha1_to_hex(sha1)));
+ }
+ continue;
+ }
if (starts_with(arg, "--since=")) {
show_datestring("--max-age=", arg+8);
continue;