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 18, 2005
2 parents 1e9eb2e + 087b674 commit 6eb668d
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 79 deletions.
24 changes: 16 additions & 8 deletions Documentation/git-am.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ git-am - Apply a series of patches in a mailbox

SYNOPSIS
--------
'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>...
'git-am' [--skip]
'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...
'git-am' [--skip | --resolved]

DESCRIPTION
-----------
Expand All @@ -31,6 +31,10 @@ OPTIONS
Pass `--utf8` and `--keep` flags to `git-mailinfo` (see
gitlink:git-mailinfo[1]).

--binary::
Pass `--allow-binary-replacement` flag to `git-apply`
(see gitlink:git-apply[1]).

--3way::
When the patch does not apply cleanly, fall back on
3-way merge, if the patch records the identity of blobs
Expand All @@ -44,6 +48,13 @@ OPTIONS
--interactive::
Run interactively, just like git-applymbox.

--resolved::
After a patch failure (e.g. attempting to apply
conflicting patch), the user has applied it by hand and
the index file stores the result of the application.
Make a commit using the authorship and commit log
extracted from the e-mail message and the current index
file, and continue.

DISCUSSION
----------
Expand All @@ -56,12 +67,9 @@ recover from this in one of two ways:
. skip the current one by re-running the command with '--skip'
option.

. hand resolve the conflict in the working directory, run 'git
diff HEAD' to extract the merge result into a patch form and
replacing the patch in .dotest/patch file. After doing this,
run `git-reset --hard HEAD` to bring the working tree to the
state before half-applying the patch, then re-run the command
without any options.
. hand resolve the conflict in the working directory, and update
the index file to bring it in a state that the patch should
have produced. Then run the command with '--resume' option.

The command refuses to process new mailboxes while `.dotest`
directory exists, so if you decide to start over from scratch,
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ deb: dist
### Cleaning rules

clean:
rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o git $(PROGRAMS) $(LIB_FILE)
rm -f $(filter-out gitk,$(SCRIPTS))
rm -f *.spec *.pyc *.pyo
rm -rf $(GIT_TARNAME)
Expand Down
24 changes: 18 additions & 6 deletions apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,12 +893,24 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
patchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);

if (!patchsize) {
static const char binhdr[] = "Binary files ";

if (sizeof(binhdr) - 1 < size - offset - hdrsize &&
!memcmp(binhdr, buffer + hdrsize + offset,
sizeof(binhdr)-1))
patch->is_binary = 1;
static const char *binhdr[] = {
"Binary files ",
"Files ",
NULL,
};
int i;
int hd = hdrsize + offset;
unsigned long llen = linelen(buffer + hd, size - hd);

if (!memcmp(" differ\n", buffer + hd + llen - 8, 8))
for (i = 0; binhdr[i]; i++) {
int len = strlen(binhdr[i]);
if (len < size - hd &&
!memcmp(binhdr[i], buffer + hd, len)) {
patch->is_binary = 1;
break;
}
}

/* Empty patch cannot be applied if:
* - it is a binary patch and we do not do binary_replace, or
Expand Down
18 changes: 17 additions & 1 deletion date.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const char *month_names[] = {
};

static const char *weekday_names[] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
"Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"
};

/*
Expand Down Expand Up @@ -531,6 +531,22 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
tl++;
}

for (i = 0; i < 7; i++) {
int match = match_string(date, weekday_names[i]);
if (match >= 3) {
int diff, n = *num -1;
*num = 0;

diff = tm->tm_wday - i;
if (diff <= 0)
n++;
diff += 7*n;

update_tm(tm, diff * 24 * 60 * 60);
return end;
}
}

if (match_string(date, "months") >= 5) {
int n = tm->tm_mon - *num;
*num = 0;
Expand Down
20 changes: 14 additions & 6 deletions git-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
. git-sh-setup || die "Not a git archive"

usage () {
echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--3way] <mbox>"
echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"
echo >&2 " or, when resuming"
echo >&2 " $0 [--skip | --resolved]"
exit 1;
Expand Down Expand Up @@ -40,7 +40,7 @@ fall_back_3way () {
cd "$dotest/patch-merge-tmp-dir" &&
GIT_INDEX_FILE="../patch-merge-tmp-index" \
GIT_OBJECT_DIRECTORY="$O_OBJECT" \
git-apply --index <../patch
git-apply $binary --index <../patch
)
then
echo Using index info to reconstruct a base tree...
Expand Down Expand Up @@ -71,7 +71,7 @@ fall_back_3way () {
GIT_OBJECT_DIRECTORY="$O_OBJECT" &&
export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY &&
git-read-tree "$base" &&
git-apply --index &&
git-apply $binary --index &&
mv ../patch-merge-tmp-index ../patch-merge-index &&
echo "$base" >../patch-merge-base
) <"$dotest/patch" 2>/dev/null && break
Expand All @@ -98,7 +98,7 @@ fall_back_3way () {
}

prec=4
dotest=.dotest sign= utf8= keep= skip= interactive= resolved=
dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary=

while case "$#" in 0) break;; esac
do
Expand All @@ -113,6 +113,9 @@ do
--interacti|--interactiv|--interactive)
interactive=t; shift ;;

-b|--b|--bi|--bin|--bina|--binar|--binary)
binary=t; shift ;;

-3|--3|--3w|--3wa|--3way)
threeway=t; shift ;;
-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
Expand Down Expand Up @@ -169,9 +172,10 @@ else
exit 1
}

# -s, -u and -k flags are kept for the resuming session after
# -b, -s, -u and -k flags are kept for the resuming session after
# a patch failure.
# -3 and -i can and must be given when resuming.
echo "$binary" >"$dotest/binary"
echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
Expand All @@ -187,6 +191,10 @@ case "$resolved" in
fi
esac

if test "$(cat "$dotest/binary")" = t
then
binary=--allow-binary-replacement
fi
if test "$(cat "$dotest/utf8")" = t
then
utf8=-u
Expand Down Expand Up @@ -339,7 +347,7 @@ do

case "$resolved" in
'')
git-apply --index "$dotest/patch"
git-apply $binary --index "$dotest/patch"
apply_status=$?
;;
t)
Expand Down
Loading

0 comments on commit 6eb668d

Please sign in to comment.