提交 671d1bc6 编写于 作者: J Junio C Hamano

Merge branch 'maint'

* maint:
  test: checkout shouldn't say that HEAD has moved if it didn't
  completion: enhance "current branch" display
  completion: simplify "current branch" in __git_ps1()
  completion: fix PS1 display during a merge on detached HEAD
  builtin-checkout: Don't tell user that HEAD has moved before it has
  pre-commit.sample: don't print incidental SHA1
  tests: Add tests for missing format-patch long options
  api-parse-options.txt: use 'func' instead of 'funct'
  Turn on USE_ST_TIMESPEC for OpenBSD
  ls-tree manpage: output of ls-tree is compatible with update-index
  ls-tree manpage: use "unless" instead of "when ... is not"
...@@ -82,8 +82,10 @@ Output Format ...@@ -82,8 +82,10 @@ Output Format
------------- -------------
<mode> SP <type> SP <object> TAB <file> <mode> SP <type> SP <object> TAB <file>
When the `-z` option is not used, TAB, LF, and backslash characters Unless the `-z` option is used, TAB, LF, and backslash characters
in pathnames are represented as `\t`, `\n`, and `\\`, respectively. in pathnames are represented as `\t`, `\n`, and `\\`, respectively.
This output format is compatible with what '--index-info --stdin' of
'git update-index' expects.
When the `-l` option is used, format changes to When the `-l` option is used, format changes to
......
...@@ -198,7 +198,7 @@ The function must be defined in this form: ...@@ -198,7 +198,7 @@ The function must be defined in this form:
The callback mechanism is as follows: The callback mechanism is as follows:
* Inside `funct`, the only interesting member of the structure * Inside `func`, the only interesting member of the structure
given by `opt` is the void pointer `opt->value`. given by `opt` is the void pointer `opt->value`.
`\*opt->value` will be the value that is saved into `var`, if you `\*opt->value` will be the value that is saved into `var`, if you
use `OPT_CALLBACK()`. use `OPT_CALLBACK()`.
......
...@@ -749,6 +749,7 @@ endif ...@@ -749,6 +749,7 @@ endif
ifeq ($(uname_S),OpenBSD) ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease NO_STRCASESTR = YesPlease
NO_MEMMEM = YesPlease NO_MEMMEM = YesPlease
USE_ST_TIMESPEC = YesPlease
NEEDS_LIBICONV = YesPlease NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -I/usr/local/include BASIC_CFLAGS += -I/usr/local/include
BASIC_LDFLAGS += -L/usr/local/lib BASIC_LDFLAGS += -L/usr/local/lib
......
...@@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) ...@@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
parse_commit(new->commit); parse_commit(new->commit);
} }
/*
* If we were on a detached HEAD, but we are now moving to
* a new commit, we want to mention the old commit once more
* to remind the user that it might be lost.
*/
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
describe_detached_head("Previous HEAD position was", old.commit);
if (!old.commit && !opts->force) { if (!old.commit && !opts->force) {
if (!opts->quiet) { if (!opts->quiet) {
warning("You appear to be on a branch yet to be born."); warning("You appear to be on a branch yet to be born.");
...@@ -561,6 +553,14 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new) ...@@ -561,6 +553,14 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
if (ret) if (ret)
return ret; return ret;
/*
* If we were on a detached HEAD, but have now moved to
* a new commit, we want to mention the old commit once more
* to remind the user that it might be lost.
*/
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
describe_detached_head("Previous HEAD position was", old.commit);
update_refs_for_switch(opts, &old, new); update_refs_for_switch(opts, &old, new);
ret = post_checkout_hook(old.commit, new->commit, 1); ret = post_checkout_hook(old.commit, new->commit, 1);
......
...@@ -99,20 +99,32 @@ __git_ps1 () ...@@ -99,20 +99,32 @@ __git_ps1 ()
elif [ -d "$g/rebase-merge" ]; then elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m" r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")" b="$(cat "$g/rebase-merge/head-name")"
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
b="$(git symbolic-ref HEAD 2>/dev/null)"
else else
if [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
fi
if [ -f "$g/BISECT_LOG" ]; then if [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING" r="|BISECTING"
fi fi
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then b="$(git symbolic-ref HEAD 2>/dev/null)" || {
if [ -r "$g/HEAD" ]; then
b="$(cut -c1-7 "$g/HEAD")..." b="$(
fi case "${GIT_PS1_DESCRIBE_STYLE-}" in
fi (contains)
fi git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --exact-match HEAD ;;
esac 2>/dev/null)" ||
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
b="unknown"
b="($b)"
}
fi fi
local w local w
......
...@@ -505,4 +505,15 @@ test_expect_success 'format-patch from a subdirectory (3)' ' ...@@ -505,4 +505,15 @@ test_expect_success 'format-patch from a subdirectory (3)' '
test -f "$basename" test -f "$basename"
' '
test_expect_success 'format-patch --in-reply-to' '
git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 &&
grep "^In-Reply-To: <baz@foo.bar>" patch8 &&
grep "^References: <baz@foo.bar>" patch8
'
test_expect_success 'format-patch --signoff' '
git format-patch -1 --signoff --stdout |
grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
'
test_done test_done
...@@ -108,4 +108,10 @@ test_expect_success 'format.numbered = auto && --no-numbered' ' ...@@ -108,4 +108,10 @@ test_expect_success 'format.numbered = auto && --no-numbered' '
' '
test_expect_success '--start-number && --numbered' '
git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 &&
grep "^Subject: \[PATCH 3/3\]" patch8
'
test_done test_done
...@@ -534,4 +534,12 @@ test_expect_success 'failing checkout -b should not break working tree' ' ...@@ -534,4 +534,12 @@ test_expect_success 'failing checkout -b should not break working tree' '
' '
test_expect_success 'switch out of non-branch' '
git reset --hard master &&
git checkout master^0 &&
echo modified >one &&
test_must_fail git checkout renamer 2>error.log &&
! grep "^Previous HEAD" error.log
'
test_done test_done
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# #
# To enable this hook, rename this file to "pre-commit". # To enable this hook, rename this file to "pre-commit".
if git-rev-parse --verify HEAD 2>/dev/null if git-rev-parse --verify HEAD >/dev/null 2>&1
then then
against=HEAD against=HEAD
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册