Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Junio C Hamano committed Nov 19, 2005
2 parents 6eb668d + 0b42769 commit 52b6536
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 93 deletions.
4 changes: 3 additions & 1 deletion Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
-t, \--tags::
By default, the git core utilities will not fetch and store
tags under the same name as the remote repository; ask it
to do so using `--tags`.
to do so using `--tags`. Using this option will bound the
list of objects pulled to the remote tags. Commits in branches
beyond the tags will be ignored.

-u, \--update-head-ok::
By default `git-fetch` refuses to update the head which
Expand Down
8 changes: 8 additions & 0 deletions Documentation/git-pack-redundant.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ This program computes which packs in your repository
are redundant. The output is suitable for piping to
'xargs rm' if you are in the root of the repository.

git-pack-redundant accepts a list of objects on standard input. Any objects
given will be ignored when checking which packs are required. This makes the
following command useful when wanting to remove packs which contain unreachable
objects.

git-fsck-objects --full --unreachable | cut -d ' ' -f3 | \
git-pack-redundant --all | xargs rm

OPTIONS
-------

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ endif
ifeq ($(uname_O),Cygwin)
NO_STRCASESTR = YesPlease
NEEDS_LIBICONV = YesPlease
# There are conflicting reports about this.
# On some boxes NO_MMAP is needed, and not so elsewhere.
# Try uncommenting this if you see things break -- YMMV.
# NO_MMAP = YesPlease
NO_IPV6 = YesPlease
X = .exe
ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
Expand Down
54 changes: 49 additions & 5 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,52 @@ static void update_tm(struct tm *tm, unsigned long sec)
localtime_r(&n, tm);
}

static void date_yesterday(struct tm *tm, int *num)
{
update_tm(tm, 24*60*60);
}

static void date_time(struct tm *tm, int hour)
{
if (tm->tm_hour < hour)
date_yesterday(tm, NULL);
tm->tm_hour = hour;
tm->tm_min = 0;
tm->tm_sec = 0;
}

static void date_midnight(struct tm *tm, int *num)
{
date_time(tm, 0);
}

static void date_noon(struct tm *tm, int *num)
{
date_time(tm, 12);
}

static void date_tea(struct tm *tm, int *num)
{
date_time(tm, 17);
}

static const struct special {
const char *name;
void (*fn)(struct tm *, int *);
} special[] = {
{ "yesterday", date_yesterday },
{ "noon", date_noon },
{ "midnight", date_midnight },
{ "tea", date_tea },
{ NULL }
};

static const char *number_name[] = {
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine", "ten",
};

static struct typelen {
static const struct typelen {
const char *type;
int length;
} typelen[] = {
Expand All @@ -487,7 +527,8 @@ static struct typelen {

static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
{
struct typelen *tl;
const struct typelen *tl;
const struct special *s;
const char *end = date;
int n = 1, i;

Expand All @@ -502,9 +543,12 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
}
}

if (match_string(date, "yesterday") > 8) {
update_tm(tm, 24*60*60);
return end;
for (s = special; s->name; s++) {
int len = strlen(s->name);
if (match_string(date, s->name) == len) {
s->fn(tm, num);
return end;
}
}

if (!*num) {
Expand Down
25 changes: 18 additions & 7 deletions git-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. git-sh-setup || die "Not a git archive"

usage () {
echo >&2 "usage: $(basename $0)"' [-d <branch>] | [<branch> [start-point]]
echo >&2 "usage: $(basename $0)"' [-d <branch>] | [[-f] <branch> [start-point]]
If no arguments, show available branches and mark current branch with a star.
If one argument, create a new branch <branchname> based off of current HEAD.
Expand All @@ -12,11 +12,12 @@ If two arguments, create a new branch <branchname> based off of <start-point>.
exit 1
}

headref=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD |
sed -e 's|^refs/heads/||')

delete_branch () {
option="$1"
shift
headref=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD |
sed -e 's|^refs/heads/||')
for branch_name
do
case ",$headref," in
Expand Down Expand Up @@ -52,13 +53,17 @@ delete_branch () {
exit 0
}

force=
while case "$#,$1" in 0,*) break ;; *,-*) ;; *) break ;; esac
do
case "$1" in
-d | -D)
delete_branch "$@"
exit
;;
-f)
force="$1"
;;
--)
shift
break
Expand All @@ -72,8 +77,6 @@ done

case "$#" in
0)
headref=$(GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD |
sed -e 's|^refs/heads/||')
git-rev-parse --symbolic --all |
sed -ne 's|^refs/heads/||p' |
sort |
Expand All @@ -97,10 +100,18 @@ branchname="$1"

rev=$(git-rev-parse --verify "$head") || exit

[ -e "$GIT_DIR/refs/heads/$branchname" ] &&
die "$branchname already exists."
git-check-ref-format "heads/$branchname" ||
die "we do not like '$branchname' as a branch name."

if [ -e "$GIT_DIR/refs/heads/$branchname" ]
then
if test '' = "$force"
then
die "$branchname already exists."
elif test "$branchname" = "$headref"
then
die "cannot force-update the current branch."
fi
fi
git update-ref "refs/heads/$branchname" $rev

14 changes: 9 additions & 5 deletions git-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ IFS="$LF"
tags=
append=
force=
verbose=
update_head_ok=
while case "$#" in 0) break ;; esac
do
Expand All @@ -30,6 +31,9 @@ do
--update-head-o|--update-head-ok)
update_head_ok=t
;;
-v|--verbose)
verbose=Yes
;;
*)
break
;;
Expand Down Expand Up @@ -91,12 +95,12 @@ append_fetch_head () {
then
headc_=$(git-rev-parse --verify "$head_^0") || exit
echo "$headc_ $not_for_merge_ $note_" >>"$GIT_DIR/FETCH_HEAD"
echo >&2 "* committish: $head_"
echo >&2 " $note_"
[ "$verbose" ] && echo >&2 "* committish: $head_"
[ "$verbose" ] && echo >&2 " $note_"
else
echo "$head_ not-for-merge $note_" >>"$GIT_DIR/FETCH_HEAD"
echo >&2 "* non-commit: $head_"
echo >&2 " $note_"
[ "$verbose" ] && echo >&2 "* non-commit: $head_"
[ "$verbose" ] && echo >&2 " $note_"
fi
if test "$local_name_" != ""
then
Expand All @@ -116,7 +120,7 @@ fast_forward_local () {
then
if now_=$(cat "$GIT_DIR/$1") && test "$now_" = "$2"
then
echo >&2 "* $1: same as $3"
[ "$verbose" ] && echo >&2 "* $1: same as $3"
else
echo >&2 "* $1: updating with $3"
fi
Expand Down
2 changes: 1 addition & 1 deletion git-prune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ git-prune-packed $dryrun
redundant=$(git-pack-redundant --all)
if test "" != "$redundant"
then
if test "" = $dryrun
if test "" = "$dryrun"
then
echo "$redundant" | xargs rm -f
else
Expand Down
72 changes: 16 additions & 56 deletions git-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,25 @@

. git-sh-setup || die "Not a git archive."

usage="usage: $0 "'<upstream> [<head>]
Uses output from git-cherry to rebase local commits to the new head of
upstream tree.'

case "$#,$1" in
1,*..*)
upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
set x "$upstream" "$ours"
shift ;;
esac
# The other head is given
other=$(git-rev-parse --verify "$1^0") || exit

# The tree must be really really clean.
git-update-index --refresh || exit
diff=$(git-diff-index --cached --name-status -r HEAD)
case "$different" in
?*) echo "$diff"
exit 1
;;
esac

# If the branch to rebase is given, first switch to it.
case "$#" in
1) ours_symbolic=HEAD ;;
2) ours_symbolic="$2" ;;
*) die "$usage" ;;
2)
git-checkout "$2" || exit
esac

upstream=`git-rev-parse --verify "$1"` &&
ours=`git-rev-parse --verify "$ours_symbolic"` || exit
different1=$(git-diff-index --name-only --cached "$ours") &&
different2=$(git-diff-index --name-only "$ours") &&
test "$different1$different2" = "" ||
die "Your working tree does not match $ours_symbolic."

git-read-tree -m -u $ours $upstream &&
new_head=$(git-rev-parse --verify "$upstream^0") &&
git-update-ref HEAD "$new_head" || exit

tmp=.rebase-tmp$$
fail=$tmp-fail
trap "rm -rf $tmp-*" 1 2 3 15

>$fail

git-cherry -v $upstream $ours |
while read sign commit msg
do
case "$sign" in
-)
echo >&2 "* Already applied: $msg"
continue ;;
esac
echo >&2 "* Applying: $msg"
S=$(git-rev-parse --verify HEAD) &&
git-cherry-pick --replay $commit || {
echo >&2 "* Not applying the patch and continuing."
echo $commit >>$fail
git-reset --hard $S
}
done
if test -s $fail
then
echo >&2 Some commits could not be rebased, check by hand:
cat >&2 $fail
echo >&2 "(the same list of commits are found in $tmp)"
exit 1
else
rm -f $fail
fi
# Rewind the head to "$other"
git-reset --hard "$other"
git-format-patch -k --stdout --full-index "$other" ORIG_HEAD |
git am --binary -3 -k
19 changes: 16 additions & 3 deletions git-repack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,22 @@ exit
if test "$remove_redundant" = t
then
sync
redundant=$(git-pack-redundant --all)
if test "$redundant" != "" ; then
echo $redundant | xargs rm
if test "$all_into_one" = t
then
cd "$PACKDIR"
existing=`find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
for e in $existing
do
case "$e" in
./pack-$name.pack | ./pack-$name.idx) ;;
*) rm -f $e ;;
esac
done
else
redundant=$(git-pack-redundant --all)
if test "$redundant" != "" ; then
echo $redundant | xargs rm
fi
fi
fi

Expand Down
5 changes: 4 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ static void add_cmdname(const char *name, int len)
if (!ent)
oom();
ent->len = len;
memcpy(ent->name, name, len+1);
memcpy(ent->name, name, len);
ent->name[len] = 0;
cmdname[cmdname_cnt++] = ent;
}

Expand Down Expand Up @@ -132,6 +133,8 @@ static void list_commands(const char *exec_path, const char *pattern)
continue;

entlen = strlen(de->d_name);
if (4 < entlen && !strcmp(de->d_name + entlen - 4, ".exe"))
entlen -= 4;

if (longest < entlen)
longest = entlen;
Expand Down
Loading

0 comments on commit 52b6536

Please sign in to comment.