зеркало из https://github.com/microsoft/git.git
Merge branch 'maint'
* maint: merge-file: handle empty files gracefully merge-recursive: handle file mode changes Minor wording changes in the keyboard descriptions in git-add --interactive. git fetch: Take '-n' to mean '--no-tags' quiltimport: fix misquoting of parsed -p<num> parameter git-quiltimport: better parser to grok "enhanced" series files.
This commit is contained in:
Коммит
16007f3916
|
@ -207,16 +207,14 @@ patch::
|
|||
and the working tree file and asks you if you want to stage
|
||||
the change of each hunk. You can say:
|
||||
|
||||
y - add the change from that hunk to index
|
||||
n - do not add the change from that hunk to index
|
||||
a - add the change from that hunk and all the rest to index
|
||||
d - do not the change from that hunk nor any of the rest to index
|
||||
j - do not decide on this hunk now, and view the next
|
||||
undecided hunk
|
||||
J - do not decide on this hunk now, and view the next hunk
|
||||
k - do not decide on this hunk now, and view the previous
|
||||
undecided hunk
|
||||
K - do not decide on this hunk now, and view the previous hunk
|
||||
y - stage this hunk
|
||||
n - do not stage this hunk
|
||||
a - stage this and all the remaining hunks in the file
|
||||
d - do not stage this hunk nor any of the remaining hunks in the file
|
||||
j - leave this hunk undecided, see next undecided hunk
|
||||
J - leave this hunk undecided, see next hunk
|
||||
k - leave this hunk undecided, see previous undecided hunk
|
||||
K - leave this hunk undecided, see previous hunk
|
||||
s - split the current hunk into smaller hunks
|
||||
? - print help
|
||||
+
|
||||
|
|
|
@ -40,6 +40,8 @@ static struct option builtin_fetch_options[] = {
|
|||
"force overwrite of local branch"),
|
||||
OPT_SET_INT('t', "tags", &tags,
|
||||
"fetch all tags and associated objects", TAGS_SET),
|
||||
OPT_SET_INT('n', NULL, &tags,
|
||||
"do not fetch all tags (--no-tags)", TAGS_UNSET),
|
||||
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
|
||||
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
|
||||
"allow updating of HEAD ref"),
|
||||
|
|
|
@ -57,7 +57,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
|
|||
|
||||
if (!f)
|
||||
ret = error("Could not open %s for writing", filename);
|
||||
else if (fwrite(result.ptr, result.size, 1, f) != 1)
|
||||
else if (result.size &&
|
||||
fwrite(result.ptr, result.size, 1, f) != 1)
|
||||
ret = error("Could not write to %s", filename);
|
||||
else if (fclose(f))
|
||||
ret = error("Could not close %s", filename);
|
||||
|
|
|
@ -668,9 +668,20 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
|
|||
if (!sha_eq(a->sha1, o->sha1) && !sha_eq(b->sha1, o->sha1))
|
||||
result.merge = 1;
|
||||
|
||||
result.mode = a->mode == o->mode ? b->mode: a->mode;
|
||||
/*
|
||||
* Merge modes
|
||||
*/
|
||||
if (a->mode == b->mode || a->mode == o->mode)
|
||||
result.mode = b->mode;
|
||||
else {
|
||||
result.mode = a->mode;
|
||||
if (b->mode != o->mode) {
|
||||
result.clean = 0;
|
||||
result.merge = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sha_eq(a->sha1, o->sha1))
|
||||
if (sha_eq(a->sha1, b->sha1) || sha_eq(a->sha1, o->sha1))
|
||||
hashcpy(result.sha, b->sha1);
|
||||
else if (sha_eq(b->sha1, o->sha1))
|
||||
hashcpy(result.sha, a->sha1);
|
||||
|
|
|
@ -63,7 +63,23 @@ tmp_info="$tmp_dir/info"
|
|||
commit=$(git rev-parse HEAD)
|
||||
|
||||
mkdir $tmp_dir || exit 2
|
||||
for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
|
||||
while read patch_name level garbage
|
||||
do
|
||||
case "$patch_name" in ''|'#'*) continue;; esac
|
||||
case "$level" in
|
||||
-p*) ;;
|
||||
''|'#'*)
|
||||
level=;;
|
||||
*)
|
||||
echo "unable to parse patch level, ignoring it."
|
||||
level=;;
|
||||
esac
|
||||
case "$garbage" in
|
||||
''|'#'*);;
|
||||
*)
|
||||
echo "trailing garbage found in series file: $garbage"
|
||||
exit 1;;
|
||||
esac
|
||||
if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then
|
||||
echo "$patch_name doesn't exist. Skipping."
|
||||
continue
|
||||
|
@ -113,10 +129,10 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
|
|||
fi
|
||||
|
||||
if [ -z "$dry_run" ] ; then
|
||||
git apply --index -C1 "$tmp_patch" &&
|
||||
git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
|
||||
tree=$(git write-tree) &&
|
||||
commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
|
||||
git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
|
||||
fi
|
||||
done
|
||||
done <"$QUILT_PATCHES/series"
|
||||
rm -rf $tmp_dir || exit 5
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='merge-recursive: handle file mode'
|
||||
. ./test-lib.sh
|
||||
|
||||
test_expect_success 'mode change in one branch: keep changed version' '
|
||||
: >file1 &&
|
||||
git add file1 &&
|
||||
git commit -m initial &&
|
||||
git checkout -b a1 master &&
|
||||
: >dummy &&
|
||||
git add dummy &&
|
||||
git commit -m a &&
|
||||
git checkout -b b1 master &&
|
||||
chmod +x file1 &&
|
||||
git add file1 &&
|
||||
git commit -m b1 &&
|
||||
git checkout a1 &&
|
||||
git merge-recursive master -- a1 b1 &&
|
||||
test -x file1
|
||||
'
|
||||
|
||||
test_expect_success 'mode change in both branches: expect conflict' '
|
||||
git reset --hard HEAD &&
|
||||
git checkout -b a2 master &&
|
||||
: >file2 &&
|
||||
H=$(git hash-object file2) &&
|
||||
chmod +x file2 &&
|
||||
git add file2 &&
|
||||
git commit -m a2 &&
|
||||
git checkout -b b2 master &&
|
||||
: >file2 &&
|
||||
git add file2 &&
|
||||
git commit -m b2 &&
|
||||
git checkout a2 &&
|
||||
(
|
||||
git merge-recursive master -- a2 b2
|
||||
test $? = 1
|
||||
) &&
|
||||
git ls-files -u >actual &&
|
||||
(
|
||||
echo "100755 $H 2 file2"
|
||||
echo "100644 $H 3 file2"
|
||||
) >expect &&
|
||||
diff -u actual expect &&
|
||||
test -x file2
|
||||
'
|
||||
|
||||
test_done
|
|
@ -152,8 +152,8 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
|
|||
if ((f = fopen(filename, "rb")) == NULL)
|
||||
return error("Could not open %s", filename);
|
||||
sz = xsize_t(st.st_size);
|
||||
ptr->ptr = xmalloc(sz);
|
||||
if (fread(ptr->ptr, sz, 1, f) != 1)
|
||||
ptr->ptr = xmalloc(sz ? sz : 1);
|
||||
if (sz && fread(ptr->ptr, sz, 1, f) != 1)
|
||||
return error("Could not read %s", filename);
|
||||
fclose(f);
|
||||
ptr->size = sz;
|
||||
|
|
Загрузка…
Ссылка в новой задаче