Merge branch 'fix'
* fix: Document --short and --git-dir in git-rev-parse(1) git-rev-parse: Fix --short= option parsing Prevent git-upload-pack segfault if object cannot be found Abstract test_create_repo out for use in tests. Trap exit to clean up created directory if clone fails.
This commit is contained in:
commit
0f4aa3993d
@ -77,6 +77,14 @@ OPTIONS
|
|||||||
path of the top-level directory relative to the current
|
path of the top-level directory relative to the current
|
||||||
directory (typically a sequence of "../", or an empty string).
|
directory (typically a sequence of "../", or an empty string).
|
||||||
|
|
||||||
|
--git-dir::
|
||||||
|
Show `$GIT_DIR` if defined else show the path to the .git directory.
|
||||||
|
|
||||||
|
--short, short=number::
|
||||||
|
Instead of outputting the full SHA1 values of object names try to
|
||||||
|
abbriviate them to a shorter unique name. When no length is specified
|
||||||
|
7 is used. The minimum length is 4.
|
||||||
|
|
||||||
--since=datestring, --after=datestring::
|
--since=datestring, --after=datestring::
|
||||||
Parses the date string, and outputs corresponding
|
Parses the date string, and outputs corresponding
|
||||||
--max-age= parameter for git-rev-list command.
|
--max-age= parameter for git-rev-list command.
|
||||||
|
@ -118,6 +118,7 @@ dir="$2"
|
|||||||
[ -e "$dir" ] && echo "$dir already exists." && usage
|
[ -e "$dir" ] && echo "$dir already exists." && usage
|
||||||
mkdir -p "$dir" &&
|
mkdir -p "$dir" &&
|
||||||
D=$(cd "$dir" && pwd) &&
|
D=$(cd "$dir" && pwd) &&
|
||||||
|
trap 'err=$?; rm -r $D; exit $err' exit
|
||||||
case "$bare" in
|
case "$bare" in
|
||||||
yes) GIT_DIR="$D" ;;
|
yes) GIT_DIR="$D" ;;
|
||||||
*) GIT_DIR="$D/.git" ;;
|
*) GIT_DIR="$D/.git" ;;
|
||||||
@ -255,3 +256,6 @@ Pull: $head_points_at:$origin" &&
|
|||||||
git checkout
|
git checkout
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
trap - exit
|
||||||
|
|
||||||
|
@ -226,12 +226,12 @@ int main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--short") ||
|
if (!strcmp(arg, "--short") ||
|
||||||
!strncmp(arg, "--short=", 9)) {
|
!strncmp(arg, "--short=", 8)) {
|
||||||
filter &= ~(DO_FLAGS|DO_NOREV);
|
filter &= ~(DO_FLAGS|DO_NOREV);
|
||||||
verify = 1;
|
verify = 1;
|
||||||
abbrev = DEFAULT_ABBREV;
|
abbrev = DEFAULT_ABBREV;
|
||||||
if (arg[8] == '=')
|
if (arg[7] == '=')
|
||||||
abbrev = strtoul(arg + 9, NULL, 10);
|
abbrev = strtoul(arg + 8, NULL, 10);
|
||||||
if (abbrev < MINIMUM_ABBREV)
|
if (abbrev < MINIMUM_ABBREV)
|
||||||
abbrev = MINIMUM_ABBREV;
|
abbrev = MINIMUM_ABBREV;
|
||||||
else if (40 <= abbrev)
|
else if (40 <= abbrev)
|
||||||
|
@ -551,8 +551,10 @@ static void prepare_packed_git_one(char *objdir, int local)
|
|||||||
sprintf(path, "%s/pack", objdir);
|
sprintf(path, "%s/pack", objdir);
|
||||||
len = strlen(path);
|
len = strlen(path);
|
||||||
dir = opendir(path);
|
dir = opendir(path);
|
||||||
if (!dir)
|
if (!dir) {
|
||||||
|
fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
path[len++] = '/';
|
path[len++] = '/';
|
||||||
while ((de = readdir(dir)) != NULL) {
|
while ((de = readdir(dir)) != NULL) {
|
||||||
int namelen = strlen(de->d_name);
|
int namelen = strlen(de->d_name);
|
||||||
|
@ -149,6 +149,21 @@ test_expect_code () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Most tests can use the created repository, but some amy need to create more.
|
||||||
|
# Usage: test_create_repo <directory>
|
||||||
|
test_create_repo () {
|
||||||
|
test "$#" = 1 ||
|
||||||
|
error "bug in the test script: not 1 parameter to test-create-repo"
|
||||||
|
owd=`pwd`
|
||||||
|
repo="$1"
|
||||||
|
mkdir "$repo"
|
||||||
|
cd "$repo" || error "Cannot setup test environment"
|
||||||
|
"$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ 2>/dev/null ||
|
||||||
|
error "cannot run git init-db -- have you built things yet?"
|
||||||
|
mv .git/hooks .git/hooks-disabled
|
||||||
|
cd "$owd"
|
||||||
|
}
|
||||||
|
|
||||||
test_done () {
|
test_done () {
|
||||||
trap - exit
|
trap - exit
|
||||||
case "$test_failure" in
|
case "$test_failure" in
|
||||||
@ -196,9 +211,5 @@ test -d ../templates/blt || {
|
|||||||
# Test repository
|
# Test repository
|
||||||
test=trash
|
test=trash
|
||||||
rm -fr "$test"
|
rm -fr "$test"
|
||||||
mkdir "$test"
|
test_create_repo $test
|
||||||
cd "$test" || error "Cannot setup test environment"
|
cd "$test"
|
||||||
"$GIT_EXEC_PATH/git" init-db --template=../../templates/blt/ 2>/dev/null ||
|
|
||||||
error "cannot run git init-db -- have you built things yet?"
|
|
||||||
|
|
||||||
mv .git/hooks .git/hooks-disabled
|
|
||||||
|
@ -216,6 +216,9 @@ static int send_ref(const char *refname, const unsigned char *sha1)
|
|||||||
static char *capabilities = "multi_ack";
|
static char *capabilities = "multi_ack";
|
||||||
struct object *o = parse_object(sha1);
|
struct object *o = parse_object(sha1);
|
||||||
|
|
||||||
|
if (!o)
|
||||||
|
die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));
|
||||||
|
|
||||||
if (capabilities)
|
if (capabilities)
|
||||||
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
|
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
|
||||||
0, capabilities);
|
0, capabilities);
|
||||||
|
Loading…
Reference in New Issue
Block a user