Merge branch 'jc/subdir'
This commit is contained in:
18
apply.c
18
apply.c
@ -16,6 +16,9 @@
|
|||||||
// --numstat does numeric diffstat, and doesn't actually apply
|
// --numstat does numeric diffstat, and doesn't actually apply
|
||||||
// --index-info shows the old and new index info for paths if available.
|
// --index-info shows the old and new index info for paths if available.
|
||||||
//
|
//
|
||||||
|
static const char *prefix;
|
||||||
|
static int prefix_length = -1;
|
||||||
|
|
||||||
static int allow_binary_replacement = 0;
|
static int allow_binary_replacement = 0;
|
||||||
static int check_index = 0;
|
static int check_index = 0;
|
||||||
static int write_index = 0;
|
static int write_index = 0;
|
||||||
@ -1706,6 +1709,12 @@ static int use_patch(struct patch *p)
|
|||||||
return 0;
|
return 0;
|
||||||
x = x->next;
|
x = x->next;
|
||||||
}
|
}
|
||||||
|
if (0 < prefix_length) {
|
||||||
|
int pathlen = strlen(pathname);
|
||||||
|
if (pathlen <= prefix_length ||
|
||||||
|
memcmp(prefix, pathname, prefix_length))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1845,6 +1854,15 @@ int main(int argc, char **argv)
|
|||||||
line_termination = 0;
|
line_termination = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (check_index && prefix_length < 0) {
|
||||||
|
prefix = setup_git_directory();
|
||||||
|
prefix_length = prefix ? strlen(prefix) : 0;
|
||||||
|
git_config(git_default_config);
|
||||||
|
}
|
||||||
|
if (0 < prefix_length)
|
||||||
|
arg = prefix_filename(prefix, prefix_length, arg);
|
||||||
|
|
||||||
fd = open(arg, O_RDONLY);
|
fd = open(arg, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
usage(apply_usage);
|
usage(apply_usage);
|
||||||
|
2
cache.h
2
cache.h
@ -147,8 +147,10 @@ extern char *get_graft_file(void);
|
|||||||
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
|
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
|
||||||
|
|
||||||
extern const char **get_pathspec(const char *prefix, const char **pathspec);
|
extern const char **get_pathspec(const char *prefix, const char **pathspec);
|
||||||
|
extern const char *setup_git_directory_gently(int *);
|
||||||
extern const char *setup_git_directory(void);
|
extern const char *setup_git_directory(void);
|
||||||
extern const char *prefix_path(const char *prefix, int len, const char *path);
|
extern const char *prefix_path(const char *prefix, int len, const char *path);
|
||||||
|
extern const char *prefix_filename(const char *prefix, int len, const char *path);
|
||||||
|
|
||||||
#define alloc_nr(x) (((x)+16)*3/2)
|
#define alloc_nr(x) (((x)+16)*3/2)
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
|
||||||
|
static const char *prefix;
|
||||||
|
static int prefix_length;
|
||||||
|
|
||||||
static struct checkout state = {
|
static struct checkout state = {
|
||||||
.base_dir = "",
|
.base_dir = "",
|
||||||
.base_dir_len = 0,
|
.base_dir_len = 0,
|
||||||
@ -69,6 +72,10 @@ static int checkout_all(void)
|
|||||||
struct cache_entry *ce = active_cache[i];
|
struct cache_entry *ce = active_cache[i];
|
||||||
if (ce_stage(ce))
|
if (ce_stage(ce))
|
||||||
continue;
|
continue;
|
||||||
|
if (prefix && *prefix &&
|
||||||
|
( ce_namelen(ce) <= prefix_length ||
|
||||||
|
memcmp(prefix, ce->name, prefix_length) ))
|
||||||
|
continue;
|
||||||
if (checkout_entry(ce, &state) < 0)
|
if (checkout_entry(ce, &state) < 0)
|
||||||
errs++;
|
errs++;
|
||||||
}
|
}
|
||||||
@ -91,6 +98,9 @@ int main(int argc, char **argv)
|
|||||||
int newfd = -1;
|
int newfd = -1;
|
||||||
int all = 0;
|
int all = 0;
|
||||||
|
|
||||||
|
prefix = setup_git_directory();
|
||||||
|
prefix_length = prefix ? strlen(prefix) : 0;
|
||||||
|
|
||||||
if (read_cache() < 0) {
|
if (read_cache() < 0) {
|
||||||
die("invalid cache");
|
die("invalid cache");
|
||||||
}
|
}
|
||||||
@ -155,7 +165,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
die("git-checkout-index: don't mix '--all' and explicit filenames");
|
die("git-checkout-index: don't mix '--all' and explicit filenames");
|
||||||
checkout_file(arg);
|
checkout_file(prefix_path(prefix, prefix_length, arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
|
@ -271,6 +271,8 @@ int main(int argc, char **argv)
|
|||||||
int fd[2];
|
int fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
nr_heads = 0;
|
nr_heads = 0;
|
||||||
heads = NULL;
|
heads = NULL;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
@ -91,6 +91,8 @@ int main(int argc, char **argv)
|
|||||||
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
|
if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
|
||||||
usage(commit_tree_usage);
|
usage(commit_tree_usage);
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
check_valid(tree_sha1, "tree");
|
check_valid(tree_sha1, "tree");
|
||||||
for (i = 2; i < argc; i += 2) {
|
for (i = 2; i < argc; i += 2) {
|
||||||
char *a, *b;
|
char *a, *b;
|
||||||
|
@ -316,6 +316,8 @@ int main(int argc, char **argv)
|
|||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
struct entry *entry;
|
struct entry *entry;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
if (argc != 2 || get_sha1(argv[1], sha1))
|
if (argc != 2 || get_sha1(argv[1], sha1))
|
||||||
usage("git-convert-objects <sha1>");
|
usage("git-convert-objects <sha1>");
|
||||||
|
|
||||||
|
@ -424,6 +424,8 @@ int main(int argc, char **argv)
|
|||||||
int fd[2];
|
int fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
nr_heads = 0;
|
nr_heads = 0;
|
||||||
heads = NULL;
|
heads = NULL;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
@ -431,6 +431,8 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int i, heads;
|
int i, heads;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
die "usage: git add [-n] [-v] <file>..."
|
die "usage: git add [-n] [-v] <file>..."
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. git-sh-setup
|
GIT_DIR=`git-rev-parse --git-dir` || exit $?
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]
|
echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]
|
||||||
@ -12,8 +17,7 @@ If two arguments, create a new branch <branchname> based off of <start-point>.
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
headref=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD |
|
headref=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
|
||||||
sed -e 's|^refs/heads/||')
|
|
||||||
|
|
||||||
delete_branch () {
|
delete_branch () {
|
||||||
option="$1"
|
option="$1"
|
||||||
@ -114,4 +118,3 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
git update-ref "refs/heads/$branchname" $rev
|
git update-ref "refs/heads/$branchname" $rev
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# Copyright (c) 2005 Junio C Hamano
|
# Copyright (c) 2005 Junio C Hamano
|
||||||
#
|
#
|
||||||
|
|
||||||
. git-sh-setup
|
GIT_DIR=`git-rev-parse --git-dir` || exit $?
|
||||||
|
|
||||||
dc </dev/null 2>/dev/null || {
|
dc </dev/null 2>/dev/null || {
|
||||||
# This is not a real DC at all -- it just knows how
|
# This is not a real DC at all -- it just knows how
|
||||||
|
@ -7,6 +7,11 @@ rev=$(git-rev-parse --revs-only --no-flags --sq "$@") || exit
|
|||||||
flags=$(git-rev-parse --no-revs --flags --sq "$@")
|
flags=$(git-rev-parse --no-revs --flags --sq "$@")
|
||||||
files=$(git-rev-parse --no-revs --no-flags --sq "$@")
|
files=$(git-rev-parse --no-revs --no-flags --sq "$@")
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# I often say 'git diff --cached -p' and get scolded by git-diff-files, but
|
# I often say 'git diff --cached -p' and get scolded by git-diff-files, but
|
||||||
# obviously I mean 'git diff --cached -p HEAD' in that case.
|
# obviously I mean 'git diff --cached -p HEAD' in that case.
|
||||||
case "$rev" in
|
case "$rev" in
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. git-sh-setup
|
GIT_DIR=`git-rev-parse --git-dir` || exit $?
|
||||||
|
|
||||||
laf="$GIT_DIR/lost-found"
|
laf="$GIT_DIR/lost-found"
|
||||||
rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
|
rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
|
||||||
|
|
||||||
|
@ -6,6 +6,11 @@ usage () {
|
|||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
while case "$#" in 0) break;; esac
|
while case "$#" in 0) break;; esac
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
LF='
|
LF='
|
||||||
'
|
'
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# The first parameters up to -- are merge bases; the rest are heads.
|
# The first parameters up to -- are merge bases; the rest are heads.
|
||||||
bases= head= remotes= sep_seen=
|
bases= head= remotes= sep_seen=
|
||||||
for arg
|
for arg
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (c) 2005 Linus Torvalds
|
# Copyright (c) 2005 Linus Torvalds
|
||||||
|
|
||||||
. git-sh-setup
|
GIT_DIR=`git-rev-parse --git-dir` || exit $?
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]"
|
echo >&2 "Usage: git-tag [-a | -s | -u <key-id>] [-f | -d] [-m <msg>] <tagname> [<head>]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
annotate=
|
annotate=
|
||||||
signed=
|
signed=
|
||||||
force=
|
force=
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. git-sh-setup
|
|
||||||
|
GIT_DIR=`git-rev-parse --git-dir` || exit $?
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo >&2 "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
type="$(git-cat-file -t "$1" 2>/dev/null)" ||
|
type="$(git-cat-file -t "$1" 2>/dev/null)" ||
|
||||||
die "$1: no such object."
|
die "$1: no such object."
|
||||||
@ -7,6 +13,9 @@ type="$(git-cat-file -t "$1" 2>/dev/null)" ||
|
|||||||
test "$type" = tag ||
|
test "$type" = tag ||
|
||||||
die "$1: cannot verify a non-tag object of type $type."
|
die "$1: cannot verify a non-tag object of type $type."
|
||||||
|
|
||||||
git-cat-file tag "$1" > .tmp-vtag || exit 1
|
git-cat-file tag "$1" >"$GIT_DIR/.tmp-vtag" || exit 1
|
||||||
cat .tmp-vtag | sed '/-----BEGIN PGP/Q' | gpg --verify .tmp-vtag - || exit 1
|
cat "$GIT_DIR/.tmp-vtag" |
|
||||||
rm -f .tmp-vtag
|
sed '/-----BEGIN PGP/Q' |
|
||||||
|
gpg --verify "$GIT_DIR/.tmp-vtag" - || exit 1
|
||||||
|
rm -f "$GIT_DIR/.tmp-vtag"
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
const char *type = "blob";
|
const char *type = "blob";
|
||||||
int write_object = 0;
|
int write_object = 0;
|
||||||
|
const char *prefix = NULL;
|
||||||
|
int prefix_length = -1;
|
||||||
|
|
||||||
for (i = 1 ; i < argc; i++) {
|
for (i = 1 ; i < argc; i++) {
|
||||||
if (!strcmp(argv[i], "-t")) {
|
if (!strcmp(argv[i], "-t")) {
|
||||||
@ -36,10 +38,20 @@ int main(int argc, char **argv)
|
|||||||
die(hash_object_usage);
|
die(hash_object_usage);
|
||||||
type = argv[i];
|
type = argv[i];
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "-w"))
|
else if (!strcmp(argv[i], "-w")) {
|
||||||
|
if (prefix_length < 0) {
|
||||||
|
prefix = setup_git_directory();
|
||||||
|
prefix_length = prefix ? strlen(prefix) : 0;
|
||||||
|
}
|
||||||
write_object = 1;
|
write_object = 1;
|
||||||
else
|
}
|
||||||
hash_object(argv[i], type, write_object);
|
else {
|
||||||
|
const char *arg = argv[i];
|
||||||
|
if (0 <= prefix_length)
|
||||||
|
arg = prefix_filename(prefix, prefix_length,
|
||||||
|
arg);
|
||||||
|
hash_object(arg, type, write_object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -922,6 +922,8 @@ int main(int argc, char **argv)
|
|||||||
int arg = 1;
|
int arg = 1;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
while (arg < argc && argv[arg][0] == '-') {
|
while (arg < argc && argv[arg][0] == '-') {
|
||||||
if (argv[arg][1] == 't') {
|
if (argv[arg][1] == 't') {
|
||||||
get_tree = 1;
|
get_tree = 1;
|
||||||
|
@ -1237,6 +1237,7 @@ int main(int argc, char **argv)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
setup_ident();
|
setup_ident();
|
||||||
|
|
||||||
remote = xmalloc(sizeof(*remote));
|
remote = xmalloc(sizeof(*remote));
|
||||||
|
@ -207,6 +207,8 @@ int main(int argc, char **argv)
|
|||||||
char *commit_id;
|
char *commit_id;
|
||||||
int arg = 1;
|
int arg = 1;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
while (arg < argc && argv[arg][0] == '-') {
|
while (arg < argc && argv[arg][0] == '-') {
|
||||||
if (argv[arg][1] == 't')
|
if (argv[arg][1] == 't')
|
||||||
get_tree = 1;
|
get_tree = 1;
|
||||||
|
@ -236,6 +236,8 @@ int main(int argc, char **argv)
|
|||||||
struct commit *rev1, *rev2;
|
struct commit *rev1, *rev2;
|
||||||
unsigned char rev1key[20], rev2key[20];
|
unsigned char rev1key[20], rev2key[20];
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
while (1 < argc && argv[1][0] == '-') {
|
while (1 < argc && argv[1][0] == '-') {
|
||||||
char *arg = argv[1];
|
char *arg = argv[1];
|
||||||
if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
|
if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
|
||||||
|
@ -102,6 +102,7 @@ int main(int argc, char **argv)
|
|||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
|
usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
read_cache();
|
read_cache();
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
|
2
mktag.c
2
mktag.c
@ -111,6 +111,8 @@ int main(int argc, char **argv)
|
|||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
usage("cat <signaturefile> | git-mktag");
|
usage("cat <signaturefile> | git-mktag");
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
// Read the signature
|
// Read the signature
|
||||||
size = 0;
|
size = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -473,6 +473,8 @@ int main(int argc, char **argv)
|
|||||||
struct object_entry **list;
|
struct object_entry **list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
|
@ -600,6 +600,8 @@ int main(int argc, char **argv)
|
|||||||
unsigned char *sha1;
|
unsigned char *sha1;
|
||||||
char buf[42]; /* 40 byte sha1 + \n + \0 */
|
char buf[42]; /* 40 byte sha1 + \n + \0 */
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
if(!strcmp(arg, "--")) {
|
if(!strcmp(arg, "--")) {
|
||||||
|
@ -27,6 +27,9 @@ int main(int argc, char **argv)
|
|||||||
char *dest = NULL;
|
char *dest = NULL;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
int nongit = 0;
|
||||||
|
|
||||||
|
setup_git_directory_gently(&nongit);
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
|
@ -58,6 +58,8 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
|
@ -629,6 +629,8 @@ int main(int argc, char **argv)
|
|||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
merge_fn_t fn = NULL;
|
merge_fn_t fn = NULL;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
newfd = hold_index_file_for_update(&cache_file, get_index_file());
|
newfd = hold_index_file_for_update(&cache_file, get_index_file());
|
||||||
if (newfd < 0)
|
if (newfd < 0)
|
||||||
die("unable to create new cachefile");
|
die("unable to create new cachefile");
|
||||||
|
@ -273,6 +273,7 @@ int main(int argc, char **argv)
|
|||||||
int fd[2], ret;
|
int fd[2], ret;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
argv++;
|
argv++;
|
||||||
for (i = 1; i < argc; i++, argv++) {
|
for (i = 1; i < argc; i++, argv++) {
|
||||||
char *arg = *argv;
|
char *arg = *argv;
|
||||||
|
28
setup.c
28
setup.c
@ -47,6 +47,21 @@ const char *prefix_path(const char *prefix, int len, const char *path)
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unlike prefix_path, this should be used if the named file does
|
||||||
|
* not have to interact with index entry; i.e. name of a random file
|
||||||
|
* on the filesystem.
|
||||||
|
*/
|
||||||
|
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||||
|
{
|
||||||
|
static char path[PATH_MAX];
|
||||||
|
if (!pfx || !*pfx || arg[0] == '/')
|
||||||
|
return arg;
|
||||||
|
memcpy(path, pfx, pfx_len);
|
||||||
|
strcpy(path + pfx_len, arg);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
const char **get_pathspec(const char *prefix, const char **pathspec)
|
const char **get_pathspec(const char *prefix, const char **pathspec)
|
||||||
{
|
{
|
||||||
const char *entry = *pathspec;
|
const char *entry = *pathspec;
|
||||||
@ -92,7 +107,7 @@ static int is_toplevel_directory(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *setup_git_directory_1(void)
|
const char *setup_git_directory_gently(int *nongit_ok)
|
||||||
{
|
{
|
||||||
static char cwd[PATH_MAX+1];
|
static char cwd[PATH_MAX+1];
|
||||||
int len, offset;
|
int len, offset;
|
||||||
@ -139,8 +154,15 @@ static const char *setup_git_directory_1(void)
|
|||||||
break;
|
break;
|
||||||
chdir("..");
|
chdir("..");
|
||||||
do {
|
do {
|
||||||
if (!offset)
|
if (!offset) {
|
||||||
|
if (nongit_ok) {
|
||||||
|
if (chdir(cwd))
|
||||||
|
die("Cannot come back to cwd");
|
||||||
|
*nongit_ok = 1;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
die("Not a git repository");
|
die("Not a git repository");
|
||||||
|
}
|
||||||
} while (cwd[--offset] != '/');
|
} while (cwd[--offset] != '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +194,7 @@ int check_repository_format(void)
|
|||||||
|
|
||||||
const char *setup_git_directory(void)
|
const char *setup_git_directory(void)
|
||||||
{
|
{
|
||||||
const char *retval = setup_git_directory_1();
|
const char *retval = setup_git_directory_gently(NULL);
|
||||||
check_repository_format();
|
check_repository_format();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,8 @@ int main(int argc, char **argv)
|
|||||||
prog = getenv("GIT_SSH_PUSH");
|
prog = getenv("GIT_SSH_PUSH");
|
||||||
if (!prog) prog = "git-ssh-upload";
|
if (!prog) prog = "git-ssh-upload";
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
while (arg < argc && argv[arg][0] == '-') {
|
while (arg < argc && argv[arg][0] == '-') {
|
||||||
if (argv[arg][1] == 't') {
|
if (argv[arg][1] == 't') {
|
||||||
get_tree = 1;
|
get_tree = 1;
|
||||||
|
@ -121,6 +121,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
prog = getenv(COUNTERPART_ENV_NAME);
|
prog = getenv(COUNTERPART_ENV_NAME);
|
||||||
if (!prog) prog = COUNTERPART_PROGRAM_NAME;
|
if (!prog) prog = COUNTERPART_PROGRAM_NAME;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
while (arg < argc && argv[arg][0] == '-') {
|
while (arg < argc && argv[arg][0] == '-') {
|
||||||
if (argv[arg][1] == 'w')
|
if (argv[arg][1] == 'w')
|
||||||
arg++;
|
arg++;
|
||||||
|
@ -407,6 +407,8 @@ int main(int argc, char **argv)
|
|||||||
void *buffer;
|
void *buffer;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 3:
|
case 3:
|
||||||
basedir = argv[2];
|
basedir = argv[2];
|
||||||
|
@ -29,6 +29,8 @@ int main(int argc, char **argv)
|
|||||||
if (argc != 2 || get_sha1(argv[1], sha1))
|
if (argc != 2 || get_sha1(argv[1], sha1))
|
||||||
usage("git-unpack-file <sha1>");
|
usage("git-unpack-file <sha1>");
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
puts(create_temp_file(sha1));
|
puts(create_temp_file(sha1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,8 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
for (i = 1 ; i < argc; i++) {
|
for (i = 1 ; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
|
@ -19,5 +19,7 @@ int main(int ac, char **av)
|
|||||||
if (i != ac)
|
if (i != ac)
|
||||||
usage(update_server_info_usage);
|
usage(update_server_info_usage);
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
return !!update_server_info(force);
|
return !!update_server_info(force);
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,12 @@ static int write_tree(struct cache_entry **cachep, int maxentries, const char *b
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, funny;
|
int i, funny;
|
||||||
int entries = read_cache();
|
int entries;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
|
|
||||||
|
setup_git_directory();
|
||||||
|
|
||||||
|
entries = read_cache();
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
if (!strcmp(argv[1], "--missing-ok"))
|
if (!strcmp(argv[1], "--missing-ok"))
|
||||||
missing_ok = 1;
|
missing_ok = 1;
|
||||||
|
Reference in New Issue
Block a user