+read_repo_info(char *name, size_t namelen, char *value, size_t valuelen)
+{
+ if (!opt_git_dir[0])
+ string_ncopy(opt_git_dir, name, namelen);
+ else
+ string_ncopy(opt_cdup, name, namelen);
+ return OK;
+}
+
+/* XXX: The line outputted by "--show-cdup" can be empty so the option
+ * must be the last one! */
+static int
+load_repo_info(void)
+{
+ return read_properties(popen("git rev-parse --git-dir --show-cdup 2>/dev/null", "r"),
+ "=", read_repo_info);
+}
+
+static int