Skip to content

Commit a9645b7

Browse files
committed
Merge branch 'maint'
* maint: Documentation: bisect: change a few instances of "git-cmd" to "git cmd" Documentation: rev-list: change a few instances of "git-cmd" to "git cmd" checkout: Don't crash when switching away from an invalid branch.
2 parents d2d188d + 5bcce84 commit a9645b7

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

Documentation/git-bisect.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on the subcommand:
2626
git bisect log
2727
git bisect run <cmd>...
2828

29-
This command uses 'git-rev-list --bisect' to help drive the
29+
This command uses 'git rev-list --bisect' to help drive the
3030
binary search process to find which change introduced a bug, given an
3131
old "good" commit object name and a later "bad" commit object name.
3232

@@ -101,7 +101,7 @@ $ git bisect visualize
101101
to see the currently remaining suspects in 'gitk'. `visualize` is a bit
102102
too long to type and `view` is provided as a synonym.
103103

104-
If 'DISPLAY' environment variable is not set, 'git-log' is used
104+
If 'DISPLAY' environment variable is not set, 'git log' is used
105105
instead. You can even give command line options such as `-p` and
106106
`--stat`.
107107

@@ -215,7 +215,7 @@ tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or
215215
work around other problem this bisection is not interested in")
216216
applied to the revision being tested.
217217

218-
To cope with such a situation, after the inner 'git-bisect' finds the
218+
To cope with such a situation, after the inner 'git bisect' finds the
219219
next revision to test, with the "run" script, you can apply that tweak
220220
before compiling, run the real test, and after the test decides if the
221221
revision (possibly with the needed tweaks) passed the test, rewind the

Documentation/rev-list-options.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ See also linkgit:git-reflog[1].
285285
History Simplification
286286
~~~~~~~~~~~~~~~~~~~~~~
287287

288-
When optional paths are given, 'git-rev-list' simplifies commits with
288+
When optional paths are given, 'git rev-list' simplifies commits with
289289
various strategies, according to the options you have selected.
290290

291291
Suppose you specified `foo` as the <paths>. We shall call commits
@@ -466,14 +466,14 @@ Limit output to the one commit object which is roughly halfway between
466466
the included and excluded commits. Thus, if
467467

468468
-----------------------------------------------------------------------
469-
$ git-rev-list --bisect foo ^bar ^baz
469+
$ git rev-list --bisect foo ^bar ^baz
470470
-----------------------------------------------------------------------
471471

472472
outputs 'midpoint', the output of the two commands
473473

474474
-----------------------------------------------------------------------
475-
$ git-rev-list foo ^midpoint
476-
$ git-rev-list midpoint ^bar ^baz
475+
$ git rev-list foo ^midpoint
476+
$ git rev-list midpoint ^bar ^baz
477477
-----------------------------------------------------------------------
478478

479479
would be of roughly the same length. Finding the change which

builtin-checkout.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int post_checkout_hook(struct commit *old, struct commit *new,
4747

4848
memset(&proc, 0, sizeof(proc));
4949
argv[0] = name;
50-
argv[1] = xstrdup(sha1_to_hex(old->object.sha1));
50+
argv[1] = xstrdup(sha1_to_hex(old ? old->object.sha1 : null_sha1));
5151
argv[2] = xstrdup(sha1_to_hex(new->object.sha1));
5252
argv[3] = changed ? "1" : "0";
5353
argv[4] = NULL;
@@ -492,10 +492,10 @@ static void update_refs_for_switch(struct checkout_opts *opts,
492492
}
493493

494494
old_desc = old->name;
495-
if (!old_desc)
495+
if (!old_desc && old->commit)
496496
old_desc = sha1_to_hex(old->commit->object.sha1);
497497
strbuf_addf(&msg, "checkout: moving from %s to %s",
498-
old_desc, new->name);
498+
old_desc ? old_desc : "(invalid)", new->name);
499499

500500
if (new->path) {
501501
create_symref("HEAD", new->path, msg.buf);
@@ -551,7 +551,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
551551
* a new commit, we want to mention the old commit once more
552552
* to remind the user that it might be lost.
553553
*/
554-
if (!opts->quiet && !old.path && new->commit != old.commit)
554+
if (!opts->quiet && !old.path && old.commit && new->commit != old.commit)
555555
describe_detached_head("Previous HEAD position was", old.commit);
556556

557557
if (!old.commit) {

t/t2011-checkout-invalid-head.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
test_description='checkout switching away from an invalid branch'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success 'setup' '
8+
echo hello >world &&
9+
git add world &&
10+
git commit -m initial
11+
'
12+
13+
test_expect_success 'checkout master from invalid HEAD' '
14+
echo 0000000000000000000000000000000000000000 >.git/HEAD &&
15+
git checkout master --
16+
'
17+
18+
test_done

0 commit comments

Comments
 (0)