Skip to content

Commit 464509f

Browse files
committed
Merge branch 'maint-1.5.4' into maint
* maint-1.5.4: git-bisect: make "start", "good" and "skip" succeed or fail atomically git-am: cope better with an empty Subject: line Ignore leading empty lines while summarizing merges bisect: squelch "fatal: ref HEAD not a symref" misleading message builtin-apply: Show a more descriptive error on failure when opening a patch Clarify documentation of git-cvsserver, particularly in relation to git-shell
2 parents 2b6f0b0 + d3e54c8 commit 464509f

File tree

6 files changed

+54
-33
lines changed

6 files changed

+54
-33
lines changed

Documentation/git-cvsserver.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ cvs -d ":ext;CVS_SERVER=git-cvsserver:user@server/path/repo.git" co <HEAD_name>
110110
------
111111
This has the advantage that it will be saved in your 'CVS/Root' files and
112112
you don't need to worry about always setting the correct environment
113-
variable.
113+
variable. SSH users restricted to git-shell don't need to override the default
114+
with CVS_SERVER (and shouldn't) as git-shell understands `cvs` to mean
115+
git-cvsserver and pretends that the other end runs the real cvs better.
114116
--
115117
2. For each repo that you want accessible from CVS you need to edit config in
116118
the repo and add the following section.
@@ -141,25 +143,29 @@ allowing access over SSH.
141143
enabled=1
142144
------
143145
--
144-
3. On the client machine you need to set the following variables.
145-
CVSROOT should be set as per normal, but the directory should point at the
146-
appropriate git repo. For example:
146+
3. If you didn't specify the CVSROOT/CVS_SERVER directly in the checkout command,
147+
automatically saving it in your 'CVS/Root' files, then you need to set them
148+
explicitly in your environment. CVSROOT should be set as per normal, but the
149+
directory should point at the appropriate git repo. As above, for SSH clients
150+
_not_ restricted to git-shell, CVS_SERVER should be set to git-cvsserver.
147151
+
148152
--
149-
For SSH access, CVS_SERVER should be set to git-cvsserver
150-
151-
Example:
152-
153153
------
154154
export CVSROOT=:ext:user@server:/var/git/project.git
155155
export CVS_SERVER=git-cvsserver
156156
------
157157
--
158-
4. For SSH clients that will make commits, make sure their .bashrc file
159-
sets the GIT_AUTHOR and GIT_COMMITTER variables.
158+
4. For SSH clients that will make commits, make sure their server-side
159+
.ssh/environment files (or .bashrc, etc., according to their specific shell)
160+
export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL,
161+
GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL. For SSH clients whose login
162+
shell is bash, .bashrc may be a reasonable alternative.
160163

161164
5. Clients should now be able to check out the project. Use the CVS 'module'
162-
name to indicate what GIT 'head' you want to check out. Example:
165+
name to indicate what GIT 'head' you want to check out. This also sets the
166+
name of your newly checked-out directory, unless you tell it otherwise with
167+
`-d <dir_name>`. For example, this checks out 'master' branch to the
168+
`project-master` directory:
163169
+
164170
------
165171
cvs co -d project-master master

builtin-apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3121,7 +3121,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
31213121

31223122
fd = open(arg, O_RDONLY);
31233123
if (fd < 0)
3124-
usage(apply_usage);
3124+
die("can't open patch '%s': %s", arg, strerror(errno));
31253125
read_stdin = 0;
31263126
set_default_whitespace_mode(whitespace_option);
31273127
errs |= apply_patch(fd, arg, inaccurate_eof);

builtin-fmt-merge-msg.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,22 @@ static void shortlog(const char *name, unsigned char *sha1,
201201
continue;
202202

203203
bol = strstr(commit->buffer, "\n\n");
204+
if (bol) {
205+
unsigned char c;
206+
do {
207+
c = *++bol;
208+
} while (isspace(c));
209+
if (!c)
210+
bol = NULL;
211+
}
212+
204213
if (!bol) {
205214
append_to_list(&subjects, xstrdup(sha1_to_hex(
206215
commit->object.sha1)),
207216
NULL);
208217
continue;
209218
}
210219

211-
bol += 2;
212220
eol = strchr(bol, '\n');
213221
if (eol) {
214222
oneline = xmemdupz(bol, eol - bol);

git-am.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ It does not apply to blobs recorded in its index."
107107
# patch did not touch, so recursive ends up canceling them,
108108
# saying that we reverted all those changes.
109109

110-
eval GITHEAD_$his_tree='"$SUBJECT"'
110+
eval GITHEAD_$his_tree='"$FIRSTLINE"'
111111
export GITHEAD_$his_tree
112112
git-merge-recursive $orig_tree -- HEAD $his_tree || {
113113
git rerere
@@ -117,10 +117,6 @@ It does not apply to blobs recorded in its index."
117117
unset GITHEAD_$his_tree
118118
}
119119

120-
reread_subject () {
121-
git stripspace <"$1" | sed -e 1q
122-
}
123-
124120
prec=4
125121
dotest=".dotest"
126122
sign= utf8=t keep= skip= interactive= resolved= binary= rebasing=
@@ -331,7 +327,11 @@ do
331327
echo "Patch is empty. Was it split wrong?"
332328
stop_here $this
333329
}
334-
git stripspace < "$dotest/msg" > "$dotest/msg-clean"
330+
SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
331+
case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
332+
333+
(echo "$SUBJECT" ; echo ; cat "$dotest/msg") |
334+
git stripspace > "$dotest/msg-clean"
335335
;;
336336
esac
337337

@@ -347,9 +347,6 @@ do
347347

348348
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
349349

350-
SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
351-
case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
352-
353350
case "$resume" in
354351
'')
355352
if test '' != "$SIGNOFF"
@@ -368,10 +365,8 @@ do
368365
ADD_SIGNOFF=
369366
fi
370367
{
371-
printf '%s\n' "$SUBJECT"
372368
if test -s "$dotest/msg-clean"
373369
then
374-
echo
375370
cat "$dotest/msg-clean"
376371
fi
377372
if test '' != "$ADD_SIGNOFF"
@@ -388,6 +383,7 @@ do
388383
;;
389384
esac
390385
esac
386+
FIRSTLINE=$(head -1 "$dotest/final-commit")
391387

392388
resume=
393389
if test "$interactive" = t
@@ -408,7 +404,7 @@ do
408404
[aA]*) action=yes interactive= ;;
409405
[nN]*) action=skip ;;
410406
[eE]*) git_editor "$dotest/final-commit"
411-
SUBJECT=$(reread_subject "$dotest/final-commit")
407+
FIRSTLINE=$(head -1 "$dotest/final-commit")
412408
action=again ;;
413409
[vV]*) action=again
414410
LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -431,7 +427,7 @@ do
431427
stop_here $this
432428
fi
433429

434-
printf 'Applying %s\n' "$SUBJECT"
430+
printf 'Applying %s\n' "$FIRSTLINE"
435431

436432
case "$resolved" in
437433
'')
@@ -489,7 +485,7 @@ do
489485
tree=$(git write-tree) &&
490486
parent=$(git rev-parse --verify HEAD) &&
491487
commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
492-
git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
488+
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
493489
stop_here $this
494490

495491
if test -x "$GIT_DIR"/hooks/post-applypatch

git-bisect.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ bisect_start() {
6262
# Verify HEAD. If we were bisecting before this, reset to the
6363
# top-of-line master first!
6464
#
65-
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
65+
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
6666
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
6767
die "Bad HEAD - I need a HEAD"
68+
start_head=''
6869
case "$head" in
6970
refs/heads/bisect)
7071
if [ -s "$GIT_DIR/BISECT_START" ]; then
@@ -78,7 +79,7 @@ bisect_start() {
7879
# This error message should only be triggered by cogito usage,
7980
# and cogito users should understand it relates to cg-seek.
8081
[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
81-
echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START"
82+
start_head="${head#refs/heads/}"
8283
;;
8384
*)
8485
die "Bad HEAD - strange symbolic ref"
@@ -99,6 +100,7 @@ bisect_start() {
99100
done
100101
orig_args=$(sq "$@")
101102
bad_seen=0
103+
eval=''
102104
while [ $# -gt 0 ]; do
103105
arg="$1"
104106
case "$arg" in
@@ -116,13 +118,15 @@ bisect_start() {
116118
0) state='bad' ; bad_seen=1 ;;
117119
*) state='good' ;;
118120
esac
119-
bisect_write "$state" "$rev" 'nolog'
121+
eval="$eval bisect_write '$state' '$rev' 'nolog'; "
120122
shift
121123
;;
122124
esac
123125
done
124126

125127
sq "$@" >"$GIT_DIR/BISECT_NAMES"
128+
test -n "$start_head" && echo "$start_head" >"$GIT_DIR/BISECT_START"
129+
eval "$eval"
126130
echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
127131
bisect_auto_next
128132
}
@@ -153,12 +157,14 @@ bisect_state() {
153157
bisect_write "$state" "$rev" ;;
154158
2,bad|*,good|*,skip)
155159
shift
160+
eval=''
156161
for rev in "$@"
157162
do
158163
sha=$(git rev-parse --verify "$rev^{commit}") ||
159164
die "Bad rev input: $rev"
160-
bisect_write "$state" "$sha"
161-
done ;;
165+
eval="$eval bisect_write '$state' '$sha'; "
166+
done
167+
eval "$eval" ;;
162168
*,bad)
163169
die "'git bisect bad' can take only one argument." ;;
164170
*)

t/t6030-bisect-porcelain.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,20 @@ test_expect_success 'bisect start with one bad and good' '
7171
git bisect next
7272
'
7373

74-
test_expect_success 'bisect good and bad fails if not given only revs' '
74+
test_expect_success 'bisect fails if given any junk instead of revs' '
7575
git bisect reset &&
76+
test_must_fail git bisect start foo $HASH1 -- &&
77+
test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
78+
test -z "$(git for-each-ref "refs/bisect/*")" &&
79+
test_must_fail ls .git/BISECT_* &&
7680
git bisect start &&
7781
test_must_fail git bisect good foo $HASH1 &&
7882
test_must_fail git bisect good $HASH1 bar &&
7983
test_must_fail git bisect bad frotz &&
8084
test_must_fail git bisect bad $HASH3 $HASH4 &&
8185
test_must_fail git bisect skip bar $HASH3 &&
8286
test_must_fail git bisect skip $HASH1 foo &&
87+
test -z "$(git for-each-ref "refs/bisect/*")" &&
8388
git bisect good $HASH1 &&
8489
git bisect bad $HASH4
8590
'

0 commit comments

Comments
 (0)