summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-format-patch.txt5
-rw-r--r--Documentation/git-reset.txt277
-rw-r--r--builtin/log.c2
-rw-r--r--builtin/push.c4
-rw-r--r--builtin/rebase.c51
-rw-r--r--builtin/replace.c1
-rw-r--r--compat/msvc.h8
-rwxr-xr-xgit-legacy-rebase.sh10
-rw-r--r--http.c2
-rw-r--r--log-tree.c2
-rw-r--r--midx.c2
-rw-r--r--range-diff.c6
-rw-r--r--range-diff.h5
-rw-r--r--refs/files-backend.c3
-rw-r--r--t/lib-git-daemon.sh2
-rw-r--r--t/perf/perf-lib.sh4
-rwxr-xr-xt/t0001-init.sh4
-rwxr-xr-xt/t3406-rebase-message.sh36
-rwxr-xr-xt/t4013-diff-various.sh2
-rwxr-xr-xt/t5516-fetch-push.sh2
-rwxr-xr-xt/t5562-http-backend-content-length.sh1
-rw-r--r--[-rwxr-xr-x]t/t5562/invoke-with-content-length.pl1
-rwxr-xr-xt/t5601-clone.sh2
-rwxr-xr-xt/t6050-replace.sh5
-rwxr-xr-xt/t9902-completion.sh2
-rw-r--r--t/test-lib-functions.sh45
-rw-r--r--t/test-lib.sh10
-rw-r--r--transport-helper.c2
28 files changed, 307 insertions, 189 deletions
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index aba4c5f..2730442 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -250,6 +250,11 @@ feeding the result to `git send-email`.
feature/v2`), or a revision range if the two versions of the series are
disjoint (for example `git format-patch --cover-letter
--range-diff=feature/v1~3..feature/v1 -3 feature/v2`).
++
+Note that diff options passed to the command affect how the primary
+product of `format-patch` is generated, and they are not passed to
+the underlying `range-diff` machinery used to generate the cover-letter
+material (this may change in the future).
--creation-factor=<percent>::
Used with `--range-diff`, tweak the heuristic which matches up commits
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 2dac95c..9f69ae8 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -14,14 +14,14 @@ SYNOPSIS
DESCRIPTION
-----------
-In the first and second form, copy entries from <tree-ish> to the index.
-In the third form, set the current branch head (HEAD) to <commit>, optionally
-modifying index and working tree to match. The <tree-ish>/<commit> defaults
-to HEAD in all forms.
+In the first and second form, copy entries from `<tree-ish>` to the index.
+In the third form, set the current branch head (`HEAD`) to `<commit>`,
+optionally modifying index and working tree to match.
+The `<tree-ish>`/`<commit>` defaults to `HEAD` in all forms.
'git reset' [-q] [<tree-ish>] [--] <paths>...::
- This form resets the index entries for all <paths> to their
- state at <tree-ish>. (It does not affect the working tree or
+ This form resets the index entries for all `<paths>` to their
+ state at `<tree-ish>`. (It does not affect the working tree or
the current branch.)
+
This means that `git reset <paths>` is the opposite of `git add
@@ -36,7 +36,7 @@ working tree in one go.
'git reset' (--patch | -p) [<tree-ish>] [--] [<paths>...]::
Interactively select hunks in the difference between the index
- and <tree-ish> (defaults to HEAD). The chosen hunks are applied
+ and `<tree-ish>` (defaults to `HEAD`). The chosen hunks are applied
in reverse to the index.
+
This means that `git reset -p` is the opposite of `git add -p`, i.e.
@@ -44,16 +44,16 @@ you can use it to selectively reset hunks. See the ``Interactive Mode''
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
'git reset' [<mode>] [<commit>]::
- This form resets the current branch head to <commit> and
- possibly updates the index (resetting it to the tree of <commit>) and
- the working tree depending on <mode>. If <mode> is omitted,
- defaults to "--mixed". The <mode> must be one of the following:
+ This form resets the current branch head to `<commit>` and
+ possibly updates the index (resetting it to the tree of `<commit>`) and
+ the working tree depending on `<mode>`. If `<mode>` is omitted,
+ defaults to `--mixed`. The `<mode>` must be one of the following:
+
--
--soft::
Does not touch the index file or the working tree at all (but
- resets the head to <commit>, just like all modes do). This leaves
- all your changed files "Changes to be committed", as 'git status'
+ resets the head to `<commit>`, just like all modes do). This leaves
+ all your changed files "Changes to be committed", as `git status`
would put it.
--mixed::
@@ -66,24 +66,24 @@ linkgit:git-add[1]).
--hard::
Resets the index and working tree. Any changes to tracked files in the
- working tree since <commit> are discarded.
+ working tree since `<commit>` are discarded.
--merge::
Resets the index and updates the files in the working tree that are
- different between <commit> and HEAD, but keeps those which are
+ different between `<commit>` and `HEAD`, but keeps those which are
different between the index and working tree (i.e. which have changes
which have not been added).
- If a file that is different between <commit> and the index has unstaged
- changes, reset is aborted.
+ If a file that is different between `<commit>` and the index has
+ unstaged changes, reset is aborted.
+
-In other words, --merge does something like a 'git read-tree -u -m <commit>',
+In other words, `--merge` does something like a `git read-tree -u -m <commit>`,
but carries forward unmerged index entries.
--keep::
Resets index entries and updates files in the working tree that are
- different between <commit> and HEAD.
- If a file that is different between <commit> and HEAD has local changes,
- reset is aborted.
+ different between `<commit>` and `HEAD`.
+ If a file that is different between `<commit>` and `HEAD` has local
+ changes, reset is aborted.
--
If you want to undo a commit other than the latest on a branch,
@@ -116,15 +116,15 @@ $ git pull git://info.example.com/ nitfol <4>
+
<1> You are happily working on something, and find the changes
in these files are in good order. You do not want to see them
-when you run "git diff", because you plan to work on other files
+when you run `git diff`, because you plan to work on other files
and changes with these files are distracting.
<2> Somebody asks you to pull, and the changes sound worthy of merging.
<3> However, you already dirtied the index (i.e. your index does
-not match the HEAD commit). But you know the pull you are going
-to make does not affect frotz.c or filfre.c, so you revert the
+not match the `HEAD` commit). But you know the pull you are going
+to make does not affect `frotz.c` or `filfre.c`, so you revert the
index changes for these two files. Your changes in working tree
remain there.
-<4> Then you can pull and merge, leaving frotz.c and filfre.c
+<4> Then you can pull and merge, leaving `frotz.c` and `filfre.c`
changes still in the working tree.
Undo a commit and redo::
@@ -140,11 +140,11 @@ $ git commit -a -c ORIG_HEAD <3>
just committed is incomplete, or you misspelled your commit
message, or both. Leaves working tree as it was before "reset".
<2> Make corrections to working tree files.
-<3> "reset" copies the old head to .git/ORIG_HEAD; redo the
+<3> "reset" copies the old head to `.git/ORIG_HEAD`; redo the
commit by starting with its log message. If you do not need to
-edit the message further, you can give -C option instead.
+edit the message further, you can give `-C` option instead.
+
-See also the --amend option to linkgit:git-commit[1].
+See also the `--amend` option to linkgit:git-commit[1].
Undo a commit, making it a topic branch::
+
@@ -155,11 +155,11 @@ $ git checkout topic/wip <3>
------------
+
<1> You have made some commits, but realize they were premature
-to be in the "master" branch. You want to continue polishing
-them in a topic branch, so create "topic/wip" branch off of the
-current HEAD.
+to be in the `master` branch. You want to continue polishing
+them in a topic branch, so create `topic/wip` branch off of the
+current `HEAD`.
<2> Rewind the master branch to get rid of those three commits.
-<3> Switch to "topic/wip" branch and keep working.
+<3> Switch to `topic/wip` branch and keep working.
Undo commits permanently::
+
@@ -168,7 +168,7 @@ $ git commit ...
$ git reset --hard HEAD~3 <1>
------------
+
-<1> The last three commits (HEAD, HEAD^, and HEAD~2) were bad
+<1> The last three commits (`HEAD`, `HEAD^`, and `HEAD~2`) were bad
and you do not want to ever see them again. Do *not* do this if
you have already given these commits to somebody else. (See the
"RECOVERING FROM UPSTREAM REBASE" section in linkgit:git-rebase[1] for
@@ -191,14 +191,14 @@ $ git reset --hard ORIG_HEAD <4>
<1> Try to update from the upstream resulted in a lot of
conflicts; you were not ready to spend a lot of time merging
right now, so you decide to do that later.
-<2> "pull" has not made merge commit, so "git reset --hard"
-which is a synonym for "git reset --hard HEAD" clears the mess
+<2> "pull" has not made merge commit, so `git reset --hard`
+which is a synonym for `git reset --hard HEAD` clears the mess
from the index file and the working tree.
<3> Merge a topic branch into the current branch, which resulted
in a fast-forward.
<4> But you decided that the topic branch is not ready for public
consumption yet. "pull" or "merge" always leaves the original
-tip of the current branch in ORIG_HEAD, so resetting hard to it
+tip of the current branch in `ORIG_HEAD`, so resetting hard to it
brings your index file and the working tree back to that state,
and resets the tip of the branch to that commit.
@@ -214,14 +214,14 @@ $ git reset --merge ORIG_HEAD <2>
------------
+
<1> Even if you may have local modifications in your
-working tree, you can safely say "git pull" when you know
+working tree, you can safely say `git pull` when you know
that the change in the other branch does not overlap with
them.
<2> After inspecting the result of the merge, you may find
that the change in the other branch is unsatisfactory. Running
-"git reset --hard ORIG_HEAD" will let you go back to where you
+`git reset --hard ORIG_HEAD` will let you go back to where you
were, but it will discard your local changes, which you do not
-want. "git reset --merge" keeps your local changes.
+want. `git reset --merge` keeps your local changes.
Interrupted workflow::
@@ -287,13 +287,13 @@ $ git checkout -b branch2 <2>
$ git reset --keep start <3>
------------
+
-<1> This commits your first edits in branch1.
+<1> This commits your first edits in `branch1`.
<2> In the ideal world, you could have realized that the earlier
commit did not belong to the new topic when you created and switched
- to branch2 (i.e. "git checkout -b branch2 start"), but nobody is
+ to `branch2` (i.e. `git checkout -b branch2 start`), but nobody is
perfect.
-<3> But you can use "reset --keep" to remove the unwanted commit after
- you switched to "branch2".
+<3> But you can use `reset --keep` to remove the unwanted commit after
+ you switched to `branch2`.
Split a commit apart into a sequence of commits::
+
@@ -317,26 +317,27 @@ $ git commit ... <8>
+
<1> First, reset the history back one commit so that we remove the original
commit, but leave the working tree with all the changes. The -N ensures
- that any new files added with HEAD are still marked so that git add -p
+ that any new files added with `HEAD` are still marked so that `git add -p`
will find them.
-<2> Next, we interactively select diff hunks to add using the git add -p
+<2> Next, we interactively select diff hunks to add using the `git add -p`
facility. This will ask you about each diff hunk in sequence and you can
use simple commands such as "yes, include this", "No don't include this"
or even the very powerful "edit" facility.
<3> Once satisfied with the hunks you want to include, you should verify what
- has been prepared for the first commit by using git diff --cached. This
+ has been prepared for the first commit by using `git diff --cached`. This
shows all the changes that have been moved into the index and are about
to be committed.
-<4> Next, commit the changes stored in the index. The -c option specifies to
+<4> Next, commit the changes stored in the index. The `-c` option specifies to
pre-populate the commit message from the original message that you started
- with in the first commit. This is helpful to avoid retyping it. The HEAD@{1}
- is a special notation for the commit that HEAD used to be at prior to the
- original reset commit (1 change ago). See linkgit:git-reflog[1] for more
- details. You may also use any other valid commit reference.
+ with in the first commit. This is helpful to avoid retyping it. The
+ `HEAD@{1}` is a special notation for the commit that `HEAD` used to be at
+ prior to the original reset commit (1 change ago).
+ See linkgit:git-reflog[1] for more details. You may also use any other
+ valid commit reference.
<5> You can repeat steps 2-4 multiple times to break the original code into
any number of commits.
<6> Now you've split out many of the changes into their own commits, and might
- no longer use the patch mode of git add, in order to select all remaining
+ no longer use the patch mode of `git add`, in order to select all remaining
uncommitted changes.
<7> Once again, check to verify that you've included what you want to. You may
also wish to verify that git diff doesn't show any remaining changes to be
@@ -353,104 +354,120 @@ The tables below show what happens when running:
git reset --option target
----------
-to reset the HEAD to another commit (`target`) with the different
+to reset the `HEAD` to another commit (`target`) with the different
reset options depending on the state of the files.
-In these tables, A, B, C and D are some different states of a
+In these tables, `A`, `B`, `C` and `D` are some different states of a
file. For example, the first line of the first table means that if a
-file is in state A in the working tree, in state B in the index, in
-state C in HEAD and in state D in the target, then "git reset --soft
-target" will leave the file in the working tree in state A and in the
-index in state B. It resets (i.e. moves) the HEAD (i.e. the tip of
-the current branch, if you are on one) to "target" (which has the file
-in state D).
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- A B C D --soft A B D
- --mixed A D D
- --hard D D D
- --merge (disallowed)
- --keep (disallowed)
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- A B C C --soft A B C
- --mixed A C C
- --hard C C C
- --merge (disallowed)
- --keep A C C
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- B B C D --soft B B D
- --mixed B D D
- --hard D D D
- --merge D D D
- --keep (disallowed)
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- B B C C --soft B B C
- --mixed B C C
- --hard C C C
- --merge C C C
- --keep B C C
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- B C C D --soft B C D
- --mixed B D D
- --hard D D D
- --merge (disallowed)
- --keep (disallowed)
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- B C C C --soft B C C
- --mixed B C C
- --hard C C C
- --merge B C C
- --keep B C C
-
-"reset --merge" is meant to be used when resetting out of a conflicted
+file is in state `A` in the working tree, in state `B` in the index, in
+state `C` in `HEAD` and in state `D` in the target, then `git reset --soft
+target` will leave the file in the working tree in state `A` and in the
+index in state `B`. It resets (i.e. moves) the `HEAD` (i.e. the tip of
+the current branch, if you are on one) to `target` (which has the file
+in state `D`).
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ A B C D --soft A B D
+ --mixed A D D
+ --hard D D D
+ --merge (disallowed)
+ --keep (disallowed)
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ A B C C --soft A B C
+ --mixed A C C
+ --hard C C C
+ --merge (disallowed)
+ --keep A C C
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ B B C D --soft B B D
+ --mixed B D D
+ --hard D D D
+ --merge D D D
+ --keep (disallowed)
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ B B C C --soft B B C
+ --mixed B C C
+ --hard C C C
+ --merge C C C
+ --keep B C C
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ B C C D --soft B C D
+ --mixed B D D
+ --hard D D D
+ --merge (disallowed)
+ --keep (disallowed)
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ B C C C --soft B C C
+ --mixed B C C
+ --hard C C C
+ --merge B C C
+ --keep B C C
+....
+
+`reset --merge` is meant to be used when resetting out of a conflicted
merge. Any mergy operation guarantees that the working tree file that is
involved in the merge does not have local change wrt the index before
it starts, and that it writes the result out to the working tree. So if
we see some difference between the index and the target and also
between the index and the working tree, then it means that we are not
resetting out from a state that a mergy operation left after failing
-with a conflict. That is why we disallow --merge option in this case.
+with a conflict. That is why we disallow `--merge` option in this case.
-"reset --keep" is meant to be used when removing some of the last
+`reset --keep` is meant to be used when removing some of the last
commits in the current branch while keeping changes in the working
tree. If there could be conflicts between the changes in the commit we
want to remove and the changes in the working tree we want to keep,
the reset is disallowed. That's why it is disallowed if there are both
-changes between the working tree and HEAD, and between HEAD and the
+changes between the working tree and `HEAD`, and between `HEAD` and the
target. To be safe, it is also disallowed when there are unmerged
entries.
The following tables show what happens when there are unmerged
entries:
- working index HEAD target working index HEAD
- ----------------------------------------------------
- X U A B --soft (disallowed)
- --mixed X B B
- --hard B B B
- --merge B B B
- --keep (disallowed)
-
- working index HEAD target working index HEAD
- ----------------------------------------------------
- X U A A --soft (disallowed)
- --mixed X A A
- --hard A A A
- --merge A A A
- --keep (disallowed)
-
-X means any state and U means an unmerged index.
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ X U A B --soft (disallowed)
+ --mixed X B B
+ --hard B B B
+ --merge B B B
+ --keep (disallowed)
+....
+
+....
+working index HEAD target working index HEAD
+----------------------------------------------------
+ X U A A --soft (disallowed)
+ --mixed X A A
+ --hard A A A
+ --merge A A A
+ --keep (disallowed)
+....
+
+`X` means any state and `U` means an unmerged index.
GIT
---
diff --git a/builtin/log.c b/builtin/log.c
index 0fe6f9b..5ac18e2 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1096,7 +1096,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
if (rev->rdiff1) {
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
show_range_diff(rev->rdiff1, rev->rdiff2,
- rev->creation_factor, 1, &rev->diffopt);
+ rev->creation_factor, 1, NULL);
}
}
diff --git a/builtin/push.c b/builtin/push.c
index d09a420..8bb8a08 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -173,10 +173,10 @@ static NORETURN int die_push_simple(struct branch *branch, struct remote *remote
"\n"
"To push to the branch of the same name on the remote, use\n"
"\n"
- " git push %s %s\n"
+ " git push %s HEAD\n"
"%s"),
remote->name, short_upstream,
- remote->name, branch->name, advice_maybe);
+ remote->name, advice_maybe);
}
static const char message_detached_head_die[] =
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 5b3e5ba..b5c99ec 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -776,6 +776,23 @@ static void NORETURN error_on_missing_default_upstream(void)
exit(1);
}
+static void set_reflog_action(struct rebase_options *options)
+{
+ const char *env;
+ struct strbuf buf = STRBUF_INIT;
+
+ if (!is_interactive(options))
+ return;
+
+ env = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);
+ if (env && strcmp("rebase", env))
+ return; /* only override it if it is "rebase" */
+
+ strbuf_addf(&buf, "rebase -i (%s)", options->action);
+ setenv(GIT_REFLOG_ACTION_ENVIRONMENT, buf.buf, 1);
+ strbuf_release(&buf);
+}
+
int cmd_rebase(int argc, const char **argv, const char *prefix)
{
struct rebase_options options = {
@@ -871,7 +888,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
"them"), REBASE_PRESERVE_MERGES),
OPT_BOOL(0, "rerere-autoupdate",
&options.allow_rerere_autoupdate,
- N_("allow rerere to update index with resolved "
+ N_("allow rerere to update index with resolved "
"conflict")),
OPT_BOOL('k', "keep-empty", &options.keep_empty,
N_("preserve empty commits during rebase")),
@@ -978,6 +995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (action != NO_ACTION && !in_progress)
die(_("No rebase in progress?"));
+ setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0);
if (action == ACTION_EDIT_TODO && !is_interactive(&options))
die(_("The --edit-todo action can only be used during "
@@ -990,6 +1008,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
int fd;
options.action = "continue";
+ set_reflog_action(&options);
/* Sanity check */
if (get_oid("HEAD", &head))
@@ -1018,6 +1037,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
struct string_list merge_rr = STRING_LIST_INIT_DUP;
options.action = "skip";
+ set_reflog_action(&options);
rerere_clear(&merge_rr);
string_list_clear(&merge_rr, 1);
@@ -1033,6 +1053,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
case ACTION_ABORT: {
struct string_list merge_rr = STRING_LIST_INIT_DUP;
options.action = "abort";
+ set_reflog_action(&options);
rerere_clear(&merge_rr);
string_list_clear(&merge_rr, 1);
@@ -1440,11 +1461,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
}
strbuf_reset(&buf);
- strbuf_addf(&buf, "rebase: checkout %s",
+ strbuf_addf(&buf, "%s: checkout %s",
+ getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
options.switch_to);
if (reset_head(&oid, "checkout",
options.head_name, 0,
- NULL, NULL) < 0) {
+ NULL, buf.buf) < 0) {
ret = !!error(_("could not switch to "
"%s"),
options.switch_to);
@@ -1481,10 +1503,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (options.flags & REBASE_DIFFSTAT) {
struct diff_options opts;
- if (options.flags & REBASE_VERBOSE)
- printf(_("Changes from %s to %s:\n"),
- oid_to_hex(&merge_base),
- oid_to_hex(&options.onto->object.oid));
+ if (options.flags & REBASE_VERBOSE) {
+ if (is_null_oid(&merge_base))
+ printf(_("Changes to %s:\n"),
+ oid_to_hex(&options.onto->object.oid));
+ else
+ printf(_("Changes from %s to %s:\n"),
+ oid_to_hex(&merge_base),
+ oid_to_hex(&options.onto->object.oid));
+ }
/* We want color (if set), but no pager */
diff_setup(&opts);
@@ -1494,8 +1521,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
- diff_tree_oid(&merge_base, &options.onto->object.oid,
- "", &opts);
+ diff_tree_oid(is_null_oid(&merge_base) ?
+ the_hash_algo->empty_tree : &merge_base,
+ &options.onto->object.oid, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}
@@ -1508,7 +1536,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
printf(_("First, rewinding head to replay your work on top of "
"it...\n"));
- strbuf_addf(&msg, "rebase: checkout %s", options.onto_name);
+ strbuf_addf(&msg, "%s: checkout %s",
+ getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
if (reset_head(&options.onto->object.oid, "checkout", NULL,
RESET_HEAD_DETACH, NULL, msg.buf))
die(_("Could not detach HEAD"));
@@ -1520,7 +1549,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
*/
strbuf_reset(&msg);
if (!oidcmp(&merge_base, &options.orig_head)) {
- printf(_("Fast-forwarded %s to %s. \n"),
+ printf(_("Fast-forwarded %s to %s.\n"),
branch_name, options.onto_name);
strbuf_addf(&msg, "rebase finished: %s onto %s",
options.head_name ? options.head_name : "detached HEAD",
diff --git a/builtin/replace.c b/builtin/replace.c
index a58b9c6..affcdfb 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -495,6 +495,7 @@ static int convert_graft_file(int force)
if (!fp)
return -1;
+ advice_graft_file_deprecated = 0;
while (strbuf_getline(&buf, fp) != EOF) {
if (*buf.buf == '#')
continue;
diff --git a/compat/msvc.h b/compat/msvc.h
index 580bb55..29a8ce8 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -10,18 +10,12 @@
#define inline __inline
#define __inline__ __inline
#define __attribute__(x)
+#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define ftruncate _chsize
#define strtoull _strtoui64
#define strtoll _strtoi64
-static __inline int strcasecmp (const char *s1, const char *s2)
-{
- int size1 = strlen(s1);
- int sisz2 = strlen(s2);
- return _strnicmp(s1, s2, sisz2 > size1 ? sisz2 : size1);
-}
-
#undef ERROR
#include "compat/mingw.h"
diff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh
index b97ffdc..b4c7dbf 100755
--- a/git-legacy-rebase.sh
+++ b/git-legacy-rebase.sh
@@ -718,10 +718,16 @@ if test -n "$diffstat"
then
if test -n "$verbose"
then
- echo "$(eval_gettext "Changes from \$mb to \$onto:")"
+ if test -z "$mb"
+ then
+ echo "$(eval_gettext "Changes to \$onto:")"
+ else
+ echo "$(eval_gettext "Changes from \$mb to \$onto:")"
+ fi
fi
+ mb_tree="${mb:-$(git hash-object -t tree /dev/null)}"
# We want color (if set), but no pager
- GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
+ GIT_PAGER='' git diff --stat --summary "$mb_tree" "$onto"
fi
test -n "$interactive_rebase" && run_specific_rebase
diff --git a/http.c b/http.c
index 3dc8c56..eacc2a7 100644
--- a/http.c
+++ b/http.c
@@ -834,7 +834,7 @@ static CURL *get_curl_handle(void)
#if LIBCURL_VERSION_NUM >= 0x072c00
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
#else
- warning(_("CURLSSLOPT_NO_REVOKE not suported with cURL < 7.44.0"));
+ warning(_("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0"));
#endif
}
diff --git a/log-tree.c b/log-tree.c
index 7a83e99..b243779 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -762,7 +762,7 @@ void show_log(struct rev_info *opt)
next_commentary_block(opt, NULL);
fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
show_range_diff(opt->rdiff1, opt->rdiff2,
- opt->creation_factor, 1, &opt->diffopt);
+ opt->creation_factor, 1, NULL);
memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
}
diff --git a/midx.c b/midx.c
index 730ff84..2a6a24f 100644
--- a/midx.c
+++ b/midx.c
@@ -202,7 +202,7 @@ int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id)
struct strbuf pack_name = STRBUF_INIT;
if (pack_int_id >= m->num_packs)
- die(_("bad pack-int-id: %u (%u total packs"),
+ die(_("bad pack-int-id: %u (%u total packs)"),
pack_int_id, m->num_packs);
if (m->packs[pack_int_id])
diff --git a/range-diff.c b/range-diff.c
index 767af8c..48b0e1b 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -460,7 +460,11 @@ int show_range_diff(const char *range1, const char *range2,
struct diff_options opts;
struct strbuf indent = STRBUF_INIT;
- memcpy(&opts, diffopt, sizeof(opts));
+ if (diffopt)
+ memcpy(&opts, diffopt, sizeof(opts));
+ else
+ diff_setup(&opts);
+
if (!opts.output_format)
opts.output_format = DIFF_FORMAT_PATCH;
opts.flags.suppress_diff_headers = 1;
diff --git a/range-diff.h b/range-diff.h
index 190593f..08a50b6 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -5,6 +5,11 @@
#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
+/*
+ * Compare series of commmits in RANGE1 and RANGE2, and emit to the
+ * standard output. NULL can be passed to DIFFOPT to use the built-in
+ * default.
+ */
int show_range_diff(const char *range1, const char *range2,
int creation_factor, int dual_color,
struct diff_options *diffopt);
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 9183875..dd8abe9 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -180,7 +180,8 @@ static void files_reflog_path(struct files_ref_store *refs,
break;
case REF_TYPE_OTHER_PSEUDOREF:
case REF_TYPE_MAIN_PSEUDOREF:
- return files_reflog_path_other_worktrees(refs, sb, refname);
+ files_reflog_path_other_worktrees(refs, sb, refname);
+ break;
case REF_TYPE_NORMAL:
strbuf_addf(sb, "%s/logs/%s", refs->gitcommondir, refname);
break;
diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
index edbea2d..f98de95 100644
--- a/t/lib-git-daemon.sh
+++ b/t/lib-git-daemon.sh
@@ -92,7 +92,7 @@ stop_git_daemon() {
kill "$GIT_DAEMON_PID"
wait "$GIT_DAEMON_PID" >&3 2>&4
ret=$?
- if test_match_signal 15 $?
+ if ! test_match_signal 15 $ret
then
error "git daemon exited with status: $ret"
fi
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 11d1922..2e33ab3 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -82,7 +82,7 @@ test_perf_do_repo_symlink_config_ () {
test_perf_create_repo_from () {
test "$#" = 2 ||
- error "bug in the test script: not 2 parameters to test-create-repo"
+ BUG "not 2 parameters to test-create-repo"
repo="$1"
source="$2"
source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)"
@@ -184,7 +184,7 @@ test_wrapper_ () {
test_start_
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test-expect-success"
+ BUG "not 2 or 3 parameters to test-expect-success"
export test_prereq
if ! test_skip "$@"
then
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 182da06..42a263c 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -319,14 +319,14 @@ test_lazy_prereq GETCWD_IGNORES_PERMS '
base=GETCWD_TEST_BASE_DIR &&
mkdir -p $base/dir &&
chmod 100 $base ||
- error "bug in test script: cannot prepare $base"
+ BUG "cannot prepare $base"
(cd $base/dir && /bin/pwd -P)
status=$?
chmod 700 $base &&
rm -rf $base ||
- error "bug in test script: cannot clean $base"
+ BUG "cannot clean $base"
return $status
'
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh
index 38bd876..f64b130 100755
--- a/t/t3406-rebase-message.sh
+++ b/t/t3406-rebase-message.sh
@@ -91,4 +91,40 @@ test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' '
test_i18ngrep "Invalid whitespace option" err
'
+test_expect_success 'GIT_REFLOG_ACTION' '
+ git checkout start &&
+ test_commit reflog-onto &&
+ git checkout -b reflog-topic start &&
+ test_commit reflog-to-rebase &&
+
+ git rebase reflog-onto &&
+ git log -g --format=%gs -3 >actual &&
+ cat >expect <<-\EOF &&
+ rebase finished: returning to refs/heads/reflog-topic
+ rebase: reflog-to-rebase
+ rebase: checkout reflog-onto
+ EOF
+ test_cmp expect actual &&
+
+ git checkout -b reflog-prefix reflog-to-rebase &&
+ GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&
+ git log -g --format=%gs -3 >actual &&
+ cat >expect <<-\EOF &&
+ rebase finished: returning to refs/heads/reflog-prefix
+ change-the-reflog: reflog-to-rebase
+ change-the-reflog: checkout reflog-onto
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'rebase -i onto unrelated history' '
+ git init unrelated &&
+ test_commit -C unrelated 1 &&
+ git -C unrelated remote add -f origin "$PWD" &&
+ git -C unrelated branch --set-upstream-to=origin/master &&
+ git -C unrelated -c core.editor=true rebase -i -v --stat >actual &&
+ test_i18ngrep "Changes to " actual &&
+ test_i18ngrep "5 files changed" actual
+'
+
test_done
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 73f7038..7d985ff 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -129,7 +129,7 @@ do
case "$magic" in
noellipses) ;;
*)
- die "bug in t4103: unknown magic $magic" ;;
+ BUG "unknown magic $magic" ;;
esac ;;
*)
cmd="$magic $cmd" magic=
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 7316365..37e8e80 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -95,7 +95,7 @@ mk_child() {
check_push_result () {
test $# -ge 3 ||
- error "bug in the test script: check_push_result requires at least 3 parameters"
+ BUG "check_push_result requires at least 3 parameters"
repo_name="$1"
shift
diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh
index b24d8b0..90d890d 100755
--- a/t/t5562-http-backend-content-length.sh
+++ b/t/t5562-http-backend-content-length.sh
@@ -31,6 +31,7 @@ test_http_env() {
PATH_TRANSLATED="$PWD/.git/git-$handler_type-pack" \
GIT_HTTP_EXPORT_ALL=TRUE \
REQUEST_METHOD=POST \
+ "$PERL_PATH" \
"$TEST_DIRECTORY"/t5562/invoke-with-content-length.pl \
"$request_body" git http-backend >act.out 2>act.err
}
diff --git a/t/t5562/invoke-with-content-length.pl b/t/t5562/invoke-with-content-length.pl
index 6c2aae7..0943474 100755..100644
--- a/t/t5562/invoke-with-content-length.pl
+++ b/t/t5562/invoke-with-content-length.pl
@@ -1,4 +1,3 @@
-#!/usr/bin/perl
use 5.008;
use strict;
use warnings;
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index c28d51b..8bbc706 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -628,7 +628,7 @@ test_expect_success 'clone on case-insensitive fs' '
)
'
-test_expect_success !MINGW,CASE_INSENSITIVE_FS 'colliding file detection' '
+test_expect_success CASE_INSENSITIVE_FS 'colliding file detection' '
grep X icasefs/warning &&
grep x icasefs/warning &&
test_i18ngrep "the following paths have collided" icasefs/warning
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 86374a9..5d6d318 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -461,7 +461,10 @@ test_expect_success '--convert-graft-file' '
printf "%s\n%s %s\n\n# comment\n%s\n" \
$(git rev-parse HEAD^^ HEAD^ HEAD^^ HEAD^2) \
>.git/info/grafts &&
- git replace --convert-graft-file &&
+ git status 2>stderr &&
+ test_i18ngrep "hint:.*grafts is deprecated" stderr &&
+ git replace --convert-graft-file 2>stderr &&
+ test_i18ngrep ! "hint:.*grafts is deprecated" stderr &&
test_path_is_missing .git/info/grafts &&
: verify that the history is now "grafted" &&
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 3c6b185..d01ad8e 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1249,7 +1249,7 @@ test_expect_success 'teardown after ref completion' '
test_path_completion ()
{
- test $# = 2 || error "bug in the test script: not 2 parameters to test_path_completion"
+ test $# = 2 || BUG "not 2 parameters to test_path_completion"
local cur="$1" expected="$2"
echo "$expected" >expected &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b4e3915..6b3bbf9 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -418,14 +418,14 @@ test_declared_prereq () {
test_verify_prereq () {
test -z "$test_prereq" ||
expr >/dev/null "$test_prereq" : '[A-Z0-9_,!]*$' ||
- error "bug in the test script: '$test_prereq' does not look like a prereq"
+ BUG "'$test_prereq' does not look like a prereq"
}
test_expect_failure () {
test_start_
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
+ BUG "not 2 or 3 parameters to test-expect-failure"
test_verify_prereq
export test_prereq
if ! test_skip "$@"
@@ -445,7 +445,7 @@ test_expect_success () {
test_start_
test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test-expect-success"
+ BUG "not 2 or 3 parameters to test-expect-success"
test_verify_prereq
export test_prereq
if ! test_skip "$@"
@@ -472,7 +472,7 @@ test_expect_success () {
test_external () {
test "$#" = 4 && { test_prereq=$1; shift; } || test_prereq=
test "$#" = 3 ||
- error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
+ BUG "not 3 or 4 parameters to test_external"
descr="$1"
shift
test_verify_prereq
@@ -613,7 +613,7 @@ test_path_is_missing () {
test_line_count () {
if test $# != 3
then
- error "bug in the test script: not 3 parameters to test_line_count"
+ BUG "not 3 parameters to test_line_count"
elif ! test $(wc -l <"$3") "$1" "$2"
then
echo "test_line_count: line count for $3 !$1 $2"
@@ -793,13 +793,12 @@ test_i18ngrep () {
eval "last_arg=\${$#}"
test -f "$last_arg" ||
- error "bug in the test script: test_i18ngrep requires a file" \
- "to read as the last parameter"
+ BUG "test_i18ngrep requires a file to read as the last parameter"
if test $# -lt 2 ||
{ test "x!" = "x$1" && test $# -lt 3 ; }
then
- error "bug in the test script: too few parameters to test_i18ngrep"
+ BUG "too few parameters to test_i18ngrep"
fi
if test_have_prereq !C_LOCALE_OUTPUT
@@ -854,9 +853,23 @@ test_must_be_empty () {
# Tests that its two parameters refer to the same revision
test_cmp_rev () {
- git rev-parse --verify "$1" >expect.rev &&
- git rev-parse --verify "$2" >actual.rev &&
- test_cmp expect.rev actual.rev
+ if test $# != 2
+ then
+ error "bug in the test script: test_cmp_rev requires two revisions, but got $#"
+ else
+ local r1 r2
+ r1=$(git rev-parse --verify "$1") &&
+ r2=$(git rev-parse --verify "$2") &&
+ if test "$r1" != "$r2"
+ then
+ cat >&4 <<-EOF
+ error: two revisions point to different objects:
+ '$1': $r1
+ '$2': $r2
+ EOF
+ return 1
+ fi
+ fi
}
# Print a sequence of integers in increasing order, either with
@@ -871,7 +884,7 @@ test_seq () {
case $# in
1) set 1 "$@" ;;
2) ;;
- *) error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
+ *) BUG "not 1 or 2 parameters to test_seq" ;;
esac
test_seq_counter__=$1
while test "$test_seq_counter__" -le "$2"
@@ -909,7 +922,7 @@ test_when_finished () {
# doing so on Bash is better than nothing (the test will
# silently pass on other shells).
test "${BASH_SUBSHELL-0}" = 0 ||
- error "bug in test script: test_when_finished does nothing in a subshell"
+ BUG "test_when_finished does nothing in a subshell"
test_cleanup="{ $*
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
}
@@ -918,7 +931,7 @@ test_when_finished () {
# Usage: test_create_repo <directory>
test_create_repo () {
test "$#" = 1 ||
- error "bug in the test script: not 1 parameter to test-create-repo"
+ BUG "not 1 parameter to test-create-repo"
repo="$1"
mkdir -p "$repo"
(
@@ -1231,7 +1244,7 @@ test_oid_cache () {
if ! expr "$k" : '[a-z0-9][a-z0-9]*$' >/dev/null
then
- error 'bug in the test script: bad hash algorithm'
+ BUG 'bad hash algorithm'
fi &&
eval "test_oid_${k}_$tag=\"\$v\""
done
@@ -1246,7 +1259,7 @@ test_oid () {
# key-hash pair, so exit with an error.
if eval "test -z \"\${$var+set}\""
then
- error "bug in the test script: undefined key '$1'" >&2
+ BUG "undefined key '$1'"
fi &&
eval "printf '%s' \"\${$var}\""
}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 6c6c0af..0f1faa2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -402,6 +402,10 @@ error () {
exit 1
}
+BUG () {
+ error >&7 "bug in the test script: $*"
+}
+
say () {
say_color info "$*"
}
@@ -729,7 +733,7 @@ test_run_ () {
if $(printf '%s\n' "$1" | sed -f "$GIT_BUILD_DIR/t/chainlint.sed" | grep -q '?![A-Z][A-Z]*?!') ||
test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
then
- error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
+ BUG "broken &&-chain or run-away HERE-DOC: $1"
fi
trace=$trace_tmp
fi
@@ -1231,7 +1235,7 @@ test_lazy_prereq SANITY '
chmod -w SANETESTD.1 &&
chmod -r SANETESTD.1/x &&
chmod -rx SANETESTD.2 ||
- error "bug in test sript: cannot prepare SANETESTD"
+ BUG "cannot prepare SANETESTD"
! test -r SANETESTD.1/x &&
! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
@@ -1239,7 +1243,7 @@ test_lazy_prereq SANITY '
chmod +rwx SANETESTD.1 SANETESTD.2 &&
rm -rf SANETESTD.1 SANETESTD.2 ||
- error "bug in test sript: cannot clean SANETESTD"
+ BUG "cannot clean SANETESTD"
return $status
'
diff --git a/transport-helper.c b/transport-helper.c
index 7213fa0..bf225c6 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -573,7 +573,7 @@ static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
fprintf(stderr, "Debug: Falling back to dumb "
"transport.\n");
} else {
- die(_(_("unknown response to connect: %s")),
+ die(_("unknown response to connect: %s"),
cmdbuf->buf);
}