Skip to content

Commit 671d1bc

Browse files
committed
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"
2 parents 8a94bc7 + e4b09da commit 671d1bc

9 files changed

Lines changed: 61 additions & 21 deletions

File tree

Documentation/git-ls-tree.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ Output Format
8282
-------------
8383
<mode> SP <type> SP <object> TAB <file>
8484

85-
When the `-z` option is not used, TAB, LF, and backslash characters
85+
Unless the `-z` option is used, TAB, LF, and backslash characters
8686
in pathnames are represented as `\t`, `\n`, and `\\`, respectively.
87+
This output format is compatible with what '--index-info --stdin' of
88+
'git update-index' expects.
8789

8890
When the `-l` option is used, format changes to
8991

Documentation/technical/api-parse-options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ The function must be defined in this form:
198198

199199
The callback mechanism is as follows:
200200

201-
* Inside `funct`, the only interesting member of the structure
201+
* Inside `func`, the only interesting member of the structure
202202
given by `opt` is the void pointer `opt->value`.
203203
`\*opt->value` will be the value that is saved into `var`, if you
204204
use `OPT_CALLBACK()`.

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ endif
749749
ifeq ($(uname_S),OpenBSD)
750750
NO_STRCASESTR = YesPlease
751751
NO_MEMMEM = YesPlease
752+
USE_ST_TIMESPEC = YesPlease
752753
NEEDS_LIBICONV = YesPlease
753754
BASIC_CFLAGS += -I/usr/local/include
754755
BASIC_LDFLAGS += -L/usr/local/lib

builtin-checkout.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,6 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
541541
parse_commit(new->commit);
542542
}
543543

544-
/*
545-
* If we were on a detached HEAD, but we are now moving to
546-
* a new commit, we want to mention the old commit once more
547-
* to remind the user that it might be lost.
548-
*/
549-
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
550-
describe_detached_head("Previous HEAD position was", old.commit);
551-
552544
if (!old.commit && !opts->force) {
553545
if (!opts->quiet) {
554546
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)
561553
if (ret)
562554
return ret;
563555

556+
/*
557+
* If we were on a detached HEAD, but have now moved to
558+
* a new commit, we want to mention the old commit once more
559+
* to remind the user that it might be lost.
560+
*/
561+
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
562+
describe_detached_head("Previous HEAD position was", old.commit);
563+
564564
update_refs_for_switch(opts, &old, new);
565565

566566
ret = post_checkout_hook(old.commit, new->commit, 1);

contrib/completion/git-completion.bash

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,32 @@ __git_ps1 ()
9999
elif [ -d "$g/rebase-merge" ]; then
100100
r="|REBASE-m"
101101
b="$(cat "$g/rebase-merge/head-name")"
102-
elif [ -f "$g/MERGE_HEAD" ]; then
103-
r="|MERGING"
104-
b="$(git symbolic-ref HEAD 2>/dev/null)"
105102
else
103+
if [ -f "$g/MERGE_HEAD" ]; then
104+
r="|MERGING"
105+
fi
106106
if [ -f "$g/BISECT_LOG" ]; then
107107
r="|BISECTING"
108108
fi
109-
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
110-
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
111-
if [ -r "$g/HEAD" ]; then
112-
b="$(cut -c1-7 "$g/HEAD")..."
113-
fi
114-
fi
115-
fi
109+
110+
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
111+
112+
b="$(
113+
case "${GIT_PS1_DESCRIBE_STYLE-}" in
114+
(contains)
115+
git describe --contains HEAD ;;
116+
(branch)
117+
git describe --contains --all HEAD ;;
118+
(describe)
119+
git describe HEAD ;;
120+
(* | default)
121+
git describe --exact-match HEAD ;;
122+
esac 2>/dev/null)" ||
123+
124+
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
125+
b="unknown"
126+
b="($b)"
127+
}
116128
fi
117129

118130
local w

t/t4014-format-patch.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,15 @@ test_expect_success 'format-patch from a subdirectory (3)' '
505505
test -f "$basename"
506506
'
507507

508+
test_expect_success 'format-patch --in-reply-to' '
509+
git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 &&
510+
grep "^In-Reply-To: <baz@foo.bar>" patch8 &&
511+
grep "^References: <baz@foo.bar>" patch8
512+
'
513+
514+
test_expect_success 'format-patch --signoff' '
515+
git format-patch -1 --signoff --stdout |
516+
grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
517+
'
518+
508519
test_done

t/t4021-format-patch-numbered.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,10 @@ test_expect_success 'format.numbered = auto && --no-numbered' '
108108
109109
'
110110

111+
test_expect_success '--start-number && --numbered' '
112+
113+
git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 &&
114+
grep "^Subject: \[PATCH 3/3\]" patch8
115+
'
116+
111117
test_done

t/t7201-co.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,12 @@ test_expect_success 'failing checkout -b should not break working tree' '
534534
535535
'
536536

537+
test_expect_success 'switch out of non-branch' '
538+
git reset --hard master &&
539+
git checkout master^0 &&
540+
echo modified >one &&
541+
test_must_fail git checkout renamer 2>error.log &&
542+
! grep "^Previous HEAD" error.log
543+
'
544+
537545
test_done

templates/hooks--pre-commit.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# To enable this hook, rename this file to "pre-commit".
99

10-
if git-rev-parse --verify HEAD 2>/dev/null
10+
if git-rev-parse --verify HEAD >/dev/null 2>&1
1111
then
1212
against=HEAD
1313
else

0 commit comments

Comments
 (0)