From: Junio C Hamano Date: Wed, 30 Nov 2005 19:09:33 +0000 (-0800) Subject: Merge branch 'jc/subdir' X-Git-Tag: v0.99.9l^2~23 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9cac9d368934f68e75810df95211a6522d4d139e?ds=inline;hp=-c Merge branch 'jc/subdir' --- 9cac9d368934f68e75810df95211a6522d4d139e diff --combined git-diff.sh index 7baf7044e4,e45f50ec22..b62e58341c --- a/git-diff.sh +++ b/git-diff.sh @@@ -7,6 -7,13 +7,11 @@@ rev=$(git-rev-parse --revs-only --no-fl flags=$(git-rev-parse --no-revs --flags --sq "$@") files=$(git-rev-parse --no-revs --no-flags --sq "$@") -: ${flags:="'-M' '-p'"} - + die () { + echo >&2 "$*" + exit 1 + } + # 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. case "$rev" in @@@ -18,21 -25,6 +23,21 @@@ esac esac +# If we do not have --name-status, --name-only nor -r, default to -p. +# If we do not have -B nor -C, default to -M. +case " $flags " in +*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* ) + ;; +*) + flags="$flags'-p' " ;; +esac +case " $flags " in +*" '-"[BCM]* | *" '--find-copies-harder' "*) + ;; # something like -M50. +*) + flags="$flags'-M' " ;; +esac + case "$rev" in ?*' '?*' '?*) echo >&2 "I don't understand" diff --combined http-push.c index fc013ec139,c6e782cbed..fe925609b4 --- a/http-push.c +++ b/http-push.c @@@ -1008,7 -1008,9 +1008,7 @@@ static int unlock_remote(struct active_ if (lock->owner != NULL) free(lock->owner); free(lock->url); -/* Freeing the token causes a segfault... free(lock->token); -*/ free(lock); return rc; @@@ -1237,6 -1239,7 +1237,7 @@@ int main(int argc, char **argv int rc = 0; int i; + setup_git_directory(); setup_ident(); remote = xmalloc(sizeof(*remote)); @@@ -1271,9 -1274,6 +1272,9 @@@ break; } + if (!remote->url) + usage(http_push_usage); + memset(remote_dir_exists, 0, 256); http_init(); diff --combined setup.c index 3286a568ed,bde590f7cc..d3556edf12 --- a/setup.c +++ b/setup.c @@@ -47,6 -47,21 +47,21 @@@ const char *prefix_path(const char *pre 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 *entry = *pathspec; @@@ -92,7 -107,7 +107,7 @@@ static int is_toplevel_directory(void 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]; int len, offset; @@@ -116,7 -131,7 +131,7 @@@ if (validate_symref(path)) goto bad_dir_environ; if (getenv(DB_ENVIRONMENT)) { - if (access(DB_ENVIRONMENT, X_OK)) + if (access(getenv(DB_ENVIRONMENT), X_OK)) goto bad_dir_environ; } else { @@@ -139,8 -154,15 +154,15 @@@ break; chdir(".."); 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"); + } } while (cwd[--offset] != '/'); } @@@ -172,7 -194,7 +194,7 @@@ int check_repository_format(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(); return retval; }