summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Documentation/MyFirstContribution.txt16
-rw-r--r--Documentation/RelNotes/2.30.0.txt84
-rw-r--r--Documentation/config/credential.txt6
-rw-r--r--Documentation/config/format.txt5
-rw-r--r--Documentation/config/gc.txt6
-rw-r--r--Documentation/git-format-patch.txt8
-rw-r--r--Documentation/git-parse-remote.txt23
-rw-r--r--Documentation/git-rev-parse.txt8
-rw-r--r--Documentation/git-update-ref.txt3
-rw-r--r--Documentation/technical/api-trace2.txt2
-rw-r--r--Makefile3
-rw-r--r--add-interactive.c40
-rw-r--r--add-patch.c25
-rw-r--r--archive.c1
-rw-r--r--archive.h2
-rw-r--r--attr.c26
-rw-r--r--bisect.c27
-rw-r--r--blame.c2
-rw-r--r--block-sha1/sha1.c2
-rw-r--r--block-sha1/sha1.h2
-rw-r--r--bloom.c5
-rw-r--r--builtin/credential-store.c8
-rw-r--r--builtin/difftool.c9
-rw-r--r--builtin/fetch.c6
-rw-r--r--builtin/gc.c14
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/log.c20
-rw-r--r--builtin/pack-redundant.c6
-rw-r--r--builtin/pull.c72
-rw-r--r--builtin/receive-pack.c94
-rw-r--r--builtin/repack.c153
-rw-r--r--builtin/rev-parse.c100
-rw-r--r--builtin/shortlog.c61
-rw-r--r--builtin/stash.c2
-rw-r--r--builtin/update-ref.c15
-rw-r--r--builtin/worktree.c4
-rw-r--r--cache.h1
-rwxr-xr-xci/print-test-failures.sh2
-rw-r--r--command-list.txt1
-rw-r--r--config.c2
-rw-r--r--config.mak.uname8
-rw-r--r--contrib/completion/git-completion.bash54
-rw-r--r--csum-file.h7
-rw-r--r--diff-lib.c2
-rw-r--r--diff.c7
-rw-r--r--diffcore-rename.c2
-rw-r--r--dir.c8
-rwxr-xr-xgit-add--interactive.perl12
-rw-r--r--git-compat-util.h2
-rw-r--r--git-mergetool--lib.sh4
-rw-r--r--git-parse-remote.sh101
-rwxr-xr-xgit-submodule.sh21
-rw-r--r--hashmap.c74
-rw-r--r--hashmap.h91
-rw-r--r--list-objects-filter-options.c2
-rw-r--r--log-tree.c2
-rw-r--r--log-tree.h1
-rw-r--r--merge-recursive.c6
-rw-r--r--mergetools/bc1
-rw-r--r--midx.c9
-rw-r--r--name-hash.c4
-rw-r--r--notes.c2
-rw-r--r--object.c2
-rw-r--r--oidmap.c2
-rw-r--r--pack-check.c10
-rw-r--r--pack-revindex.c2
-rw-r--r--pack-write.c5
-rw-r--r--packfile.c33
-rw-r--r--patch-ids.c2
-rw-r--r--range-diff.c6
-rw-r--r--ref-filter.c2
-rw-r--r--revision.c11
-rw-r--r--revision.h1
-rw-r--r--send-pack.c1
-rw-r--r--sequencer.c4
-rw-r--r--strmap.c178
-rw-r--r--strmap.h268
-rw-r--r--submodule-config.c4
-rw-r--r--t/helper/test-hashmap.c9
-rw-r--r--t/helper/test-proc-receive.c54
-rwxr-xr-xt/perf/p1400-update-ref.sh20
-rwxr-xr-xt/t0000-basic.sh21
-rwxr-xr-xt/t1309-early-config.sh4
-rwxr-xr-xt/t1400-update-ref.sh138
-rwxr-xr-xt/t1503-rev-parse-verify.sh13
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh25
-rwxr-xr-xt/t2106-update-index-assume-unchanged.sh31
-rwxr-xr-xt/t3040-subprojects-basic.sh3
-rwxr-xr-xt/t3301-notes.sh5
-rwxr-xr-xt/t3404-rebase-interactive.sh89
-rwxr-xr-xt/t3701-add-interactive.sh84
-rwxr-xr-xt/t4014-format-patch.sh54
-rwxr-xr-xt/t4015-diff-whitespace.sh6
-rwxr-xr-xt/t5310-pack-bitmaps.sh4
-rwxr-xr-xt/t5319-multi-pack-index.sh30
-rw-r--r--t/t5411/common-functions.sh7
-rw-r--r--t/t5411/test-0000-standard-git-push.sh9
-rw-r--r--t/t5411/test-0001-standard-git-push--porcelain.sh15
-rw-r--r--t/t5411/test-0013-bad-protocol.sh138
-rw-r--r--t/t5411/test-0014-bad-protocol--porcelain.sh173
-rw-r--r--t/t5411/test-0026-push-options.sh60
-rw-r--r--t/t5411/test-0027-push-options--porcelain.sh62
-rwxr-xr-xt/t5572-pull-submodule.sh56
-rwxr-xr-xt/t7601-merge-pull-config.sh7
-rwxr-xr-xt/t7800-difftool.sh13
-rwxr-xr-xt/t9902-completion.sh19
-rw-r--r--t/test-lib-functions.sh8
-rw-r--r--upload-pack.c1
-rw-r--r--usage.c6
110 files changed, 2169 insertions, 815 deletions
diff --git a/.gitignore b/.gitignore
index f85d02c854..f22b7a4cf1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,7 +115,6 @@
/git-pack-redundant
/git-pack-objects
/git-pack-refs
-/git-parse-remote
/git-patch-id
/git-prune
/git-prune-packed
diff --git a/Documentation/MyFirstContribution.txt b/Documentation/MyFirstContribution.txt
index 60eed5edcd..7c9a037cc2 100644
--- a/Documentation/MyFirstContribution.txt
+++ b/Documentation/MyFirstContribution.txt
@@ -1143,11 +1143,25 @@ After a few days, you will hopefully receive a reply to your patchset with some
comments. Woohoo! Now you can get back to work.
It's good manners to reply to each comment, notifying the reviewer that you have
-made the change requested, feel the original is better, or that the comment
+made the change suggested, feel the original is better, or that the comment
inspired you to do something a new way which is superior to both the original
and the suggested change. This way reviewers don't need to inspect your v2 to
figure out whether you implemented their comment or not.
+Reviewers may ask you about what you wrote in the patchset, either in
+the proposed commit log message or in the changes themselves. You
+should answer these questions in your response messages, but often the
+reason why reviewers asked these questions to understand what you meant
+to write is because your patchset needed clarification to be understood.
+
+Do not be satisfied by just answering their questions in your response
+and hear them say that they now understand what you wanted to say.
+Update your patches to clarify the points reviewers had trouble with,
+and prepare your v2; the words you used to explain your v1 to answer
+reviewers' questions may be useful thing to use. Your goal is to make
+your v2 clear enough so that it becomes unnecessary for you to give the
+same explanation to the next person who reads it.
+
If you are going to push back on a comment, be polite and explain why you feel
your original is better; be prepared that the reviewer may still disagree with
you, and the rest of the community may weigh in on one side or the other. As
diff --git a/Documentation/RelNotes/2.30.0.txt b/Documentation/RelNotes/2.30.0.txt
index 0933a7f84f..cb4d65f9ff 100644
--- a/Documentation/RelNotes/2.30.0.txt
+++ b/Documentation/RelNotes/2.30.0.txt
@@ -68,6 +68,16 @@ UI, Workflows & Features
* Zsh autocompletion (in contrib/) update.
+ * The maximum length of output filenames "git format-patch" creates
+ has become configurable (used to be capped at 64).
+
+ * "git rev-parse" learned the "--end-of-options" to help scripts to
+ safely take a parameter that is supposed to be a revision, e.g.
+ "git rev-parse --verify -q --end-of-options $rev".
+
+ * The command line completion script (in contrib/) learned to expand
+ commands that are alias of alias.
+
Performance, Internal Implementation, Development Support etc.
@@ -107,6 +117,27 @@ Performance, Internal Implementation, Development Support etc.
* "git fetch --depth=<n>" over the stateless RPC / smart HTTP
transport handled EOF from the client poorly at the server end.
+ * A specialization of hashmap that uses a string as key has been
+ introduced. Hopefully it will see wider use over time.
+
+ * "git bisect start/next" in a large span of history spends a lot of
+ time trying to come up with exactly the half-way point; this can be
+ optimized by stopping when we see a commit that is close enough to
+ the half-way point.
+
+ * A lazily defined test prerequisite can now be defined in terms of
+ another lazily defined test prerequisite.
+
+ * Expectation for the original contributor after responding to a
+ review comment to use the explanation in a patch update has been
+ described.
+
+ * Multiple "credential-store" backends can race to lock the same
+ file, causing everybody else but one to fail---reattempt locking
+ with some timeout to reduce the rate of the failure.
+
+ * "git-parse-remote" shell script library outlived its usefulness.
+
Fixes since v2.29
-----------------
@@ -217,6 +248,52 @@ Fixes since v2.29
non-existent object name in the input, instead of complaining.
(merge c714d05875 jc/blame-ignore-fix later to maint).
+ * Running "git diff" while allowing external diff in a state with
+ unmerged paths used to segfault, which has been corrected.
+ (merge d66851806f jk/diff-release-filespec-fix later to maint).
+
+ * Build configuration cleanup.
+ (merge b990f02fd8 ab/config-mak-uname-simplify later to maint).
+
+ * Fix regression introduced when nvimdiff support in mergetool was added.
+ (merge 12026f46e7 pd/mergetool-nvimdiff later to maint).
+
+ * The exchange between receive-pack and proc-receive hook did not
+ carefully check for errors.
+
+ * The code was not prepared to deal with pack .idx file that is
+ larger than 4GB.
+ (merge 81c4c5cf2e jk/4gb-idx later to maint).
+
+ * Since jgit does not yet work with SHA-256 repositories, mark the
+ tests that uses it not to run unless we are testing with ShA-1
+ repositories.
+ (merge ea699b4adc sg/t5310-jgit-wants-sha1 later to maint).
+
+ * Config parser fix for "git notes".
+ (merge 45fef1599a na/notes-displayref-is-not-boolean later to maint).
+
+ * Move a definition of compatibility wrapper from cache.h to
+ git-compat-util.h
+ (merge a76b138daa hn/sleep-millisec-decl later to maint).
+
+ * Error message fix.
+ (merge eaf5341538 km/stash-error-message-fix later to maint).
+
+ * "git pull --rebase --recurse-submodules" checked for local changes
+ in a wrong range and failed to run correctly when it should.
+ (merge 5176f20ffe pb/pull-rebase-recurse-submodules later to maint).
+
+ * "git push" that is killed may leave a pack-objects process behind,
+ still computing to find a good compression, wasting cycles. This
+ has been corrected.
+ (merge 8b59935114 jk/stop-pack-objects-when-push-is-killed later to maint).
+
+ * "git fetch" that is killed may leave a pack-objects process behind,
+ still computing to find a good compression, wasting cycles. This
+ has been corrected.
+ (merge 309a4028e7 jk/stop-pack-objects-when-fetch-is-killed later to maint).
+
* Other code cleanup, docfix, build fix, etc.
(merge 3e0a5dc9af cc/doc-filter-branch-typofix later to maint).
(merge 32c83afc2c cw/ci-ghwf-check-ws-errors later to maint).
@@ -234,3 +311,10 @@ Fixes since v2.29
(merge b7e20b4373 mc/typofix later to maint).
(merge f6bcd9a8a4 js/test-whitespace-fixes later to maint).
(merge 53b67a801b js/test-file-size later to maint).
+ (merge 970909c2a7 rs/hashwrite-be64 later to maint).
+ (merge 5a923bb1f0 ma/list-object-filter-opt-msgfix later to maint).
+ (merge 1c3e412916 rs/archive-plug-leak-refname later to maint).
+ (merge d44e5267ea rs/plug-diff-cache-leak later to maint).
+ (merge 793c1464d3 ab/gc-keep-base-option later to maint).
+ (merge b86339b12b mt/worktree-error-message-fix later to maint).
+ (merge e01ae2a4a7 js/pull-rebase-use-advise later to maint).
diff --git a/Documentation/config/credential.txt b/Documentation/config/credential.txt
index 9d01641c28..512f31876e 100644
--- a/Documentation/config/credential.txt
+++ b/Documentation/config/credential.txt
@@ -28,3 +28,9 @@ credential.<url>.*::
credentialCache.ignoreSIGHUP::
Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting.
+
+credentialStore.lockTimeoutMS::
+ The length of time, in milliseconds, for git-credential-store to retry
+ when trying to lock the credentials file. Value 0 means not to retry at
+ all; -1 means to try indefinitely. Default is 1000 (i.e., retry for
+ 1s).
diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt
index 851bf410a3..fdbc06a4d2 100644
--- a/Documentation/config/format.txt
+++ b/Documentation/config/format.txt
@@ -94,6 +94,11 @@ format.outputDirectory::
Set a custom directory to store the resulting files instead of the
current working directory. All directory components will be created.
+format.filenameMaxLength::
+ The maximum length of the output filenames generated by the
+ `format-patch` command; defaults to 64. Can be overridden
+ by the `--filename-max-length=<n>` command line option.
+
format.useAutoBase::
A boolean value which lets you enable the `--base=auto` option of
format-patch by default. Can also be set to "whenAble" to allow
diff --git a/Documentation/config/gc.txt b/Documentation/config/gc.txt
index 00ea0a678e..c834e07991 100644
--- a/Documentation/config/gc.txt
+++ b/Documentation/config/gc.txt
@@ -44,9 +44,9 @@ gc.autoDetach::
gc.bigPackThreshold::
If non-zero, all packs larger than this limit are kept when
- `git gc` is run. This is very similar to `--keep-base-pack`
+ `git gc` is run. This is very similar to `--keep-largest-pack`
except that all packs that meet the threshold are kept, not
- just the base pack. Defaults to zero. Common unit suffixes of
+ just the largest pack. Defaults to zero. Common unit suffixes of
'k', 'm', or 'g' are supported.
+
Note that if the number of kept packs is more than gc.autoPackLimit,
@@ -57,7 +57,7 @@ gc.autoPackLimit and gc.bigPackThreshold should be respected again.
If the amount of memory estimated for `git repack` to run smoothly is
not available and `gc.bigPackThreshold` is not set, the largest pack
will also be excluded (this is the equivalent of running `git gc` with
-`--keep-base-pack`).
+`--keep-largest-pack`).
gc.writeCommitGraph::
If true, then gc will rewrite the commit-graph file when
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index bf1bb40f63..3e49bf2210 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -28,6 +28,7 @@ SYNOPSIS
[--no-notes | --notes[=<ref>]]
[--interdiff=<previous>]
[--range-diff=<previous> [--creation-factor=<percent>]]
+ [--filename-max-length=<n>]
[--progress]
[<common diff options>]
[ <since> | <revision range> ]
@@ -200,6 +201,13 @@ populated with placeholder text.
allows for useful naming of a patch series, and can be
combined with the `--numbered` option.
+--filename-max-length=<n>::
+ Instead of the standard 64 bytes, chomp the generated output
+ filenames at around '<n>' bytes (too short a value will be
+ silently raised to a reasonable length). Defaults to the
+ value of the `format.filenameMaxLength` configuration
+ variable, or 64 if unconfigured.
+
--rfc::
Alias for `--subject-prefix="RFC PATCH"`. RFC means "Request For
Comments"; use this when sending an experimental patch for
diff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt
deleted file mode 100644
index a45ea1ece8..0000000000
--- a/Documentation/git-parse-remote.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-git-parse-remote(1)
-===================
-
-NAME
-----
-git-parse-remote - Routines to help parsing remote repository access parameters
-
-
-SYNOPSIS
---------
-[verse]
-'. "$(git --exec-path)/git-parse-remote"'
-
-DESCRIPTION
------------
-This script is included in various scripts to supply
-routines to parse files under $GIT_DIR/remotes/ and
-$GIT_DIR/branches/ and configuration variables that are related
-to fetching, pulling and pushing.
-
-GIT
----
-Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 19b12b6d43..5013daa6ef 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -109,6 +109,10 @@ names an existing object that is a commit-ish (i.e. a commit, or an
annotated tag that points at a commit). To make sure that `$VAR`
names an existing object of any type, `git rev-parse "$VAR^{object}"`
can be used.
++
+Note that if you are verifying a name from an untrusted source, it is
+wise to use `--end-of-options` so that the name argument is not mistaken
+for another option.
-q::
--quiet::
@@ -446,7 +450,7 @@ $ git rev-parse --verify HEAD
* Print the commit object name from the revision in the $REV shell variable:
+
------------
-$ git rev-parse --verify $REV^{commit}
+$ git rev-parse --verify --end-of-options $REV^{commit}
------------
+
This will error out if $REV is empty or not a valid revision.
@@ -454,7 +458,7 @@ This will error out if $REV is empty or not a valid revision.
* Similar to above:
+
------------
-$ git rev-parse --default master --verify $REV
+$ git rev-parse --default master --verify --end-of-options $REV
------------
+
but if $REV is empty, the commit object name from master will be printed.
diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt
index d401234b03..48b6683071 100644
--- a/Documentation/git-update-ref.txt
+++ b/Documentation/git-update-ref.txt
@@ -125,7 +125,8 @@ option::
start::
Start a transaction. In contrast to a non-transactional session, a
transaction will automatically abort if the session ends without an
- explicit commit.
+ explicit commit. This command may create a new empty transaction when
+ the current one has been committed or aborted already.
prepare::
Prepare to commit the transaction. This will create lock files for all
diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 6b6085585d..c65ffafc48 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -466,7 +466,7 @@ completed.)
`"error"`::
This event is emitted when one of the `error()`, `die()`,
- or `usage()` functions are called.
+ `warning()`, or `usage()` functions are called.
+
------------
{
diff --git a/Makefile b/Makefile
index dd1cf41e00..45bce31016 100644
--- a/Makefile
+++ b/Makefile
@@ -613,7 +613,6 @@ SCRIPT_SH += git-submodule.sh
SCRIPT_SH += git-web--browse.sh
SCRIPT_LIB += git-mergetool--lib
-SCRIPT_LIB += git-parse-remote
SCRIPT_LIB += git-rebase--preserve-merges
SCRIPT_LIB += git-sh-i18n
SCRIPT_LIB += git-sh-setup
@@ -1004,6 +1003,7 @@ LIB_OBJS += stable-qsort.o
LIB_OBJS += strbuf.o
LIB_OBJS += streaming.o
LIB_OBJS += string-list.o
+LIB_OBJS += strmap.o
LIB_OBJS += strvec.o
LIB_OBJS += sub-process.o
LIB_OBJS += submodule-config.o
@@ -2582,7 +2582,6 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
--keyword=__ --keyword=N__ --keyword="__n:1,2"
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
LOCALIZED_SH = $(SCRIPT_SH)
-LOCALIZED_SH += git-parse-remote.sh
LOCALIZED_SH += git-rebase--preserve-merges.sh
LOCALIZED_SH += git-sh-setup.sh
LOCALIZED_PERL = $(SCRIPT_PERL)
diff --git a/add-interactive.c b/add-interactive.c
index 555c4abf32..9b8cdb4a31 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -12,10 +12,10 @@
#include "prompt.h"
static void init_color(struct repository *r, struct add_i_state *s,
- const char *slot_name, char *dst,
+ const char *section_and_slot, char *dst,
const char *default_color)
{
- char *key = xstrfmt("color.interactive.%s", slot_name);
+ char *key = xstrfmt("color.%s", section_and_slot);
const char *value;
if (!s->use_color)
@@ -40,20 +40,27 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
git_config_colorbool("color.interactive", value);
s->use_color = want_color(s->use_color);
- init_color(r, s, "header", s->header_color, GIT_COLOR_BOLD);
- init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED);
- init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE);
- init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED);
- init_color(r, s, "reset", s->reset_color, GIT_COLOR_RESET);
- init_color(r, s, "fraginfo", s->fraginfo_color,
+ init_color(r, s, "interactive.header", s->header_color, GIT_COLOR_BOLD);
+ init_color(r, s, "interactive.help", s->help_color, GIT_COLOR_BOLD_RED);
+ init_color(r, s, "interactive.prompt", s->prompt_color,
+ GIT_COLOR_BOLD_BLUE);
+ init_color(r, s, "interactive.error", s->error_color,
+ GIT_COLOR_BOLD_RED);
+
+ init_color(r, s, "diff.frag", s->fraginfo_color,
diff_get_color(s->use_color, DIFF_FRAGINFO));
- init_color(r, s, "context", s->context_color,
- diff_get_color(s->use_color, DIFF_CONTEXT));
- init_color(r, s, "old", s->file_old_color,
+ init_color(r, s, "diff.context", s->context_color, "fall back");
+ if (!strcmp(s->context_color, "fall back"))
+ init_color(r, s, "diff.plain", s->context_color,
+ diff_get_color(s->use_color, DIFF_CONTEXT));
+ init_color(r, s, "diff.old", s->file_old_color,
diff_get_color(s->use_color, DIFF_FILE_OLD));
- init_color(r, s, "new", s->file_new_color,
+ init_color(r, s, "diff.new", s->file_new_color,
diff_get_color(s->use_color, DIFF_FILE_NEW));
+ strlcpy(s->reset_color,
+ s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);
+
FREE_AND_NULL(s->interactive_diff_filter);
git_config_get_string("interactive.difffilter",
&s->interactive_diff_filter);
@@ -194,7 +201,8 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list)
else if (index + 1 < list->sorted.nr &&
starts_with(list->sorted.items[index + 1].string, string))
return -1;
- else if (index < list->sorted.nr)
+ else if (index < list->sorted.nr &&
+ starts_with(list->sorted.items[index].string, string))
item = list->sorted.items[index].util;
else
return -1;
@@ -364,7 +372,7 @@ static ssize_t list_and_choose(struct add_i_state *s,
if (from < 0 || from >= items->items.nr ||
(singleton && from + 1 != to)) {
- color_fprintf_ln(stdout, s->error_color,
+ color_fprintf_ln(stderr, s->error_color,
_("Huh (%s)?"), p);
break;
} else if (singleton) {
@@ -557,7 +565,7 @@ static int get_modified_files(struct repository *r,
if (ps)
clear_pathspec(&rev.prune_data);
}
- hashmap_free_entries(&s.file_map, struct pathname_entry, ent);
+ hashmap_clear_and_free(&s.file_map, struct pathname_entry, ent);
if (unmerged_count)
*unmerged_count = s.unmerged_count;
if (binary_count)
@@ -1131,7 +1139,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
print_file_item_data.color = data.color;
print_file_item_data.reset = data.reset;
- strbuf_addstr(&header, " ");
+ strbuf_addstr(&header, " ");
strbuf_addf(&header, print_file_item_data.modified_fmt,
_("staged"), _("unstaged"), _("path"));
opts.list_opts.header = header.buf;
diff --git a/add-patch.c b/add-patch.c
index be4cf6e9e5..2fad92ca37 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -661,13 +661,18 @@ static void render_hunk(struct add_p_state *s, struct hunk *hunk,
else
new_offset += delta;
- strbuf_addf(out, "@@ -%lu,%lu +%lu,%lu @@",
- old_offset, header->old_count,
- new_offset, header->new_count);
+ strbuf_addf(out, "@@ -%lu", old_offset);
+ if (header->old_count != 1)
+ strbuf_addf(out, ",%lu", header->old_count);
+ strbuf_addf(out, " +%lu", new_offset);
+ if (header->new_count != 1)
+ strbuf_addf(out, ",%lu", header->new_count);
+ strbuf_addstr(out, " @@");
+
if (len)
strbuf_add(out, p, len);
else if (colored)
- strbuf_addf(out, "%s\n", GIT_COLOR_RESET);
+ strbuf_addf(out, "%s\n", s->s.reset_color);
else
strbuf_addch(out, '\n');
}
@@ -1060,7 +1065,7 @@ static void recolor_hunk(struct add_p_state *s, struct hunk *hunk)
s->s.file_new_color :
s->s.context_color);
strbuf_add(&s->colored, plain + current, eol - current);
- strbuf_addstr(&s->colored, GIT_COLOR_RESET);
+ strbuf_addstr(&s->colored, s->s.reset_color);
if (next > eol)
strbuf_add(&s->colored, plain + eol, next - eol);
current = next;
@@ -1456,15 +1461,15 @@ static int patch_update_file(struct add_p_state *s,
else
prompt_mode_type = PROMPT_HUNK;
- color_fprintf(stdout, s->s.prompt_color,
- "(%"PRIuMAX"/%"PRIuMAX") ",
+ printf("%s(%"PRIuMAX"/%"PRIuMAX") ", s->s.prompt_color,
(uintmax_t)hunk_index + 1,
(uintmax_t)(file_diff->hunk_nr
? file_diff->hunk_nr
: 1));
- color_fprintf(stdout, s->s.prompt_color,
- _(s->mode->prompt_mode[prompt_mode_type]),
- s->buf.buf);
+ printf(_(s->mode->prompt_mode[prompt_mode_type]),
+ s->buf.buf);
+ if (*s->s.reset_color)
+ fputs(s->s.reset_color, stdout);
fflush(stdout);
if (read_single_character(s) == EOF)
break;
diff --git a/archive.c b/archive.c
index 7a888c5338..5919d9e505 100644
--- a/archive.c
+++ b/archive.c
@@ -658,6 +658,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
rc = ar->write_archive(ar, &args);
string_list_clear_func(&args.extra_files, extra_file_info_clear);
+ free(args.refname);
return rc;
}
diff --git a/archive.h b/archive.h
index e3d04e8ab3..33551b7ee1 100644
--- a/archive.h
+++ b/archive.h
@@ -8,7 +8,7 @@ struct repository;
struct archiver_args {
struct repository *repo;
- const char *refname;
+ char *refname;
const char *prefix;
const char *base;
size_t baselen;
diff --git a/attr.c b/attr.c
index a826b2ef1f..4ef85d668b 100644
--- a/attr.c
+++ b/attr.c
@@ -52,13 +52,6 @@ static inline void hashmap_unlock(struct attr_hashmap *map)
pthread_mutex_unlock(&map->mutex);
}
-/*
- * The global dictionary of all interned attributes. This
- * is a singleton object which is shared between threads.
- * Access to this dictionary must be surrounded with a mutex.
- */
-static struct attr_hashmap g_attr_hashmap;
-
/* The container for objects stored in "struct attr_hashmap" */
struct attr_hash_entry {
struct hashmap_entry ent;
@@ -80,11 +73,14 @@ static int attr_hash_entry_cmp(const void *unused_cmp_data,
return (a->keylen != b->keylen) || strncmp(a->key, b->key, a->keylen);
}
-/* Initialize an 'attr_hashmap' object */
-static void attr_hashmap_init(struct attr_hashmap *map)
-{
- hashmap_init(&map->map, attr_hash_entry_cmp, NULL, 0);
-}
+/*
+ * The global dictionary of all interned attributes. This
+ * is a singleton object which is shared between threads.
+ * Access to this dictionary must be surrounded with a mutex.
+ */
+static struct attr_hashmap g_attr_hashmap = {
+ HASHMAP_INIT(attr_hash_entry_cmp, NULL)
+};
/*
* Retrieve the 'value' stored in a hashmap given the provided 'key'.
@@ -96,9 +92,6 @@ static void *attr_hashmap_get(struct attr_hashmap *map,
struct attr_hash_entry k;
struct attr_hash_entry *e;
- if (!map->map.tablesize)
- attr_hashmap_init(map);
-
hashmap_entry_init(&k.ent, memhash(key, keylen));
k.key = key;
k.keylen = keylen;
@@ -114,9 +107,6 @@ static void attr_hashmap_add(struct attr_hashmap *map,
{
struct attr_hash_entry *e;
- if (!map->map.tablesize)
- attr_hashmap_init(map);
-
e = xmalloc(sizeof(struct attr_hash_entry));
hashmap_entry_init(&e->ent, memhash(key, keylen));
e->key = key;
diff --git a/bisect.c b/bisect.c
index 58bc9c73a4..d8c2c8f7a7 100644
--- a/bisect.c
+++ b/bisect.c
@@ -103,8 +103,10 @@ static int count_interesting_parents(struct commit *commit, unsigned bisect_flag
return count;
}
-static inline int halfway(struct commit_list *p, int nr)
+static inline int approx_halfway(struct commit_list *p, int nr)
{
+ int diff;
+
/*
* Don't short-cut something we are not going to return!
*/
@@ -113,13 +115,22 @@ static inline int halfway(struct commit_list *p, int nr)
if (DEBUG_BISECT)
return 0;
/*
- * 2 and 3 are halfway of 5.
+ * For small number of commits 2 and 3 are halfway of 5, and
* 3 is halfway of 6 but 2 and 4 are not.
*/
- switch (2 * weight(p) - nr) {
+ diff = 2 * weight(p) - nr;
+ switch (diff) {
case -1: case 0: case 1:
return 1;
default:
+ /*
+ * For large number of commits we are not so strict, it's
+ * good enough if it's within ~0.1% of the halfway point,
+ * e.g. 5000 is exactly halfway of 10000, but we consider
+ * the values [4996, 5004] as halfway as well.
+ */
+ if (abs(diff) < nr / 1024)
+ return 1;
return 0;
}
}
@@ -321,8 +332,9 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
weight_set(p, count_distance(p));
clear_distance(list);
- /* Does it happen to be at exactly half-way? */
- if (!(bisect_flags & FIND_BISECTION_ALL) && halfway(p, nr))
+ /* Does it happen to be at half-way? */
+ if (!(bisect_flags & FIND_BISECTION_ALL) &&
+ approx_halfway(p, nr))
return p;
counted++;
}
@@ -362,8 +374,9 @@ static struct commit_list *do_find_bisection(struct commit_list *list,
else
weight_set(p, weight(q));
- /* Does it happen to be at exactly half-way? */
- if (!(bisect_flags & FIND_BISECTION_ALL) && halfway(p, nr))
+ /* Does it happen to be at half-way? */
+ if (!(bisect_flags & FIND_BISECTION_ALL) &&
+ approx_halfway(p, nr))
return p;
}
}
diff --git a/blame.c b/blame.c
index 9156ebeafd..a5044fcfaa 100644
--- a/blame.c
+++ b/blame.c
@@ -435,7 +435,7 @@ static void get_fingerprint(struct fingerprint *result,
static void free_fingerprint(struct fingerprint *f)
{
- hashmap_free(&f->map);
+ hashmap_clear(&f->map);
free(f->entries);
}
diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
index 22b125cf8c..8681031402 100644
--- a/block-sha1/sha1.c
+++ b/block-sha1/sha1.c
@@ -203,7 +203,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)
ctx->H[4] = 0xc3d2e1f0;
}
-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, size_t len)
{
unsigned int lenW = ctx->size & 63;
diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h
index 4df6747752..9fb0441b98 100644
--- a/block-sha1/sha1.h
+++ b/block-sha1/sha1.h
@@ -13,7 +13,7 @@ typedef struct {
} blk_SHA_CTX;
void blk_SHA1_Init(blk_SHA_CTX *ctx);
-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);
+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, size_t len);
void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
#define platform_SHA_CTX blk_SHA_CTX
diff --git a/bloom.c b/bloom.c
index 68c73200a5..b176f28f53 100644
--- a/bloom.c
+++ b/bloom.c
@@ -229,10 +229,9 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
diffcore_std(&diffopt);
if (diff_queued_diff.nr <= settings->max_changed_paths) {
- struct hashmap pathmap;
+ struct hashmap pathmap = HASHMAP_INIT(pathmap_cmp, NULL);
struct pathmap_hash_entry *e;
struct hashmap_iter iter;
- hashmap_init(&pathmap, pathmap_cmp, NULL, 0);
for (i = 0; i < diff_queued_diff.nr; i++) {
const char *path = diff_queued_diff.queue[i]->two->path;
@@ -287,7 +286,7 @@ struct bloom_filter *get_or_compute_bloom_filter(struct repository *r,
}
cleanup:
- hashmap_free_entries(&pathmap, struct pathmap_hash_entry, entry);
+ hashmap_clear_and_free(&pathmap, struct pathmap_hash_entry, entry);
} else {
for (i = 0; i < diff_queued_diff.nr; i++)
diff_free_filepair(diff_queued_diff.queue[i]);
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index 5331ab151a..ae3c1ba75f 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "config.h"
#include "lockfile.h"
#include "credential.h"
#include "string-list.h"
@@ -58,8 +59,11 @@ static void print_line(struct strbuf *buf)
static void rewrite_credential_file(const char *fn, struct credential *c,
struct strbuf *extra)
{
- if (hold_lock_file_for_update(&credential_lock, fn, 0) < 0)
- die_errno("unable to get credential storage lock");
+ int timeout_ms = 1000;
+
+ git_config_get_int("credentialstore.locktimeoutms", &timeout_ms);
+ if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0)
+ die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
if (extra)
print_line(extra);
parse_credential_file(fn, c, NULL, print_line);
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 7ac432b881..6e18e623fd 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -342,7 +342,10 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
const char *workdir, *tmp;
int ret = 0, i;
FILE *fp;
- struct hashmap working_tree_dups, submodules, symlinks2;
+ struct hashmap working_tree_dups = HASHMAP_INIT(working_tree_entry_cmp,
+ NULL);
+ struct hashmap submodules = HASHMAP_INIT(pair_cmp, NULL);
+ struct hashmap symlinks2 = HASHMAP_INIT(pair_cmp, NULL);
struct hashmap_iter iter;
struct pair_entry *entry;
struct index_state wtindex;
@@ -383,10 +386,6 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
rdir_len = rdir.len;
wtdir_len = wtdir.len;
- hashmap_init(&working_tree_dups, working_tree_entry_cmp, NULL, 0);
- hashmap_init(&submodules, pair_cmp, NULL, 0);
- hashmap_init(&symlinks2, pair_cmp, NULL, 0);
-
child.no_stdin = 1;
child.git_cmd = 1;
child.use_shell = 0;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f9c3c49f14..ecf8537605 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -393,7 +393,7 @@ static void find_non_local_tags(const struct ref *refs,
item = refname_hash_add(&remote_refs, ref->name, &ref->old_oid);
string_list_insert(&remote_refs_list, ref->name);
}
- hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&existing_refs, struct refname_hash_entry, ent);
/*
* We may have a final lightweight tag that needs to be
@@ -428,7 +428,7 @@ static void find_non_local_tags(const struct ref *refs,
**tail = rm;
*tail = &rm->next;
}
- hashmap_free_entries(&remote_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&remote_refs, struct refname_hash_entry, ent);
string_list_clear(&remote_refs_list, 0);
oidset_clear(&fetch_oids);
}
@@ -573,7 +573,7 @@ static struct ref *get_ref_map(struct remote *remote,
}
}
if (existing_refs_populated)
- hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&existing_refs, struct refname_hash_entry, ent);
return ref_map;
}
diff --git a/builtin/gc.c b/builtin/gc.c
index acfd5b9cf6..592b20fb89 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -534,7 +534,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
const char *name;
pid_t pid;
int daemonized = 0;
- int keep_base_pack = -1;
+ int keep_largest_pack = -1;
timestamp_t dummy;
struct option builtin_gc_options[] = {
@@ -548,7 +548,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
OPT_BOOL_F(0, "force", &force,
N_("force running gc even if there may be another gc running"),
PARSE_OPT_NOCOMPLETE),
- OPT_BOOL(0, "keep-largest-pack", &keep_base_pack,
+ OPT_BOOL(0, "keep-largest-pack", &keep_largest_pack,
N_("repack all other packs except the largest pack")),
OPT_END()
};
@@ -625,8 +625,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
} else {
struct string_list keep_pack = STRING_LIST_INIT_NODUP;
- if (keep_base_pack != -1) {
- if (keep_base_pack)
+ if (keep_largest_pack != -1) {
+ if (keep_largest_pack)
find_base_packs(&keep_pack, 0);
} else if (big_pack_threshold) {
find_base_packs(&keep_pack, big_pack_threshold);
@@ -1253,10 +1253,8 @@ static struct maintenance_task tasks[] = {
static int compare_tasks_by_selection(const void *a_, const void *b_)
{
- const struct maintenance_task *a, *b;
-
- a = (const struct maintenance_task *)&a_;
- b = (const struct maintenance_task *)&b_;
+ const struct maintenance_task *a = a_;
+ const struct maintenance_task *b = b_;
return b->selected_order - a->selected_order;
}
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 0d03cb442d..4b8d86e0ad 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1597,7 +1597,7 @@ static void read_v2_anomalous_offsets(struct packed_git *p,
/* The address of the 4-byte offset table */
idx1 = (((const uint32_t *)((const uint8_t *)p->index_data + p->crc_offset))
- + p->num_objects /* CRC32 table */
+ + (size_t)p->num_objects /* CRC32 table */
);
/* The address of the 8-byte offset table */
diff --git a/builtin/log.c b/builtin/log.c
index 49eb8f6431..08204e3196 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -37,6 +37,7 @@
#define MAIL_DEFAULT_WRAP 72
#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
+#define FORMAT_PATCH_NAME_MAX_DEFAULT 64
/* Set a default date-time format for git log ("log.date" config variable) */
static const char *default_date_mode = NULL;
@@ -50,6 +51,7 @@ static int decoration_style;
static int decoration_given;
static int use_mailmap_config = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
+static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT;
static const char *fmt_pretty;
static const char * const builtin_log_usage[] = {
@@ -150,6 +152,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
rev->abbrev_commit = default_abbrev_commit;
rev->show_root_diff = default_show_root;
rev->subject_prefix = fmt_patch_subject_prefix;
+ rev->patch_name_max = fmt_patch_name_max;
rev->show_signature = default_show_signature;
rev->encode_email_headers = default_encode_email_headers;
rev->diffopt.flags.allow_textconv = 1;
@@ -457,6 +460,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
return git_config_string(&fmt_pretty, var, value);
if (!strcmp(var, "format.subjectprefix"))
return git_config_string(&fmt_patch_subject_prefix, var, value);
+ if (!strcmp(var, "format.filenamemaxlength")) {
+ fmt_patch_name_max = git_config_int(var, value);
+ return 0;
+ }
if (!strcmp(var, "format.encodeemailheaders")) {
default_encode_email_headers = git_config_bool(var, value);
return 0;
@@ -958,15 +965,9 @@ static int open_next_file(struct commit *commit, const char *subject,
struct rev_info *rev, int quiet)
{
struct strbuf filename = STRBUF_INIT;
- int suffix_len = strlen(rev->patch_suffix) + 1;
if (output_directory) {
strbuf_addstr(&filename, output_directory);
- if (filename.len >=
- PATH_MAX - FORMAT_PATCH_NAME_MAX - suffix_len) {
- strbuf_release(&filename);
- return error(_("name of output directory is too long"));
- }
strbuf_complete(&filename, '/');
}
@@ -1754,6 +1755,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
N_("start numbering patches at <n> instead of 1")),
OPT_INTEGER('v', "reroll-count", &reroll_count,
N_("mark the series as Nth re-roll")),
+ OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
+ N_("max length of output filename")),
OPT_CALLBACK_F(0, "rfc", &rev, NULL,
N_("Use [RFC PATCH] instead of [PATCH]"),
PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
@@ -1854,6 +1857,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
PARSE_OPT_KEEP_DASHDASH);
+ /* Make sure "0000-$sub.patch" gives non-negative length for $sub */
+ if (fmt_patch_name_max <= strlen("0000-") + strlen(fmt_patch_suffix))
+ fmt_patch_name_max = strlen("0000-") + strlen(fmt_patch_suffix);
+
if (cover_from_description_arg)
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
@@ -1938,6 +1945,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.zero_commit = zero_commit;
+ rev.patch_name_max = fmt_patch_name_max;
if (!rev.diffopt.flags.text && !no_binary_diff)
rev.diffopt.flags.binary = 1;
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 178e3409b7..3e70f2a4c1 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -236,7 +236,7 @@ static struct pack_list * pack_list_difference(const struct pack_list *A,
static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
{
- unsigned long p1_off = 0, p2_off = 0, p1_step, p2_step;
+ size_t p1_off = 0, p2_off = 0, p1_step, p2_step;
const unsigned char *p1_base, *p2_base;
struct llist_item *p1_hint = NULL, *p2_hint = NULL;
const unsigned int hashsz = the_hash_algo->rawsz;
@@ -280,7 +280,7 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
static size_t sizeof_union(struct packed_git *p1, struct packed_git *p2)
{
size_t ret = 0;
- unsigned long p1_off = 0, p2_off = 0, p1_step, p2_step;
+ size_t p1_off = 0, p2_off = 0, p1_step, p2_step;
const unsigned char *p1_base, *p2_base;
const unsigned int hashsz = the_hash_algo->rawsz;
@@ -499,7 +499,7 @@ static void scan_alt_odb_packs(void)
static struct pack_list * add_pack(struct packed_git *p)
{
struct pack_list l;
- unsigned long off = 0, step;
+ size_t off = 0, step;
const unsigned char *base;
if (!p->pack_local && !(alt_odb || verbose))
diff --git a/builtin/pull.c b/builtin/pull.c
index 17aa63cd35..aa56ebcdd0 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -345,18 +345,18 @@ static enum rebase_type config_get_rebase(void)
return parse_config_rebase("pull.rebase", value, 1);
if (opt_verbosity >= 0 && !opt_ff) {
- warning(_("Pulling without specifying how to reconcile divergent branches is\n"
- "discouraged. You can squelch this message by running one of the following\n"
- "commands sometime before your next pull:\n"
- "\n"
- " git config pull.rebase false # merge (the default strategy)\n"
- " git config pull.rebase true # rebase\n"
- " git config pull.ff only # fast-forward only\n"
- "\n"
- "You can replace \"git config\" with \"git config --global\" to set a default\n"
- "preference for all repositories. You can also pass --rebase, --no-rebase,\n"
- "or --ff-only on the command line to override the configured default per\n"
- "invocation.\n"));
+ advise(_("Pulling without specifying how to reconcile divergent branches is\n"
+ "discouraged. You can squelch this message by running one of the following\n"
+ "commands sometime before your next pull:\n"
+ "\n"
+ " git config pull.rebase false # merge (the default strategy)\n"
+ " git config pull.rebase true # rebase\n"
+ " git config pull.ff only # fast-forward only\n"
+ "\n"
+ "You can replace \"git config\" with \"git config --global\" to set a default\n"
+ "preference for all repositories. You can also pass --rebase, --no-rebase,\n"
+ "or --ff-only on the command line to override the configured default per\n"
+ "invocation.\n"));
}
return REBASE_FALSE;
@@ -852,21 +852,42 @@ static int get_octopus_merge_base(struct object_id *merge_base,
/**
* Given the current HEAD oid, the merge head returned from git-fetch and the
- * fork point calculated by get_rebase_fork_point(), runs git-rebase with the
- * appropriate arguments and returns its exit status.
+ * fork point calculated by get_rebase_fork_point(), compute the <newbase> and
+ * <upstream> arguments to use for the upcoming git-rebase invocation.
*/
-static int run_rebase(const struct object_id *curr_head,
+static int get_rebase_newbase_and_upstream(struct object_id *newbase,
+ struct object_id *upstream,
+ const struct object_id *curr_head,
const struct object_id *merge_head,
const struct object_id *fork_point)
{
- int ret;
struct object_id oct_merge_base;
- struct strvec args = STRVEC_INIT;
if (!get_octopus_merge_base(&oct_merge_base, curr_head, merge_head, fork_point))
if (!is_null_oid(fork_point) && oideq(&oct_merge_base, fork_point))
fork_point = NULL;
+ if (fork_point && !is_null_oid(fork_point))
+ oidcpy(upstream, fork_point);
+ else
+ oidcpy(upstream, merge_head);
+
+ oidcpy(newbase, merge_head);
+
+ return 0;
+}
+
+/**
+ * Given the <newbase> and <upstream> calculated by
+ * get_rebase_newbase_and_upstream(), runs git-rebase with the
+ * appropriate arguments and returns its exit status.
+ */
+static int run_rebase(const struct object_id *newbase,
+ const struct object_id *upstream)
+{
+ int ret;
+ struct strvec args = STRVEC_INIT;
+
strvec_push(&args, "rebase");
/* Shared options */
@@ -894,12 +915,9 @@ static int run_rebase(const struct object_id *curr_head,
warning(_("ignoring --verify-signatures for rebase"));
strvec_push(&args, "--onto");
- strvec_push(&args, oid_to_hex(merge_head));
+ strvec_push(&args, oid_to_hex(newbase));
- if (fork_point && !is_null_oid(fork_point))
- strvec_push(&args, oid_to_hex(fork_point));
- else
- strvec_push(&args, oid_to_hex(merge_head));
+ strvec_push(&args, oid_to_hex(upstream));
ret = run_command_v_opt(args.v, RUN_GIT_CMD);
strvec_clear(&args);
@@ -1011,9 +1029,15 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (opt_rebase) {
int ret = 0;
int ran_ff = 0;
+
+ struct object_id newbase;
+ struct object_id upstream;
+ get_rebase_newbase_and_upstream(&newbase, &upstream, &curr_head,
+ merge_heads.oid, &rebase_fork_point);
+
if ((recurse_submodules == RECURSE_SUBMODULES_ON ||
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) &&
- submodule_touches_in_range(the_repository, &rebase_fork_point, &curr_head))
+ submodule_touches_in_range(the_repository, &upstream, &curr_head))
die(_("cannot rebase with locally recorded submodule modifications"));
if (!autostash) {
struct commit_list *list = NULL;
@@ -1034,7 +1058,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
free_commit_list(list);
}
if (!ran_ff)
- ret = run_rebase(&curr_head, merge_heads.oid, &rebase_fork_point);
+ ret = run_rebase(&newbase, &upstream);
if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON ||
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND))
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index bb9909c52e..f1f0f7bef6 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -977,15 +977,25 @@ static int read_proc_receive_report(struct packet_reader *reader,
int new_report = 0;
int code = 0;
int once = 0;
+ int response = 0;
for (;;) {
struct object_id old_oid, new_oid;
const char *head;
const char *refname;
char *p;
-
- if (packet_reader_read(reader) != PACKET_READ_NORMAL)
+ enum packet_read_status status;
+
+ status = packet_reader_read(reader);
+ if (status != PACKET_READ_NORMAL) {
+ /* Check whether proc-receive exited abnormally */
+ if (status == PACKET_READ_EOF && !response) {
+ strbuf_addstr(errmsg, "proc-receive exited abnormally");
+ return -1;
+ }
break;
+ }
+ response++;
head = reader->line;
p = strchr(head, ' ');
@@ -1145,31 +1155,49 @@ static int run_proc_receive_hook(struct command *commands,
if (use_push_options)
strbuf_addstr(&cap, " push-options");
if (cap.len) {
- packet_write_fmt(proc.in, "version=1%c%s\n", '\0', cap.buf + 1);
+ code = packet_write_fmt_gently(proc.in, "version=1%c%s\n", '\0', cap.buf + 1);
strbuf_release(&cap);
} else {
- packet_write_fmt(proc.in, "version=1\n");
+ code = packet_write_fmt_gently(proc.in, "version=1\n");
}
- packet_flush(proc.in);
+ if (!code)
+ code = packet_flush_gently(proc.in);
- for (;;) {
- int linelen;
+ if (!code)
+ for (;;) {
+ int linelen;
+ enum packet_read_status status;
- if (packet_reader_read(&reader) != PACKET_READ_NORMAL)
- break;
+ status = packet_reader_read(&reader);
+ if (status != PACKET_READ_NORMAL) {
+ /* Check whether proc-receive exited abnormally */
+ if (status == PACKET_READ_EOF)
+ code = -1;
+ break;
+ }
- if (reader.pktlen > 8 && starts_with(reader.line, "version=")) {
- version = atoi(reader.line + 8);
- linelen = strlen(reader.line);
- if (linelen < reader.pktlen) {
- const char *feature_list = reader.line + linelen + 1;
- if (parse_feature_request(feature_list, "push-options"))
- hook_use_push_options = 1;
+ if (reader.pktlen > 8 && starts_with(reader.line, "version=")) {
+ version = atoi(reader.line + 8);
+ linelen = strlen(reader.line);
+ if (linelen < reader.pktlen) {
+ const char *feature_list = reader.line + linelen + 1;
+ if (parse_feature_request(feature_list, "push-options"))
+ hook_use_push_options = 1;
+ }
}
}
+
+ if (code) {
+ strbuf_addstr(&errmsg, "fail to negotiate version with proc-receive hook");
+ goto cleanup;
}
- if (version != 1) {
+ switch (version) {
+ case 0:
+ /* fallthrough */
+ case 1:
+ break;
+ default:
strbuf_addf(&errmsg, "proc-receive version '%d' is not supported",
version);
code = -1;
@@ -1180,20 +1208,36 @@ static int run_proc_receive_hook(struct command *commands,
for (cmd = commands; cmd; cmd = cmd->next) {
if (!cmd->run_proc_receive || cmd->skip_update || cmd->error_string)
continue;
- packet_write_fmt(proc.in, "%s %s %s",
- oid_to_hex(&cmd->old_oid),
- oid_to_hex(&cmd->new_oid),
- cmd->ref_name);
+ code = packet_write_fmt_gently(proc.in, "%s %s %s",
+ oid_to_hex(&cmd->old_oid),
+ oid_to_hex(&cmd->new_oid),
+ cmd->ref_name);
+ if (code)
+ break;
+ }
+ if (!code)
+ code = packet_flush_gently(proc.in);
+ if (code) {
+ strbuf_addstr(&errmsg, "fail to write commands to proc-receive hook");
+ goto cleanup;
}
- packet_flush(proc.in);
/* Send push options */
if (hook_use_push_options) {
struct string_list_item *item;
- for_each_string_list_item(item, push_options)
- packet_write_fmt(proc.in, "%s", item->string);
- packet_flush(proc.in);
+ for_each_string_list_item(item, push_options) {
+ code = packet_write_fmt_gently(proc.in, "%s", item->string);
+ if (code)
+ break;
+ }
+ if (!code)
+ code = packet_flush_gently(proc.in);
+ if (code) {
+ strbuf_addstr(&errmsg,
+ "fail to write push-options to proc-receive hook");
+ goto cleanup;
+ }
}
/* Read result from proc-receive */
diff --git a/builtin/repack.c b/builtin/repack.c
index 01e7767c79..279be11a16 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -202,6 +202,37 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack,
return 0;
}
+static struct {
+ const char *name;
+ unsigned optional:1;
+} exts[] = {
+ {".pack"},
+ {".idx"},
+ {".bitmap", 1},
+ {".promisor", 1},
+};
+
+static unsigned populate_pack_exts(char *name)
+{
+ struct stat statbuf;
+ struct strbuf path = STRBUF_INIT;
+ unsigned ret = 0;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(exts); i++) {
+ strbuf_reset(&path);
+ strbuf_addf(&path, "%s-%s%s", packtmp, name, exts[i].name);
+
+ if (stat(path.buf, &statbuf))
+ continue;
+
+ ret |= (1 << i);
+ }
+
+ strbuf_release(&path);
+ return ret;
+}
+
static void repack_promisor_objects(const struct pack_objects_args *args,
struct string_list *names)
{
@@ -230,11 +261,12 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
out = xfdopen(cmd.out, "r");
while (strbuf_getline_lf(&line, out) != EOF) {
+ struct string_list_item *item;
char *promisor_name;
int fd;
if (line.len != the_hash_algo->hexsz)
die(_("repack: Expecting full hex object ID lines only from pack-objects."));
- string_list_append(names, line.buf);
+ item = string_list_append(names, line.buf);
/*
* pack-objects creates the .pack and .idx files, but not the
@@ -253,6 +285,9 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
if (fd < 0)
die_errno(_("unable to create '%s'"), promisor_name);
close(fd);
+
+ item->util = (void *)(uintptr_t)populate_pack_exts(item->string);
+
free(promisor_name);
}
fclose(out);
@@ -265,22 +300,13 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
int cmd_repack(int argc, const char **argv, const char *prefix)
{
- struct {
- const char *name;
- unsigned optional:1;
- } exts[] = {
- {".pack"},
- {".idx"},
- {".bitmap", 1},
- {".promisor", 1},
- };
struct child_process cmd = CHILD_PROCESS_INIT;
struct string_list_item *item;
struct string_list names = STRING_LIST_INIT_DUP;
struct string_list rollback = STRING_LIST_INIT_NODUP;
struct string_list existing_packs = STRING_LIST_INIT_DUP;
struct strbuf line = STRBUF_INIT;
- int i, ext, ret, failed;
+ int i, ext, ret;
FILE *out;
/* variables to be filled by option parsing */
@@ -429,113 +455,42 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (!names.nr && !po_args.quiet)
printf_ln(_("Nothing new to pack."));
+ for_each_string_list_item(item, &names) {
+ item->util = (void *)(uintptr_t)populate_pack_exts(item->string);
+ }
+
close_object_store(the_repository->objects);
/*
* Ok we have prepared all new packfiles.
- * First see if there are packs of the same name and if so
- * if we can move them out of the way (this can happen if we
- * repacked immediately after packing fully.
*/
- failed = 0;
for_each_string_list_item(item, &names) {
for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
char *fname, *fname_old;
- fname = mkpathdup("%s/pack-%s%s", packdir,
- item->string, exts[ext].name);
- if (!file_exists(fname)) {
- free(fname);
- continue;
- }
-
- fname_old = mkpathdup("%s/old-%s%s", packdir,
- item->string, exts[ext].name);
- if (file_exists(fname_old))
- if (unlink(fname_old))
- failed = 1;
-
- if (!failed && rename(fname, fname_old)) {
- free(fname);
- free(fname_old);
- failed = 1;
- break;
- } else {
- string_list_append(&rollback, fname);
- free(fname_old);
- }
- }
- if (failed)
- break;
- }
- if (failed) {
- struct string_list rollback_failure = STRING_LIST_INIT_DUP;
- for_each_string_list_item(item, &rollback) {
- char *fname, *fname_old;
- fname = mkpathdup("%s/%s", packdir, item->string);
- fname_old = mkpathdup("%s/old-%s", packdir, item->string);
- if (rename(fname_old, fname))
- string_list_append(&rollback_failure, fname);
- free(fname);
- free(fname_old);
- }
-
- if (rollback_failure.nr) {
- int i;
- fprintf(stderr,
- _("WARNING: Some packs in use have been renamed by\n"
- "WARNING: prefixing old- to their name, in order to\n"
- "WARNING: replace them with the new version of the\n"
- "WARNING: file. But the operation failed, and the\n"
- "WARNING: attempt to rename them back to their\n"
- "WARNING: original names also failed.\n"
- "WARNING: Please rename them in %s manually:\n"), packdir);
- for (i = 0; i < rollback_failure.nr; i++)
- fprintf(stderr, "WARNING: old-%s -> %s\n",
- rollback_failure.items[i].string,
- rollback_failure.items[i].string);
- }
- exit(1);
- }
-
- /* Now the ones with the same name are out of the way... */
- for_each_string_list_item(item, &names) {
- for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
- char *fname, *fname_old;
- struct stat statbuffer;
- int exists = 0;
fname = mkpathdup("%s/pack-%s%s",
packdir, item->string, exts[ext].name);
fname_old = mkpathdup("%s-%s%s",
packtmp, item->string, exts[ext].name);
- if (!stat(fname_old, &statbuffer)) {
- statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
- chmod(fname_old, statbuffer.st_mode);
- exists = 1;
- }
- if (exists || !exts[ext].optional) {
+
+ if (((uintptr_t)item->util) & (1 << ext)) {
+ struct stat statbuffer;
+ if (!stat(fname_old, &statbuffer)) {
+ statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
+ chmod(fname_old, statbuffer.st_mode);
+ }
+
if (rename(fname_old, fname))
die_errno(_("renaming '%s' failed"), fname_old);
- }
- free(fname);
- free(fname_old);
- }
- }
+ } else if (!exts[ext].optional)
+ die(_("missing required file: %s"), fname_old);
+ else if (unlink(fname) < 0 && errno != ENOENT)
+ die_errno(_("could not unlink: %s"), fname);
- /* Remove the "old-" files */
- for_each_string_list_item(item, &names) {
- for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
- char *fname;
- fname = mkpathdup("%s/old-%s%s",
- packdir,
- item->string,
- exts[ext].name);
- if (remove_path(fname))
- warning(_("failed to remove '%s'"), fname);
free(fname);
+ free(fname_old);
}
}
-
/* End of pack replacement. */
reprepare_packed_git(the_repository);
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index ed200c8af1..69ba7326cf 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -595,6 +595,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
struct object_context unused;
struct strbuf buf = STRBUF_INIT;
const int hexsz = the_hash_algo->hexsz;
+ int seen_end_of_options = 0;
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
@@ -622,21 +623,29 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
- if (!strcmp(arg, "--local-env-vars")) {
- int i;
- for (i = 0; local_repo_env[i]; i++)
- printf("%s\n", local_repo_env[i]);
+ if (as_is) {
+ if (show_file(arg, output_prefix) && as_is < 2)
+ verify_filename(prefix, arg, 0);
continue;
}
- if (!strcmp(arg, "--resolve-git-dir")) {
- const char *gitdir = argv[++i];
- if (!gitdir)
- die("--resolve-git-dir requires an argument");
- gitdir = resolve_gitdir(gitdir);
- if (!gitdir)
- die("not a gitdir '%s'", argv[i]);
- puts(gitdir);
- continue;
+
+ if (!seen_end_of_options) {
+ if (!strcmp(arg, "--local-env-vars")) {
+ int i;
+ for (i = 0; local_repo_env[i]; i++)
+ printf("%s\n", local_repo_env[i]);
+ continue;
+ }
+ if (!strcmp(arg, "--resolve-git-dir")) {
+ const char *gitdir = argv[++i];
+ if (!gitdir)
+ die("--resolve-git-dir requires an argument");
+ gitdir = resolve_gitdir(gitdir);
+ if (!gitdir)
+ die("not a gitdir '%s'", argv[i]);
+ puts(gitdir);
+ continue;
+ }
}
/* The rest of the options require a git repository. */
@@ -646,41 +655,36 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
did_repo_setup = 1;
}
- if (!strcmp(arg, "--git-path")) {
- if (!argv[i + 1])
- die("--git-path requires an argument");
- strbuf_reset(&buf);
- puts(relative_path(git_path("%s", argv[i + 1]),
- prefix, &buf));
- i++;
- continue;
- }
- if (as_is) {
- if (show_file(arg, output_prefix) && as_is < 2)
- verify_filename(prefix, arg, 0);
- continue;
- }
- if (!strcmp(arg,"-n")) {
- if (++i >= argc)
- die("-n requires an argument");
- if ((filter & DO_FLAGS) && (filter & DO_REVS)) {
- show(arg);
- show(argv[i]);
- }
- continue;
- }
- if (starts_with(arg, "-n")) {
- if ((filter & DO_FLAGS) && (filter & DO_REVS))
- show(arg);
+ if (!strcmp(arg, "--")) {
+ as_is = 2;
+ /* Pass on the "--" if we show anything but files.. */
+ if (filter & (DO_FLAGS | DO_REVS))
+ show_file(arg, 0);
continue;
}
- if (*arg == '-') {
- if (!strcmp(arg, "--")) {
- as_is = 2;
- /* Pass on the "--" if we show anything but files.. */
- if (filter & (DO_FLAGS | DO_REVS))
- show_file(arg, 0);
+ if (!seen_end_of_options && *arg == '-') {
+ if (!strcmp(arg, "--git-path")) {
+ if (!argv[i + 1])
+ die("--git-path requires an argument");
+ strbuf_reset(&buf);
+ puts(relative_path(git_path("%s", argv[i + 1]),
+ prefix, &buf));
+ i++;
+ continue;
+ }
+ if (!strcmp(arg,"-n")) {
+ if (++i >= argc)
+ die("-n requires an argument");
+ if ((filter & DO_FLAGS) && (filter & DO_REVS)) {
+ show(arg);
+ show(argv[i]);
+ }
+ continue;
+ }
+ if (starts_with(arg, "-n")) {
+ if ((filter & DO_FLAGS) && (filter & DO_REVS))
+ show(arg);
continue;
}
if (!strcmp(arg, "--default")) {
@@ -937,6 +941,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
puts(the_hash_algo->name);
continue;
}
+ if (!strcmp(arg, "--end-of-options")) {
+ seen_end_of_options = 1;
+ if (filter & (DO_FLAGS | DO_REVS))
+ show_file(arg, 0);
+ continue;
+ }
if (show_flag(arg) && verify)
die_no_single_rev(quiet);
continue;
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 0a5c4968f6..c52e4ccd19 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -10,6 +10,7 @@
#include "shortlog.h"
#include "parse-options.h"
#include "trailer.h"
+#include "strmap.h"
static char const * const shortlog_usage[] = {
N_("git shortlog [<options>] [<revision-range>] [[--] <path>...]"),
@@ -169,60 +170,6 @@ static void read_from_stdin(struct shortlog *log)
strbuf_release(&oneline);
}
-struct strset_item {
- struct hashmap_entry ent;
- char value[FLEX_ARRAY];
-};
-
-struct strset {
- struct hashmap map;
-};
-
-#define STRSET_INIT { { NULL } }
-
-static int strset_item_hashcmp(const void *hash_data,
- const struct hashmap_entry *entry,
- const struct hashmap_entry *entry_or_key,
- const void *keydata)
-{
- const struct strset_item *a, *b;
-
- a = container_of(entry, const struct strset_item, ent);
- if (keydata)
- return strcmp(a->value, keydata);
-
- b = container_of(entry_or_key, const struct strset_item, ent);
- return strcmp(a->value, b->value);
-}
-
-/*
- * Adds "str" to the set if it was not already present; returns true if it was
- * already there.
- */
-static int strset_check_and_add(struct strset *ss, const char *str)
-{
- unsigned int hash = strhash(str);
- struct strset_item *item;
-
- if (!ss->map.table)
- hashmap_init(&ss->map, strset_item_hashcmp, NULL, 0);
-
- if (hashmap_get_from_hash(&ss->map, hash, str))
- return 1;
-
- FLEX_ALLOC_STR(item, value, str);
- hashmap_entry_init(&item->ent, hash);
- hashmap_add(&ss->map, &item->ent);
- return 0;
-}
-
-static void strset_clear(struct strset *ss)
-{
- if (!ss->map.table)
- return;
- hashmap_free_entries(&ss->map, struct strset_item, ent);
-}
-
static void insert_records_from_trailers(struct shortlog *log,
struct strset *dups,
struct commit *commit,
@@ -253,7 +200,7 @@ static void insert_records_from_trailers(struct shortlog *log,
if (!parse_ident(log, &ident, value))
value = ident.buf;
- if (strset_check_and_add(dups, value))
+ if (!strset_add(dups, value))
continue;
insert_one_record(log, value, oneline);
}
@@ -291,7 +238,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
log->email ? "%aN <%aE>" : "%aN",
&ident, &ctx);
if (!HAS_MULTI_BITS(log->groups) ||
- !strset_check_and_add(&dups, ident.buf))
+ strset_add(&dups, ident.buf))
insert_one_record(log, ident.buf, oneline_str);
}
if (log->groups & SHORTLOG_GROUP_COMMITTER) {
@@ -300,7 +247,7 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
log->email ? "%cN <%cE>" : "%cN",
&ident, &ctx);
if (!HAS_MULTI_BITS(log->groups) ||
- !strset_check_and_add(&dups, ident.buf))
+ strset_add(&dups, ident.buf))
insert_one_record(log, ident.buf, oneline_str);
}
if (log->groups & SHORTLOG_GROUP_TRAILER) {
diff --git a/builtin/stash.c b/builtin/stash.c
index 24ddb1bffa..e1f8235fdd 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -419,7 +419,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
ret = apply_cached(&out);
strbuf_release(&out);
if (ret)
- return error(_("conflicts in index."
+ return error(_("conflicts in index. "
"Try without --index."));
discard_cache();
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 8a2df4459c..6029a80544 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -436,6 +436,8 @@ static void update_refs_stdin(void)
switch (state) {
case UPDATE_REFS_OPEN:
case UPDATE_REFS_STARTED:
+ if (state == UPDATE_REFS_STARTED && cmd->state == UPDATE_REFS_STARTED)
+ die("cannot restart ongoing transaction");
/* Do not downgrade a transaction to a non-transaction. */
if (cmd->state >= state)
state = cmd->state;
@@ -446,7 +448,18 @@ static void update_refs_stdin(void)
state = cmd->state;
break;
case UPDATE_REFS_CLOSED:
- die("transaction is closed");
+ if (cmd->state != UPDATE_REFS_STARTED)
+ die("transaction is closed");
+
+ /*
+ * Open a new transaction if we're currently closed and
+ * get a "start".
+ */
+ state = cmd->state;
+ transaction = ref_transaction_begin(&err);
+ if (!transaction)
+ die("%s", err.buf);
+
break;
}
diff --git a/builtin/worktree.c b/builtin/worktree.c
index ce56fdaaa9..197fd24a55 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -304,9 +304,9 @@ static void check_candidate_path(const char *path,
}
if (locked)
- die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), cmd, path);
+ die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), path, cmd);
else
- die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), cmd, path);
+ die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
}
static int add_worktree(const char *path, const char *refname,
diff --git a/cache.h b/cache.h
index c0072d43b1..e986cf4ea9 100644
--- a/cache.h
+++ b/cache.h
@@ -1960,7 +1960,6 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
void stat_validity_update(struct stat_validity *sv, int fd);
int versioncmp(const char *s1, const char *s2);
-void sleep_millisec(int millisec);
/*
* Create a directory and (if share is nonzero) adjust its permissions
diff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh
index 92a983a265..c70d6cdbf2 100755
--- a/ci/print-test-failures.sh
+++ b/ci/print-test-failures.sh
@@ -48,7 +48,7 @@ do
;;
github-actions)
mkdir -p failed-test-artifacts
- echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
+ echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
continue
diff --git a/command-list.txt b/command-list.txt
index 581499be82..9379b02e5e 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -136,7 +136,6 @@ git-p4 foreignscminterface
git-pack-objects plumbingmanipulators
git-pack-redundant plumbinginterrogators
git-pack-refs ancillarymanipulators
-git-parse-remote synchelpers
git-patch-id purehelpers
git-prune ancillarymanipulators complete
git-prune-packed plumbingmanipulators
diff --git a/config.c b/config.c
index 3b2edc0faf..1137bd73af 100644
--- a/config.c
+++ b/config.c
@@ -1963,7 +1963,7 @@ void git_configset_clear(struct config_set *cs)
free(entry->key);
string_list_clear(&entry->value_list, 1);
}
- hashmap_free_entries(&cs->config_hash, struct config_set_element, ent);
+ hashmap_clear_and_free(&cs->config_hash, struct config_set_element, ent);
cs->hash_initialized = 0;
free(cs->list.items);
cs->list.nr = 0;
diff --git a/config.mak.uname b/config.mak.uname
index c7eba69e54..5b30a9154a 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -541,11 +541,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
# removing the directory at OS releases J06.21 and L17.02.
# Default to the older rm until those two releases are deprecated.
RM = /bin/rm -f
- # As detected by './configure'.
- # Missdetected, hence commented out, see below.
- #NO_CURL = YesPlease
- # Added manually, see above.
- NEEDS_SSL_WITH_CURL = YesPlease
NEEDS_CRYPTO_WITH_SSL = YesPlease
HAVE_DEV_TTY = YesPlease
HAVE_LIBCHARSET_H = YesPlease
@@ -636,7 +631,6 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
prefix =
INSTALL = /bin/install
EXTLIBS += /mingw/lib/libz.a
- NO_R_TO_GCC_LINKER = YesPlease
INTERNAL_QSORT = YesPlease
HAVE_LIBCHARSET_H = YesPlease
NO_GETTEXT = YesPlease
@@ -669,7 +663,6 @@ else
-fstack-protector-strong
EXTLIBS += -lntdll
INSTALL = /bin/install
- NO_R_TO_GCC_LINKER = YesPlease
INTERNAL_QSORT = YesPlease
HAVE_LIBCHARSET_H = YesPlease
NO_GETTEXT =
@@ -695,7 +688,6 @@ ifeq ($(uname_S),QNX)
NO_MKDTEMP = YesPlease
NO_NSEC = YesPlease
NO_PTHREADS = YesPlease
- NO_R_TO_GCC_LINKER = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
endif
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7c81e4ba49..1ed03623cd 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1120,26 +1120,44 @@ __git_pretty_aliases ()
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local word cmdline=$(__git config --get "alias.$1")
- for word in $cmdline; do
- case "$word" in
- \!gitk|gitk)
- echo "gitk"
- return
- ;;
- \!*) : shell command alias ;;
- -*) : option ;;
- *=*) : setting env ;;
- git) : git itself ;;
- \(\)) : skip parens of shell function definition ;;
- {) : skip start of shell helper function ;;
- :) : skip null command ;;
- \'*) : skip opening quote after sh -c ;;
- *)
- echo "$word"
+ local cur=$1 last list word cmdline
+
+ while [[ -n "$cur" ]]; do
+ if [[ "$list" == *" $cur "* ]]; then
+ # loop detected
return
- esac
+ fi
+
+ cmdline=$(__git config --get "alias.$cur")
+ list=" $cur $list"
+ last=$cur
+ cur=
+
+ for word in $cmdline; do
+ case "$word" in
+ \!gitk|gitk)
+ cur="gitk"
+ break
+ ;;
+ \!*) : shell command alias ;;
+ -*) : option ;;
+ *=*) : setting env ;;
+ git) : git itself ;;
+ \(\)) : skip parens of shell function definition ;;
+ {) : skip start of shell helper function ;;
+ :) : skip null command ;;
+ \'*) : skip opening quote after sh -c ;;
+ *)
+ cur="$word"
+ break
+ esac
+ done
done
+
+ cur=$last
+ if [[ "$cur" != "$1" ]]; then
+ echo "$cur"
+ fi
}
# Check whether one of the given words is present on the command line,
diff --git a/csum-file.h b/csum-file.h
index f9cbd317fb..e54d53d1d0 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
hashwrite(f, &data, sizeof(data));
}
+static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
+{
+ data = htonll(data);
+ hashwrite(f, &data, sizeof(data));
+ return sizeof(data);
+}
+
#endif
diff --git a/diff-lib.c b/diff-lib.c
index 082e249fc3..b73cc1859a 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -606,10 +606,12 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
repo_init_revisions(opt->repo, &revs, NULL);
copy_pathspec(&revs.prune_data, &opt->pathspec);
+ diff_setup_done(&revs.diffopt);
revs.diffopt = *opt;
if (diff_cache(&revs, tree_oid, NULL, 1))
exit(128);
+ clear_pathspec(&revs.prune_data);
return 0;
}
diff --git a/diff.c b/diff.c
index d24f47df99..643f4f3f6d 100644
--- a/diff.c
+++ b/diff.c
@@ -4115,6 +4115,9 @@ void diff_free_filespec_blob(struct diff_filespec *s)
void diff_free_filespec_data(struct diff_filespec *s)
{
+ if (!s)
+ return;
+
diff_free_filespec_blob(s);
FREE_AND_NULL(s->cnt_data);
}
@@ -6312,9 +6315,9 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o)
if (o->color_moved == COLOR_MOVED_ZEBRA_DIM)
dim_moved_lines(o);
- hashmap_free_entries(&add_lines, struct moved_entry,
+ hashmap_clear_and_free(&add_lines, struct moved_entry,
ent);
- hashmap_free_entries(&del_lines, struct moved_entry,
+ hashmap_clear_and_free(&del_lines, struct moved_entry,
ent);
}
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 99e63e90f8..d367a6d244 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -407,7 +407,7 @@ static int find_exact_renames(struct diff_options *options)
renames += find_identical_files(&file_table, i, options);
/* Free the hash data structure and entries */
- hashmap_free_entries(&file_table, struct file_similarity, entry);
+ hashmap_clear_and_free(&file_table, struct file_similarity, entry);
return renames;
}
diff --git a/dir.c b/dir.c
index ebea5f1f91..d637461da5 100644
--- a/dir.c
+++ b/dir.c
@@ -817,8 +817,8 @@ static void add_pattern_to_hashsets(struct pattern_list *pl, struct path_pattern
clear_hashmaps:
warning(_("disabling cone pattern matching"));
- hashmap_free_entries(&pl->parent_hashmap, struct pattern_entry, ent);
- hashmap_free_entries(&pl->recursive_hashmap, struct pattern_entry, ent);
+ hashmap_clear_and_free(&pl->parent_hashmap, struct pattern_entry, ent);
+ hashmap_clear_and_free(&pl->recursive_hashmap, struct pattern_entry, ent);
pl->use_cone_patterns = 0;
}
@@ -921,8 +921,8 @@ void clear_pattern_list(struct pattern_list *pl)
free(pl->patterns[i]);
free(pl->patterns);
free(pl->filebuf);
- hashmap_free_entries(&pl->recursive_hashmap, struct pattern_entry, ent);
- hashmap_free_entries(&pl->parent_hashmap, struct pattern_entry, ent);
+ hashmap_clear_and_free(&pl->recursive_hashmap, struct pattern_entry, ent);
+ hashmap_clear_and_free(&pl->parent_hashmap, struct pattern_entry, ent);
memset(pl, 0, sizeof(*pl));
}
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index e713fe3d02..bc3a1e8eff 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -30,9 +30,9 @@ my ($fraginfo_color) =
$diff_use_color ? (
$repo->get_color('color.diff.frag', 'cyan'),
) : ();
-my ($diff_plain_color) =
+my ($diff_context_color) =
$diff_use_color ? (
- $repo->get_color('color.diff.plain', ''),
+ $repo->get_color($repo->config('color.diff.context') ? 'color.diff.context' : 'color.diff.plain', ''),
) : ();
my ($diff_old_color) =
$diff_use_color ? (
@@ -483,10 +483,8 @@ sub list_and_choose {
my $last_lf = 0;
if ($opts->{HEADER}) {
- if (!$opts->{LIST_FLAT}) {
- print " ";
- }
- print colored $header_color, "$opts->{HEADER}\n";
+ my $indent = $opts->{LIST_FLAT} ? "" : " ";
+ print colored $header_color, "$indent$opts->{HEADER}\n";
}
for ($i = 0; $i < @stuff; $i++) {
my $chosen = $chosen[$i] ? '*' : ' ';
@@ -1048,7 +1046,7 @@ sub color_diff {
colored((/^@/ ? $fraginfo_color :
/^\+/ ? $diff_new_color :
/^-/ ? $diff_old_color :
- $diff_plain_color),
+ $diff_context_color),
$_);
} @_;
}
diff --git a/git-compat-util.h b/git-compat-util.h
index adfea06897..7d509c5022 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1354,4 +1354,6 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)
((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
#endif /* !__GNUC__ */
+void sleep_millisec(int millisec);
+
#endif
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 2defef28cd..7225abd811 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -138,6 +138,10 @@ setup_user_tool () {
merge_cmd () {
( eval $merge_tool_cmd )
}
+
+ list_tool_variants () {
+ echo "$tool"
+ }
}
setup_tool () {
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
deleted file mode 100644
index d3c39980f3..0000000000
--- a/git-parse-remote.sh
+++ /dev/null
@@ -1,101 +0,0 @@
-# This is a shell library to calculate the remote repository and
-# upstream branch that should be pulled by "git pull" from the current
-# branch.
-
-# git-ls-remote could be called from outside a git managed repository;
-# this would fail in that case and would issue an error message.
-GIT_DIR=$(git rev-parse -q --git-dir) || :;
-
-get_default_remote () {
- curr_branch=$(git symbolic-ref -q HEAD)
- curr_branch="${curr_branch#refs/heads/}"
- origin=$(git config --get "branch.$curr_branch.remote")
- echo ${origin:-origin}
-}
-
-get_remote_merge_branch () {
- case "$#" in
- 0|1)
- origin="$1"
- default=$(get_default_remote)
- test -z "$origin" && origin=$default
- curr_branch=$(git symbolic-ref -q HEAD) &&
- [ "$origin" = "$default" ] &&
- echo $(git for-each-ref --format='%(upstream)' $curr_branch)
- ;;
- *)
- repo=$1
- shift
- ref=$1
- # FIXME: It should return the tracking branch
- # Currently only works with the default mapping
- case "$ref" in
- +*)
- ref=$(expr "z$ref" : 'z+\(.*\)')
- ;;
- esac
- expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:"
- remote=$(expr "z$ref" : 'z\([^:]*\):')
- case "$remote" in
- '' | HEAD ) remote=HEAD ;;
- heads/*) remote=${remote#heads/} ;;
- refs/heads/*) remote=${remote#refs/heads/} ;;
- refs/* | tags/* | remotes/* ) remote=
- esac
- [ -n "$remote" ] && case "$repo" in
- .)
- echo "refs/heads/$remote"
- ;;
- *)
- echo "refs/remotes/$repo/$remote"
- ;;
- esac
- esac
-}
-
-error_on_missing_default_upstream () {
- cmd="$1"
- op_type="$2"
- op_prep="$3" # FIXME: op_prep is no longer used
- example="$4"
- branch_name=$(git symbolic-ref -q HEAD)
- display_branch_name="${branch_name#refs/heads/}"
- # If there's only one remote, use that in the suggestion
- remote="$(gettext "<remote>")"
- branch="$(gettext "<branch>")"
- if test $(git remote | wc -l) = 1
- then
- remote=$(git remote)
- fi
-
- if test -z "$branch_name"
- then
- gettextln "You are not currently on a branch."
- else
- gettextln "There is no tracking information for the current branch."
- fi
- case "$op_type" in
- rebase)
- gettextln "Please specify which branch you want to rebase against."
- ;;
- merge)
- gettextln "Please specify which branch you want to merge with."
- ;;
- *)
- echo >&2 "BUG: unknown operation type: $op_type"
- exit 1
- ;;
- esac
- eval_gettextln "See git-\${cmd}(1) for details."
- echo
- echo " $example"
- echo
- if test -n "$branch_name"
- then
- gettextln "If you wish to set tracking information for this branch you can do so with:"
- echo
- echo " git branch --set-upstream-to=$remote/$branch $display_branch_name"
- echo
- fi
- exit 1
-}
diff --git a/git-submodule.sh b/git-submodule.sh
index 7ce52872b7..eb90f18229 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -20,7 +20,6 @@ USAGE="[--quiet] [--cached]
OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. git-sh-setup
-. git-parse-remote
require_work_tree
wt_prefix=$(git rev-parse --show-prefix)
cd_to_toplevel
@@ -413,16 +412,18 @@ is_tip_reachable () (
test -z "$rev"
)
+# usage: fetch_in_submodule <module_path> [<depth>] [<sha1>]
+# Because arguments are positional, use an empty string to omit <depth>
+# but include <sha1>.
fetch_in_submodule () (
sanitize_submodule_env &&
cd "$1" &&
- case "$2" in
- '')
- git fetch ;;
- *)
- shift
- git fetch $(get_default_remote) "$@" ;;
- esac
+ if test $# -eq 3
+ then
+ echo "$3" | git fetch --stdin ${2:+"$2"}
+ else
+ git fetch ${2:+"$2"}
+ fi
)
#
@@ -576,7 +577,7 @@ cmd_update()
fetch_in_submodule "$sm_path" $depth ||
die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
fi
- remote_name=$(sanitize_submodule_env; cd "$sm_path" && get_default_remote)
+ remote_name=$(sanitize_submodule_env; cd "$sm_path" && git submodule--helper print-default-remote)
sha1=$(sanitize_submodule_env; cd "$sm_path" &&
git rev-parse --verify "${remote_name}/${branch}") ||
die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
@@ -602,7 +603,7 @@ cmd_update()
# Now we tried the usual fetch, but $sha1 may
# not be reachable from any of the refs
is_tip_reachable "$sm_path" "$sha1" ||
- fetch_in_submodule "$sm_path" $depth "$sha1" ||
+ fetch_in_submodule "$sm_path" "$depth" "$sha1" ||
die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain \$sha1. Direct fetching of that commit failed.")"
fi
diff --git a/hashmap.c b/hashmap.c
index 09813e1a46..5009471800 100644
--- a/hashmap.c
+++ b/hashmap.c
@@ -92,8 +92,9 @@ static void alloc_table(struct hashmap *map, unsigned int size)
}
static inline int entry_equals(const struct hashmap *map,
- const struct hashmap_entry *e1, const struct hashmap_entry *e2,
- const void *keydata)
+ const struct hashmap_entry *e1,
+ const struct hashmap_entry *e2,
+ const void *keydata)
{
return (e1 == e2) ||
(e1->hash == e2->hash &&
@@ -101,7 +102,7 @@ static inline int entry_equals(const struct hashmap *map,
}
static inline unsigned int bucket(const struct hashmap *map,
- const struct hashmap_entry *key)
+ const struct hashmap_entry *key)
{
return key->hash & (map->tablesize - 1);
}
@@ -113,6 +114,7 @@ int hashmap_bucket(const struct hashmap *map, unsigned int hash)
static void rehash(struct hashmap *map, unsigned int newsize)
{
+ /* map->table MUST NOT be NULL when this function is called */
unsigned int i, oldsize = map->tablesize;
struct hashmap_entry **oldtable = map->table;
@@ -133,6 +135,7 @@ static void rehash(struct hashmap *map, unsigned int newsize)
static inline struct hashmap_entry **find_entry_ptr(const struct hashmap *map,
const struct hashmap_entry *key, const void *keydata)
{
+ /* map->table MUST NOT be NULL when this function is called */
struct hashmap_entry **e = &map->table[bucket(map, key)];
while (*e && !entry_equals(map, *e, key, keydata))
e = &(*e)->next;
@@ -148,7 +151,7 @@ static int always_equal(const void *unused_cmp_data,
}
void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
- const void *cmpfn_data, size_t initial_size)
+ const void *cmpfn_data, size_t initial_size)
{
unsigned int size = HASHMAP_INITIAL_SIZE;
@@ -171,22 +174,37 @@ void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
map->do_count_items = 1;
}
-void hashmap_free_(struct hashmap *map, ssize_t entry_offset)
+static void free_individual_entries(struct hashmap *map, ssize_t entry_offset)
+{
+ struct hashmap_iter iter;
+ struct hashmap_entry *e;
+
+ hashmap_iter_init(map, &iter);
+ while ((e = hashmap_iter_next(&iter)))
+ /*
+ * like container_of, but using caller-calculated
+ * offset (caller being hashmap_clear_and_free)
+ */
+ free((char *)e - entry_offset);
+}
+
+void hashmap_partial_clear_(struct hashmap *map, ssize_t entry_offset)
{
if (!map || !map->table)
return;
- if (entry_offset >= 0) { /* called by hashmap_free_entries */
- struct hashmap_iter iter;
- struct hashmap_entry *e;
-
- hashmap_iter_init(map, &iter);
- while ((e = hashmap_iter_next(&iter)))
- /*
- * like container_of, but using caller-calculated
- * offset (caller being hashmap_free_entries)
- */
- free((char *)e - entry_offset);
- }
+ if (entry_offset >= 0) /* called by hashmap_clear_entries */
+ free_individual_entries(map, entry_offset);
+ memset(map->table, 0, map->tablesize * sizeof(struct hashmap_entry *));
+ map->shrink_at = 0;
+ map->private_size = 0;
+}
+
+void hashmap_clear_(struct hashmap *map, ssize_t entry_offset)
+{
+ if (!map || !map->table)
+ return;
+ if (entry_offset >= 0) /* called by hashmap_clear_and_free */
+ free_individual_entries(map, entry_offset);
free(map->table);
memset(map, 0, sizeof(*map));
}
@@ -195,11 +213,13 @@ struct hashmap_entry *hashmap_get(const struct hashmap *map,
const struct hashmap_entry *key,
const void *keydata)
{
+ if (!map->table)
+ return NULL;
return *find_entry_ptr(map, key, keydata);
}
struct hashmap_entry *hashmap_get_next(const struct hashmap *map,
- const struct hashmap_entry *entry)
+ const struct hashmap_entry *entry)
{
struct hashmap_entry *e = entry->next;
for (; e; e = e->next)
@@ -210,8 +230,12 @@ struct hashmap_entry *hashmap_get_next(const struct hashmap *map,
void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
{
- unsigned int b = bucket(map, entry);
+ unsigned int b;
+
+ if (!map->table)
+ alloc_table(map, HASHMAP_INITIAL_SIZE);
+ b = bucket(map, entry);
/* add entry */
entry->next = map->table[b];
map->table[b] = entry;
@@ -225,11 +249,15 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
}
struct hashmap_entry *hashmap_remove(struct hashmap *map,
- const struct hashmap_entry *key,
- const void *keydata)
+ const struct hashmap_entry *key,
+ const void *keydata)
{
struct hashmap_entry *old;
- struct hashmap_entry **e = find_entry_ptr(map, key, keydata);
+ struct hashmap_entry **e;
+
+ if (!map->table)
+ return NULL;
+ e = find_entry_ptr(map, key, keydata);
if (!*e)
return NULL;
@@ -249,7 +277,7 @@ struct hashmap_entry *hashmap_remove(struct hashmap *map,
}
struct hashmap_entry *hashmap_put(struct hashmap *map,
- struct hashmap_entry *entry)
+ struct hashmap_entry *entry)
{
struct hashmap_entry *old = hashmap_remove(map, entry, NULL);
hashmap_add(map, entry);
diff --git a/hashmap.h b/hashmap.h
index b011b394fe..7251687d73 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -96,7 +96,7 @@
* }
*
* if (!strcmp("end", action)) {
- * hashmap_free_entries(&map, struct long2string, ent);
+ * hashmap_clear_and_free(&map, struct long2string, ent);
* break;
* }
* }
@@ -210,6 +210,9 @@ struct hashmap {
/* hashmap functions */
+#define HASHMAP_INIT(fn, data) { .cmpfn = fn, .cmpfn_data = data, \
+ .do_count_items = 1 }
+
/*
* Initializes a hashmap structure.
*
@@ -228,24 +231,72 @@ struct hashmap {
* prevent expensive resizing. If 0, the table is dynamically resized.
*/
void hashmap_init(struct hashmap *map,
- hashmap_cmp_fn equals_function,
- const void *equals_function_data,
- size_t initial_size);
+ hashmap_cmp_fn equals_function,
+ const void *equals_function_data,
+ size_t initial_size);
-/* internal function for freeing hashmap */
-void hashmap_free_(struct hashmap *map, ssize_t offset);
+/* internal functions for clearing or freeing hashmap */
+void hashmap_partial_clear_(struct hashmap *map, ssize_t offset);
+void hashmap_clear_(struct hashmap *map, ssize_t offset);
/*
- * Frees a hashmap structure and allocated memory, leaves entries undisturbed
+ * Frees a hashmap structure and allocated memory for the table, but does not
+ * free the entries nor anything they point to.
+ *
+ * Usage note:
+ *
+ * Many callers will need to iterate over all entries and free the data each
+ * entry points to; in such a case, they can free the entry itself while at it.
+ * Thus, you might see:
+ *
+ * hashmap_for_each_entry(map, hashmap_iter, e, hashmap_entry_name) {
+ * free(e->somefield);
+ * free(e);
+ * }
+ * hashmap_clear(map);
+ *
+ * instead of
+ *
+ * hashmap_for_each_entry(map, hashmap_iter, e, hashmap_entry_name) {
+ * free(e->somefield);
+ * }
+ * hashmap_clear_and_free(map, struct my_entry_struct, hashmap_entry_name);
+ *
+ * to avoid the implicit extra loop over the entries. However, if there are
+ * no special fields in your entry that need to be freed beyond the entry
+ * itself, it is probably simpler to avoid the explicit loop and just call
+ * hashmap_clear_and_free().
*/
-#define hashmap_free(map) hashmap_free_(map, -1)
+#define hashmap_clear(map) hashmap_clear_(map, -1)
/*
- * Frees @map and all entries. @type is the struct type of the entry
- * where @member is the hashmap_entry struct used to associate with @map
+ * Similar to hashmap_clear(), except that the table is no deallocated; it
+ * is merely zeroed out but left the same size as before. If the hashmap
+ * will be reused, this avoids the overhead of deallocating and
+ * reallocating map->table. As with hashmap_clear(), you may need to free
+ * the entries yourself before calling this function.
+ */
+#define hashmap_partial_clear(map) hashmap_partial_clear_(map, -1)
+
+/*
+ * Similar to hashmap_clear() but also frees all entries. @type is the
+ * struct type of the entry where @member is the hashmap_entry struct used
+ * to associate with @map.
+ *
+ * See usage note above hashmap_clear().
+ */
+#define hashmap_clear_and_free(map, type, member) \
+ hashmap_clear_(map, offsetof(type, member))
+
+/*
+ * Similar to hashmap_partial_clear() but also frees all entries. @type is
+ * the struct type of the entry where @member is the hashmap_entry struct
+ * used to associate with @map.
+ *
+ * See usage note above hashmap_clear().
*/
-#define hashmap_free_entries(map, type, member) \
- hashmap_free_(map, offsetof(type, member));
+#define hashmap_partial_clear_and_free(map, type, member) \
+ hashmap_partial_clear_(map, offsetof(type, member))
/* hashmap_entry functions */
@@ -261,7 +312,7 @@ void hashmap_free_(struct hashmap *map, ssize_t offset);
* and if it is on stack, you can just let it go out of scope).
*/
static inline void hashmap_entry_init(struct hashmap_entry *e,
- unsigned int hash)
+ unsigned int hash)
{
e->hash = hash;
e->next = NULL;
@@ -303,8 +354,8 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)
* to `hashmap_cmp_fn` to decide whether the entry matches the key.
*/
struct hashmap_entry *hashmap_get(const struct hashmap *map,
- const struct hashmap_entry *key,
- const void *keydata);
+ const struct hashmap_entry *key,
+ const void *keydata);
/*
* Returns the hashmap entry for the specified hash code and key data,
@@ -337,7 +388,7 @@ static inline struct hashmap_entry *hashmap_get_from_hash(
* call to `hashmap_get` or `hashmap_get_next`.
*/
struct hashmap_entry *hashmap_get_next(const struct hashmap *map,
- const struct hashmap_entry *entry);
+ const struct hashmap_entry *entry);
/*
* Adds a hashmap entry. This allows to add duplicate entries (i.e.
@@ -357,7 +408,7 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry);
* Returns the replaced entry, or NULL if not found (i.e. the entry was added).
*/
struct hashmap_entry *hashmap_put(struct hashmap *map,
- struct hashmap_entry *entry);
+ struct hashmap_entry *entry);
/*
* Adds or replaces a hashmap entry contained within @keyvar,
@@ -379,8 +430,8 @@ struct hashmap_entry *hashmap_put(struct hashmap *map,
* Argument explanation is the same as in `hashmap_get`.
*/
struct hashmap_entry *hashmap_remove(struct hashmap *map,
- const struct hashmap_entry *key,
- const void *keydata);
+ const struct hashmap_entry *key,
+ const void *keydata);
/*
* Removes a hashmap entry contained within @keyvar,
@@ -422,7 +473,7 @@ struct hashmap_entry *hashmap_iter_next(struct hashmap_iter *iter);
/* Initializes the iterator and returns the first entry, if any. */
static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,
- struct hashmap_iter *iter)
+ struct hashmap_iter *iter)
{
hashmap_iter_init(map, iter);
return hashmap_iter_next(iter);
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index defd3dfd10..d2d1c81caf 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -35,7 +35,7 @@ const char *list_object_filter_config_name(enum list_objects_filter_choice c)
/* not a real filter type; just the count of all filters */
break;
}
- BUG("list_object_filter_choice_name: invalid argument '%d'", c);
+ BUG("list_object_filter_config_name: invalid argument '%d'", c);
}
/*
diff --git a/log-tree.c b/log-tree.c
index 1927f917ce..fd0dde97ec 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -367,7 +367,7 @@ void fmt_output_subject(struct strbuf *filename,
const char *suffix = info->patch_suffix;
int nr = info->nr;
int start_len = filename->len;
- int max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);
+ int max_len = start_len + info->patch_name_max - (strlen(suffix) + 1);
if (0 < info->reroll_count)
strbuf_addf(filename, "v%d-", info->reroll_count);
diff --git a/log-tree.h b/log-tree.h
index 8fa79289ec..1e8c91dbf2 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -33,7 +33,6 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
int maybe_multipart);
void load_ref_decorations(struct decoration_filter *filter, int flags);
-#define FORMAT_PATCH_NAME_MAX 64
void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *);
void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);
void fmt_output_email_subject(struct strbuf *, struct rev_info *);
diff --git a/merge-recursive.c b/merge-recursive.c
index d0214335a7..f736a0f632 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2651,7 +2651,7 @@ static struct string_list *get_renames(struct merge_options *opt,
free(e->target_file);
string_list_clear(&e->source_files, 0);
}
- hashmap_free_entries(&collisions, struct collision_entry, ent);
+ hashmap_clear_and_free(&collisions, struct collision_entry, ent);
return renames;
}
@@ -2870,7 +2870,7 @@ static void initial_cleanup_rename(struct diff_queue_struct *pairs,
strbuf_release(&e->new_dir);
/* possible_new_dirs already cleared in get_directory_renames */
}
- hashmap_free_entries(dir_renames, struct dir_rename_entry, ent);
+ hashmap_clear_and_free(dir_renames, struct dir_rename_entry, ent);
free(dir_renames);
free(pairs->queue);
@@ -3497,7 +3497,7 @@ static int merge_trees_internal(struct merge_options *opt,
string_list_clear(entries, 1);
free(entries);
- hashmap_free_entries(&opt->priv->current_file_dir_set,
+ hashmap_clear_and_free(&opt->priv->current_file_dir_set,
struct path_hashmap_entry, e);
if (clean < 0) {
diff --git a/mergetools/bc b/mergetools/bc
index a89086ee72..26c19d46a5 100644
--- a/mergetools/bc
+++ b/mergetools/bc
@@ -25,4 +25,5 @@ translate_merge_tool_path() {
list_tool_variants () {
echo bc
echo bc3
+ echo bc4
}
diff --git a/midx.c b/midx.c
index d233b54ac7..79c282b070 100644
--- a/midx.c
+++ b/midx.c
@@ -298,7 +298,7 @@ static int nth_midxed_pack_entry(struct repository *r,
pack_int_id = nth_midxed_pack_int_id(m, pos);
if (prepare_midx_pack(r, m, pack_int_id))
- die(_("error preparing packfile from multi-pack-index"));
+ return 0;
p = m->packs[pack_int_id];
/*
@@ -785,9 +785,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off
if (!(offset >> 31))
continue;
- hashwrite_be32(f, offset >> 32);
- hashwrite_be32(f, offset & 0xffffffffUL);
- written += 2 * sizeof(uint32_t);
+ written += hashwrite_be64(f, offset);
nr_large_offset--;
}
@@ -975,8 +973,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
chunk_offsets[i]);
hashwrite_be32(f, chunk_ids[i]);
- hashwrite_be32(f, chunk_offsets[i] >> 32);
- hashwrite_be32(f, chunk_offsets[i]);
+ hashwrite_be64(f, chunk_offsets[i]);
written += MIDX_CHUNKLOOKUP_WIDTH;
}
diff --git a/name-hash.c b/name-hash.c
index fb526a3775..5d3c7b12c1 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -726,6 +726,6 @@ void free_name_hash(struct index_state *istate)
return;
istate->name_hash_initialized = 0;
- hashmap_free(&istate->name_hash);
- hashmap_free_entries(&istate->dir_hash, struct dir_entry, ent);
+ hashmap_clear(&istate->name_hash);
+ hashmap_clear_and_free(&istate->dir_hash, struct dir_entry, ent);
}
diff --git a/notes.c b/notes.c
index 564baac64d..d5ac081e76 100644
--- a/notes.c
+++ b/notes.c
@@ -970,7 +970,7 @@ static int notes_display_config(const char *k, const char *v, void *cb)
if (*load_refs && !strcmp(k, "notes.displayref")) {
if (!v)
- config_error_nonbool(k);
+ return config_error_nonbool(k);
string_list_add_refs_by_glob(&display_notes_refs, v);
}
diff --git a/object.c b/object.c
index 05544bc92b..68f80b0b3d 100644
--- a/object.c
+++ b/object.c
@@ -532,7 +532,7 @@ void raw_object_store_clear(struct raw_object_store *o)
close_object_store(o);
o->packed_git = NULL;
- hashmap_free(&o->pack_map);
+ hashmap_clear(&o->pack_map);
}
void parsed_object_pool_clear(struct parsed_object_pool *o)
diff --git a/oidmap.c b/oidmap.c
index 423aa014a3..286a04a53c 100644
--- a/oidmap.c
+++ b/oidmap.c
@@ -27,7 +27,7 @@ void oidmap_free(struct oidmap *map, int free_entries)
return;
/* TODO: make oidmap itself not depend on struct layouts */
- hashmap_free_(&map->map, free_entries ? 0 : -1);
+ hashmap_clear_(&map->map, free_entries ? 0 : -1);
}
void *oidmap_get(const struct oidmap *map, const struct object_id *key)
diff --git a/pack-check.c b/pack-check.c
index dad6d8ae7f..4b089fe8ec 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -39,7 +39,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
} while (len);
index_crc = p->index_data;
- index_crc += 2 + 256 + p->num_objects * (the_hash_algo->rawsz/4) + nr;
+ index_crc += 2 + 256 + (size_t)p->num_objects * (the_hash_algo->rawsz/4) + nr;
return data_crc != ntohl(*index_crc);
}
@@ -164,7 +164,7 @@ static int verify_packfile(struct repository *r,
int verify_pack_index(struct packed_git *p)
{
- off_t index_size;
+ size_t len;
const unsigned char *index_base;
git_hash_ctx ctx;
unsigned char hash[GIT_MAX_RAWSZ];
@@ -172,14 +172,14 @@ int verify_pack_index(struct packed_git *p)
if (open_pack_index(p))
return error("packfile %s index not opened", p->pack_name);
- index_size = p->index_size;
index_base = p->index_data;
+ len = p->index_size - the_hash_algo->rawsz;
/* Verify SHA1 sum of the index file */
the_hash_algo->init_fn(&ctx);
- the_hash_algo->update_fn(&ctx, index_base, (unsigned int)(index_size - the_hash_algo->rawsz));
+ the_hash_algo->update_fn(&ctx, index_base, len);
the_hash_algo->final_fn(hash, &ctx);
- if (!hasheq(hash, index_base + index_size - the_hash_algo->rawsz))
+ if (!hasheq(hash, index_base + len))
err = error("Packfile index for %s hash mismatch",
p->pack_name);
return err;
diff --git a/pack-revindex.c b/pack-revindex.c
index d28a7e43d0..ecdde39cf4 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -130,7 +130,7 @@ static void create_pack_revindex(struct packed_git *p)
if (p->index_version > 1) {
const uint32_t *off_32 =
- (uint32_t *)(index + 8 + p->num_objects * (hashsz + 4));
+ (uint32_t *)(index + 8 + (size_t)p->num_objects * (hashsz + 4));
const uint32_t *off_64 = off_32 + p->num_objects;
for (i = 0; i < num_ent; i++) {
const uint32_t off = ntohl(*off_32++);
diff --git a/pack-write.c b/pack-write.c
index 23e19cc1ec..3513665e1e 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -151,13 +151,10 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
while (nr_large_offset) {
struct pack_idx_entry *obj = *list++;
uint64_t offset = obj->offset;
- uint32_t split[2];
if (!need_large_offset(offset, opts))
continue;
- split[0] = htonl(offset >> 32);
- split[1] = htonl(offset & 0xffffffff);
- hashwrite(f, split, 8);
+ hashwrite_be64(f, offset);
nr_large_offset--;
}
}
diff --git a/packfile.c b/packfile.c
index 0929ebe4fc..86f5c8dbf6 100644
--- a/packfile.c
+++ b/packfile.c
@@ -148,7 +148,7 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
* - hash of the packfile
* - file checksum
*/
- if (idx_size != 4 * 256 + nr * (hashsz + 4) + hashsz + hashsz)
+ if (idx_size != st_add(4 * 256 + hashsz + hashsz, st_mult(nr, hashsz + 4)))
return error("wrong index v1 file size in %s", path);
} else if (version == 2) {
/*
@@ -164,10 +164,10 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
* variable sized table containing 8-byte entries
* for offsets larger than 2^31.
*/
- unsigned long min_size = 8 + 4*256 + nr*(hashsz + 4 + 4) + hashsz + hashsz;
- unsigned long max_size = min_size;
+ size_t min_size = st_add(8 + 4*256 + hashsz + hashsz, st_mult(nr, hashsz + 4 + 4));
+ size_t max_size = min_size;
if (nr)
- max_size += (nr - 1)*8;
+ max_size = st_add(max_size, st_mult(nr - 1, 8));
if (idx_size < min_size || idx_size > max_size)
return error("wrong index v2 file size in %s", path);
if (idx_size != min_size &&
@@ -514,19 +514,8 @@ static int open_packed_git_1(struct packed_git *p)
ssize_t read_result;
const unsigned hashsz = the_hash_algo->rawsz;
- if (!p->index_data) {
- struct multi_pack_index *m;
- const char *pack_name = pack_basename(p);
-
- for (m = the_repository->objects->multi_pack_index;
- m; m = m->next) {
- if (midx_contains_pack(m, pack_name))
- break;
- }
-
- if (!m && open_pack_index(p))
- return error("packfile %s index unavailable", p->pack_name);
- }
+ if (open_pack_index(p))
+ return error("packfile %s index unavailable", p->pack_name);
if (!pack_max_fds) {
unsigned int max_fds = get_max_fd_limit();
@@ -567,10 +556,6 @@ static int open_packed_git_1(struct packed_git *p)
" supported (try upgrading GIT to a newer version)",
p->pack_name, ntohl(hdr.hdr_version));
- /* Skip index checking if in multi-pack-index */
- if (!p->index_data)
- return 0;
-
/* Verify the pack matches its index. */
if (p->num_objects != ntohl(hdr.hdr_entries))
return error("packfile %s claims to have %"PRIu32" objects"
@@ -1933,14 +1918,14 @@ off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
const unsigned int hashsz = the_hash_algo->rawsz;
index += 4 * 256;
if (p->index_version == 1) {
- return ntohl(*((uint32_t *)(index + (hashsz + 4) * n)));
+ return ntohl(*((uint32_t *)(index + (hashsz + 4) * (size_t)n)));
} else {
uint32_t off;
- index += 8 + p->num_objects * (hashsz + 4);
+ index += 8 + (size_t)p->num_objects * (hashsz + 4);
off = ntohl(*((uint32_t *)(index + 4 * n)));
if (!(off & 0x80000000))
return off;
- index += p->num_objects * 4 + (off & 0x7fffffff) * 8;
+ index += (size_t)p->num_objects * 4 + (off & 0x7fffffff) * 8;
check_pack_index_ptr(p, index);
return get_be64(index);
}
diff --git a/patch-ids.c b/patch-ids.c
index 12aa6d494b..21973e4933 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -71,7 +71,7 @@ int init_patch_ids(struct repository *r, struct patch_ids *ids)
int free_patch_ids(struct patch_ids *ids)
{
- hashmap_free_entries(&ids->patches, struct patch_id, ent);
+ hashmap_clear_and_free(&ids->patches, struct patch_id, ent);
return 0;
}
diff --git a/range-diff.c b/range-diff.c
index 24dc435e48..b9950f10c8 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -232,11 +232,9 @@ static int patch_util_cmp(const void *dummy, const struct patch_util *a,
static void find_exact_matches(struct string_list *a, struct string_list *b)
{
- struct hashmap map;
+ struct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);
int i;
- hashmap_init(&map, (hashmap_cmp_fn)patch_util_cmp, NULL, 0);
-
/* First, add the patches of a to a hash map */
for (i = 0; i < a->nr; i++) {
struct patch_util *util = a->items[i].util;
@@ -266,7 +264,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
}
}
- hashmap_free(&map);
+ hashmap_clear(&map);
}
static void diffsize_consume(void *data, char *line, unsigned long len)
diff --git a/ref-filter.c b/ref-filter.c
index 6476686fea..aa260bfd09 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2230,7 +2230,7 @@ void ref_array_clear(struct ref_array *array)
used_atom_cnt = 0;
if (ref_to_worktree_map.worktrees) {
- hashmap_free_entries(&(ref_to_worktree_map.map),
+ hashmap_clear_and_free(&(ref_to_worktree_map.map),
struct ref_to_worktree_entry, ent);
free_worktrees(ref_to_worktree_map.worktrees);
ref_to_worktree_map.worktrees = NULL;
diff --git a/revision.c b/revision.c
index aa62212040..c6e169e3eb 100644
--- a/revision.c
+++ b/revision.c
@@ -124,11 +124,6 @@ static int path_and_oids_cmp(const void *hashmap_cmp_fn_data,
return strcmp(e1->path, e2->path);
}
-static void paths_and_oids_init(struct hashmap *map)
-{
- hashmap_init(map, path_and_oids_cmp, NULL, 0);
-}
-
static void paths_and_oids_clear(struct hashmap *map)
{
struct hashmap_iter iter;
@@ -139,7 +134,7 @@ static void paths_and_oids_clear(struct hashmap *map)
free(entry->path);
}
- hashmap_free_entries(map, struct path_and_oids_entry, ent);
+ hashmap_clear_and_free(map, struct path_and_oids_entry, ent);
}
static void paths_and_oids_insert(struct hashmap *map,
@@ -213,7 +208,7 @@ void mark_trees_uninteresting_sparse(struct repository *r,
struct oidset *trees)
{
unsigned has_interesting = 0, has_uninteresting = 0;
- struct hashmap map;
+ struct hashmap map = HASHMAP_INIT(path_and_oids_cmp, NULL);
struct hashmap_iter map_iter;
struct path_and_oids_entry *entry;
struct object_id *oid;
@@ -237,8 +232,6 @@ void mark_trees_uninteresting_sparse(struct repository *r,
if (!has_uninteresting || !has_interesting)
return;
- paths_and_oids_init(&map);
-
oidset_iter_init(trees, &iter);
while ((oid = oidset_iter_next(&iter))) {
struct tree *tree = lookup_tree(r, oid);
diff --git a/revision.h b/revision.h
index f6bf860d19..086ff10280 100644
--- a/revision.h
+++ b/revision.h
@@ -238,6 +238,7 @@ struct rev_info {
const char *extra_headers;
const char *log_reencode;
const char *subject_prefix;
+ int patch_name_max;
int no_inline;
int show_log_size;
struct string_list *mailmap;
diff --git a/send-pack.c b/send-pack.c
index eb4a44270b..d2701bf35c 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -85,6 +85,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
po.in = -1;
po.out = args->stateless_rpc ? -1 : fd;
po.git_cmd = 1;
+ po.clean_on_exit = 1;
if (start_command(&po))
die_errno("git pack-objects failed");
diff --git a/sequencer.c b/sequencer.c
index 221e98721d..8909a46770 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5085,7 +5085,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
oidmap_free(&commit2todo, 1);
oidmap_free(&state.commit2label, 1);
- hashmap_free_entries(&state.labels, struct labels_entry, entry);
+ hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
strbuf_release(&state.buf);
return 0;
@@ -5601,7 +5601,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
for (i = 0; i < todo_list->nr; i++)
free(subjects[i]);
free(subjects);
- hashmap_free_entries(&subject2item, struct subject2item_entry, entry);
+ hashmap_clear_and_free(&subject2item, struct subject2item_entry, entry);
clear_commit_todo_item(&commit_todo);
diff --git a/strmap.c b/strmap.c
new file mode 100644
index 0000000000..4fb9f6100e
--- /dev/null
+++ b/strmap.c
@@ -0,0 +1,178 @@
+#include "git-compat-util.h"
+#include "strmap.h"
+#include "mem-pool.h"
+
+int cmp_strmap_entry(const void *hashmap_cmp_fn_data,
+ const struct hashmap_entry *entry1,
+ const struct hashmap_entry *entry2,
+ const void *keydata)
+{
+ const struct strmap_entry *e1, *e2;
+
+ e1 = container_of(entry1, const struct strmap_entry, ent);
+ e2 = container_of(entry2, const struct strmap_entry, ent);
+ return strcmp(e1->key, e2->key);
+}
+
+static struct strmap_entry *find_strmap_entry(struct strmap *map,
+ const char *str)
+{
+ struct strmap_entry entry;
+ hashmap_entry_init(&entry.ent, strhash(str));
+ entry.key = str;
+ return hashmap_get_entry(&map->map, &entry, ent, NULL);
+}
+
+void strmap_init(struct strmap *map)
+{
+ strmap_init_with_options(map, NULL, 1);
+}
+
+void strmap_init_with_options(struct strmap *map,
+ struct mem_pool *pool,
+ int strdup_strings)
+{
+ hashmap_init(&map->map, cmp_strmap_entry, NULL, 0);
+ map->pool = pool;
+ map->strdup_strings = strdup_strings;
+}
+
+static void strmap_free_entries_(struct strmap *map, int free_values)
+{
+ struct hashmap_iter iter;
+ struct strmap_entry *e;
+
+ if (!map)
+ return;
+
+ if (!free_values && map->pool)
+ /* Memory other than util is owned by and freed with the pool */
+ return;
+
+ /*
+ * We need to iterate over the hashmap entries and free
+ * e->key and e->value ourselves; hashmap has no API to
+ * take care of that for us. Since we're already iterating over
+ * the hashmap, though, might as well free e too and avoid the need
+ * to make some call into the hashmap API to do that.
+ */
+ hashmap_for_each_entry(&map->map, &iter, e, ent) {
+ if (free_values)
+ free(e->value);
+ if (!map->pool)
+ free(e);
+ }
+}
+
+void strmap_clear(struct strmap *map, int free_values)
+{
+ strmap_free_entries_(map, free_values);
+ hashmap_clear(&map->map);
+}
+
+void strmap_partial_clear(struct strmap *map, int free_values)
+{
+ strmap_free_entries_(map, free_values);
+ hashmap_partial_clear(&map->map);
+}
+
+static struct strmap_entry *create_entry(struct strmap *map,
+ const char *str,
+ void *data)
+{
+ struct strmap_entry *entry;
+
+ if (map->strdup_strings) {
+ if (!map->pool) {
+ FLEXPTR_ALLOC_STR(entry, key, str);
+ } else {
+ size_t len = st_add(strlen(str), 1); /* include NUL */
+ entry = mem_pool_alloc(map->pool,
+ st_add(sizeof(*entry), len));
+ memcpy(entry + 1, str, len);
+ entry->key = (void *)(entry + 1);
+ }
+ } else if (!map->pool) {
+ entry = xmalloc(sizeof(*entry));
+ } else {
+ entry = mem_pool_alloc(map->pool, sizeof(*entry));
+ }
+ hashmap_entry_init(&entry->ent, strhash(str));
+ if (!map->strdup_strings)
+ entry->key = str;
+ entry->value = data;
+ return entry;
+}
+
+void *strmap_put(struct strmap *map, const char *str, void *data)
+{
+ struct strmap_entry *entry = find_strmap_entry(map, str);
+
+ if (entry) {
+ void *old = entry->value;
+ entry->value = data;
+ return old;
+ }
+
+ entry = create_entry(map, str, data);
+ hashmap_add(&map->map, &entry->ent);
+ return NULL;
+}
+
+struct strmap_entry *strmap_get_entry(struct strmap *map, const char *str)
+{
+ return find_strmap_entry(map, str);
+}
+
+void *strmap_get(struct strmap *map, const char *str)
+{
+ struct strmap_entry *entry = find_strmap_entry(map, str);
+ return entry ? entry->value : NULL;
+}
+
+int strmap_contains(struct strmap *map, const char *str)
+{
+ return find_strmap_entry(map, str) != NULL;
+}
+
+void strmap_remove(struct strmap *map, const char *str, int free_value)
+{
+ struct strmap_entry entry, *ret;
+ hashmap_entry_init(&entry.ent, strhash(str));
+ entry.key = str;
+ ret = hashmap_remove_entry(&map->map, &entry, ent, NULL);
+ if (!ret)
+ return;
+ if (free_value)
+ free(ret->value);
+ if (!map->pool)
+ free(ret);
+}
+
+void strintmap_incr(struct strintmap *map, const char *str, intptr_t amt)
+{
+ struct strmap_entry *entry = find_strmap_entry(&map->map, str);
+ if (entry) {
+ intptr_t *whence = (intptr_t*)&entry->value;
+ *whence += amt;
+ }
+ else
+ strintmap_set(map, str, map->default_value + amt);
+}
+
+int strset_add(struct strset *set, const char *str)
+{
+ /*
+ * Cannot use strmap_put() because it'll return NULL in both cases:
+ * - cannot find str: NULL means "not found"
+ * - does find str: NULL is the value associated with str
+ */
+ struct strmap_entry *entry = find_strmap_entry(&set->map, str);
+
+ if (entry)
+ return 0;
+
+ entry = create_entry(&set->map, str, NULL);
+ hashmap_add(&set->map.map, &entry->ent);
+ return 1;
+}
diff --git a/strmap.h b/strmap.h
new file mode 100644
index 0000000000..c4c104411b
--- /dev/null
+++ b/strmap.h
@@ -0,0 +1,268 @@
+#ifndef STRMAP_H
+#define STRMAP_H
+
+#include "hashmap.h"
+
+struct mem_pool;
+struct strmap {
+ struct hashmap map;
+ struct mem_pool *pool;
+ unsigned int strdup_strings:1;
+};
+
+struct strmap_entry {
+ struct hashmap_entry ent;
+ const char *key;
+ void *value;
+ /* strmap_entry may be allocated extra space to store the key at end */
+};
+
+int cmp_strmap_entry(const void *hashmap_cmp_fn_data,
+ const struct hashmap_entry *entry1,
+ const struct hashmap_entry *entry2,
+ const void *keydata);
+
+#define STRMAP_INIT { \
+ .map = HASHMAP_INIT(cmp_strmap_entry, NULL), \
+ .strdup_strings = 1, \
+ }
+#define STRINTMAP_INIT { \
+ .map = STRMAP_INIT, \
+ .default_value = 0, \
+ }
+#define STRSET_INIT { .map = STRMAP_INIT }
+
+/*
+ * Initialize the members of the strmap. Any keys added to the strmap will
+ * be strdup'ed with their memory managed by the strmap.
+ */
+void strmap_init(struct strmap *map);
+
+/*
+ * Same as strmap_init, but for those who want to control the memory management
+ * carefully instead of using the default of strdup_strings=1 and pool=NULL.
+ */
+void strmap_init_with_options(struct strmap *map,
+ struct mem_pool *pool,
+ int strdup_strings);
+
+/*
+ * Remove all entries from the map, releasing any allocated resources.
+ */
+void strmap_clear(struct strmap *map, int free_values);
+
+/*
+ * Similar to strmap_clear() but leaves map->map->table allocated and
+ * pre-sized so that subsequent uses won't need as many rehashings.
+ */
+void strmap_partial_clear(struct strmap *map, int free_values);
+
+/*
+ * Insert "str" into the map, pointing to "data".
+ *
+ * If an entry for "str" already exists, its data pointer is overwritten, and
+ * the original data pointer returned. Otherwise, returns NULL.
+ */
+void *strmap_put(struct strmap *map, const char *str, void *data);
+
+/*
+ * Return the strmap_entry mapped by "str", or NULL if there is not such
+ * an item in map.
+ */
+struct strmap_entry *strmap_get_entry(struct strmap *map, const char *str);
+
+/*
+ * Return the data pointer mapped by "str", or NULL if the entry does not
+ * exist.
+ */
+void *strmap_get(struct strmap *map, const char *str);
+
+/*
+ * Return non-zero iff "str" is present in the map. This differs from
+ * strmap_get() in that it can distinguish entries with a NULL data pointer.
+ */
+int strmap_contains(struct strmap *map, const char *str);
+
+/*
+ * Remove the given entry from the strmap. If the string isn't in the
+ * strmap, the map is not altered.
+ */
+void strmap_remove(struct strmap *map, const char *str, int free_value);
+
+/*
+ * Return how many entries the strmap has.
+ */
+static inline unsigned int strmap_get_size(struct strmap *map)
+{
+ return hashmap_get_size(&map->map);
+}
+
+/*
+ * Return whether the strmap is empty.
+ */
+static inline int strmap_empty(struct strmap *map)
+{
+ return strmap_get_size(map) == 0;
+}
+
+/*
+ * iterate through @map using @iter, @var is a pointer to a type strmap_entry
+ */
+#define strmap_for_each_entry(mystrmap, iter, var) \
+ hashmap_for_each_entry(&(mystrmap)->map, iter, var, ent)
+
+
+/*
+ * strintmap:
+ * A map of string -> int, typecasting the void* of strmap to an int.
+ *
+ * Primary differences:
+ * 1) Since the void* value is just an int in disguise, there is no value
+ * to free. (Thus one fewer argument to strintmap_clear)
+ * 2) strintmap_get() returns an int, or returns the default_value if the
+ * key is not found in the strintmap.
+ * 3) No strmap_put() equivalent; strintmap_set() and strintmap_incr()
+ * instead.
+ */
+
+struct strintmap {
+ struct strmap map;
+ int default_value;
+};
+
+#define strintmap_for_each_entry(mystrmap, iter, var) \
+ strmap_for_each_entry(&(mystrmap)->map, iter, var)
+
+static inline void strintmap_init(struct strintmap *map, int default_value)
+{
+ strmap_init(&map->map);
+ map->default_value = default_value;
+}
+
+static inline void strintmap_init_with_options(struct strintmap *map,
+ int default_value,
+ struct mem_pool *pool,
+ int strdup_strings)
+{
+ strmap_init_with_options(&map->map, pool, strdup_strings);
+ map->default_value = default_value;
+}
+
+static inline void strintmap_clear(struct strintmap *map)
+{
+ strmap_clear(&map->map, 0);
+}
+
+static inline void strintmap_partial_clear(struct strintmap *map)
+{
+ strmap_partial_clear(&map->map, 0);
+}
+
+static inline int strintmap_contains(struct strintmap *map, const char *str)
+{
+ return strmap_contains(&map->map, str);
+}
+
+static inline void strintmap_remove(struct strintmap *map, const char *str)
+{
+ return strmap_remove(&map->map, str, 0);
+}
+
+static inline int strintmap_empty(struct strintmap *map)
+{
+ return strmap_empty(&map->map);
+}
+
+static inline unsigned int strintmap_get_size(struct strintmap *map)
+{
+ return strmap_get_size(&map->map);
+}
+
+/*
+ * Returns the value for str in the map. If str isn't found in the map,
+ * the map's default_value is returned.
+ */
+static inline int strintmap_get(struct strintmap *map, const char *str)
+{
+ struct strmap_entry *result = strmap_get_entry(&map->map, str);
+ if (!result)
+ return map->default_value;
+ return (intptr_t)result->value;
+}
+
+static inline void strintmap_set(struct strintmap *map, const char *str,
+ intptr_t v)
+{
+ strmap_put(&map->map, str, (void *)v);
+}
+
+/*
+ * Increment the value for str by amt. If str isn't in the map, add it and
+ * set its value to default_value + amt.
+ */
+void strintmap_incr(struct strintmap *map, const char *str, intptr_t amt);
+
+/*
+ * strset:
+ * A set of strings.
+ *
+ * Primary differences with strmap:
+ * 1) The value is always NULL, and ignored. As there is no value to free,
+ * there is one fewer argument to strset_clear
+ * 2) No strset_get() because there is no value.
+ * 3) No strset_put(); use strset_add() instead.
+ */
+
+struct strset {
+ struct strmap map;
+};
+
+#define strset_for_each_entry(mystrset, iter, var) \
+ strmap_for_each_entry(&(mystrset)->map, iter, var)
+
+static inline void strset_init(struct strset *set)
+{
+ strmap_init(&set->map);
+}
+
+static inline void strset_init_with_options(struct strset *set,
+ struct mem_pool *pool,
+ int strdup_strings)
+{
+ strmap_init_with_options(&set->map, pool, strdup_strings);
+}
+
+static inline void strset_clear(struct strset *set)
+{
+ strmap_clear(&set->map, 0);
+}
+
+static inline void strset_partial_clear(struct strset *set)
+{
+ strmap_partial_clear(&set->map, 0);
+}
+
+static inline int strset_contains(struct strset *set, const char *str)
+{
+ return strmap_contains(&set->map, str);
+}
+
+static inline void strset_remove(struct strset *set, const char *str)
+{
+ return strmap_remove(&set->map, str, 0);
+}
+
+static inline int strset_empty(struct strset *set)
+{
+ return strmap_empty(&set->map);
+}
+
+static inline unsigned int strset_get_size(struct strset *set)
+{
+ return strmap_get_size(&set->map);
+}
+
+/* Returns 1 if str is added to the set; returns 0 if str was already in set */
+int strset_add(struct strset *set, const char *str);
+
+#endif /* STRMAP_H */
diff --git a/submodule-config.c b/submodule-config.c
index c569e22aa3..f502505566 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -103,8 +103,8 @@ static void submodule_cache_clear(struct submodule_cache *cache)
ent /* member name */)
free_one_config(entry);
- hashmap_free_entries(&cache->for_path, struct submodule_entry, ent);
- hashmap_free_entries(&cache->for_name, struct submodule_entry, ent);
+ hashmap_clear_and_free(&cache->for_path, struct submodule_entry, ent);
+ hashmap_clear_and_free(&cache->for_name, struct submodule_entry, ent);
cache->initialized = 0;
cache->gitmodules_read = 0;
}
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c
index f38706216f..36ff07bd4b 100644
--- a/t/helper/test-hashmap.c
+++ b/t/helper/test-hashmap.c
@@ -110,7 +110,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
hashmap_add(&map, &entries[i]->ent);
}
- hashmap_free(&map);
+ hashmap_clear(&map);
}
} else {
/* test map lookups */
@@ -130,7 +130,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
}
}
- hashmap_free(&map);
+ hashmap_clear(&map);
}
}
@@ -151,12 +151,11 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
int cmd__hashmap(int argc, const char **argv)
{
struct strbuf line = STRBUF_INIT;
- struct hashmap map;
int icase;
+ struct hashmap map = HASHMAP_INIT(test_entry_cmp, &icase);
/* init hash map */
icase = argc > 1 && !strcmp("ignorecase", argv[1]);
- hashmap_init(&map, test_entry_cmp, &icase, 0);
/* process commands from stdin */
while (strbuf_getline(&line, stdin) != EOF) {
@@ -262,6 +261,6 @@ int cmd__hashmap(int argc, const char **argv)
}
strbuf_release(&line);
- hashmap_free_entries(&map, struct test_entry, ent);
+ hashmap_clear_and_free(&map, struct test_entry, ent);
return 0;
}
diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c
index 42164d9898..cc08506cf0 100644
--- a/t/helper/test-proc-receive.c
+++ b/t/helper/test-proc-receive.c
@@ -10,8 +10,11 @@ static const char *proc_receive_usage[] = {
NULL
};
-static int die_version;
-static int die_readline;
+static int die_read_version;
+static int die_write_version;
+static int die_read_commands;
+static int die_read_push_options;
+static int die_write_report;
static int no_push_options;
static int use_atomic;
static int use_push_options;
@@ -33,14 +36,23 @@ struct command {
static void proc_receive_verison(struct packet_reader *reader) {
int server_version = 0;
+ if (die_read_version)
+ die("die with the --die-read-version option");
+
for (;;) {
int linelen;
if (packet_reader_read(reader) != PACKET_READ_NORMAL)
break;
+ /* Ignore version negotiation for version 0 */
+ if (version == 0)
+ continue;
+
if (reader->pktlen > 8 && starts_with(reader->line, "version=")) {
server_version = atoi(reader->line+8);
+ if (server_version != 1)
+ die("bad protocol version: %d", server_version);
linelen = strlen(reader->line);
if (linelen < reader->pktlen) {
const char *feature_list = reader->line + linelen + 1;
@@ -52,12 +64,13 @@ static void proc_receive_verison(struct packet_reader *reader) {
}
}
- if (server_version != 1 || die_version)
- die("bad protocol version: %d", server_version);
+ if (die_write_version)
+ die("die with the --die-write-version option");
- packet_write_fmt(1, "version=%d%c%s\n",
- version, '\0',
- use_push_options && !no_push_options ? "push-options": "");
+ if (version != 0)
+ packet_write_fmt(1, "version=%d%c%s\n",
+ version, '\0',
+ use_push_options && !no_push_options ? "push-options": "");
packet_flush(1);
}
@@ -75,11 +88,13 @@ static void proc_receive_read_commands(struct packet_reader *reader,
if (packet_reader_read(reader) != PACKET_READ_NORMAL)
break;
+ if (die_read_commands)
+ die("die with the --die-read-commands option");
+
if (parse_oid_hex(reader->line, &old_oid, &p) ||
*p++ != ' ' ||
parse_oid_hex(p, &new_oid, &p) ||
- *p++ != ' ' ||
- die_readline)
+ *p++ != ' ')
die("protocol error: expected 'old new ref', got '%s'",
reader->line);
refname = p;
@@ -99,6 +114,9 @@ static void proc_receive_read_push_options(struct packet_reader *reader,
if (no_push_options || !use_push_options)
return;
+ if (die_read_push_options)
+ die("die with the --die-read-push-options option");
+
while (1) {
if (packet_reader_read(reader) != PACKET_READ_NORMAL)
break;
@@ -117,10 +135,16 @@ int cmd__proc_receive(int argc, const char **argv)
struct option options[] = {
OPT_BOOL(0, "no-push-options", &no_push_options,
"disable push options"),
- OPT_BOOL(0, "die-version", &die_version,
- "die during version negotiation"),
- OPT_BOOL(0, "die-readline", &die_readline,
- "die when readline"),
+ OPT_BOOL(0, "die-read-version", &die_read_version,
+ "die when reading version"),
+ OPT_BOOL(0, "die-write-version", &die_write_version,
+ "die when writing version"),
+ OPT_BOOL(0, "die-read-commands", &die_read_commands,
+ "die when reading commands"),
+ OPT_BOOL(0, "die-read-push-options", &die_read_push_options,
+ "die when reading push-options"),
+ OPT_BOOL(0, "die-write-report", &die_write_report,
+ "die when writing report"),
OPT_STRING_LIST('r', "return", &returns, "old/new/ref/status/msg",
"return of results"),
OPT__VERBOSE(&verbose, "be verbose"),
@@ -136,7 +160,7 @@ int cmd__proc_receive(int argc, const char **argv)
usage_msg_opt("Too many arguments.", proc_receive_usage, options);
packet_reader_init(&reader, 0, NULL, 0,
PACKET_READ_CHOMP_NEWLINE |
- PACKET_READ_DIE_ON_ERR_PACKET);
+ PACKET_READ_GENTLE_ON_EOF);
sigchain_push(SIGPIPE, SIG_IGN);
proc_receive_verison(&reader);
@@ -166,6 +190,8 @@ int cmd__proc_receive(int argc, const char **argv)
fprintf(stderr, "proc-receive> %s\n", item->string);
}
+ if (die_write_report)
+ die("die with the --die-write-report option");
if (returns.nr)
for_each_string_list_item(item, &returns)
packet_write_fmt(1, "%s\n", item->string);
diff --git a/t/perf/p1400-update-ref.sh b/t/perf/p1400-update-ref.sh
index ce5ac3ed85..dda8a74866 100755
--- a/t/perf/p1400-update-ref.sh
+++ b/t/perf/p1400-update-ref.sh
@@ -7,13 +7,14 @@ test_description="Tests performance of update-ref"
test_perf_fresh_repo
test_expect_success "setup" '
- git init --bare target-repo.git &&
test_commit PRE &&
test_commit POST &&
- printf "create refs/heads/%d PRE\n" $(test_seq 1000) >create &&
- printf "update refs/heads/%d POST PRE\n" $(test_seq 1000) >update &&
- printf "delete refs/heads/%d POST\n" $(test_seq 1000) >delete &&
- git update-ref --stdin <create
+ for i in $(test_seq 5000)
+ do
+ printf "start\ncreate refs/heads/%d PRE\ncommit\n" $i &&
+ printf "start\nupdate refs/heads/%d POST PRE\ncommit\n" $i &&
+ printf "start\ndelete refs/heads/%d POST\ncommit\n" $i
+ done >instructions
'
test_perf "update-ref" '
@@ -26,14 +27,7 @@ test_perf "update-ref" '
'
test_perf "update-ref --stdin" '
- git update-ref --stdin <update &&
- git update-ref --stdin <delete &&
- git update-ref --stdin <create
-'
-
-test_perf "nonatomic push" '
- git push ./target-repo.git $(test_seq 1000) &&
- git push --delete ./target-repo.git $(test_seq 1000)
+ git update-ref --stdin <instructions >/dev/null
'
test_done
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 22489c24dc..f4ba2e8c85 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -840,6 +840,27 @@ then
exit 1
fi
+test_lazy_prereq NESTED_INNER '
+ >inner &&
+ rm -f outer
+'
+test_lazy_prereq NESTED_PREREQ '
+ >outer &&
+ test_have_prereq NESTED_INNER &&
+ echo "can create new file in cwd" >file &&
+ test -f outer &&
+ test ! -f inner
+'
+test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' '
+ nestedworks=yes
+'
+
+if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes
+then
+ say 'bug in test framework: nested lazy prerequisites do not work'
+ exit 1
+fi
+
test_expect_success 'lazy prereqs do not turn off tracing' "
run_sub_test_lib_test lazy-prereq-and-tracing \
'lazy prereqs and -x' -v -x <<-\\EOF &&
diff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh
index ebb8e1aecb..b4a9158307 100755
--- a/t/t1309-early-config.sh
+++ b/t/t1309-early-config.sh
@@ -91,11 +91,11 @@ test_expect_failure 'ignore .git/ with invalid config' '
test_expect_success 'early config and onbranch' '
echo "[broken" >broken &&
- test_with_config "[includeif \"onbranch:master\"]path=../broken"
+ test_with_config "[includeif \"onbranch:topic\"]path=../broken"
'
test_expect_success 'onbranch config outside of git repo' '
- test_config_global includeIf.onbranch:master.path non-existent &&
+ test_config_global includeIf.onbranch:topic.path non-existent &&
nongit git help
'
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 4c01e08551..31b64be521 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -48,17 +48,17 @@ test_expect_success "fail to delete $m with stale ref" '
test $B = "$(git show-ref -s --verify $m)"
'
test_expect_success "delete $m" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref -d $m $B &&
- test_path_is_missing .git/$m
+ test_must_fail git show-ref --verify -q $m
'
test_expect_success "delete $m without oldvalue verification" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref $m $A &&
test $A = $(git show-ref -s --verify $m) &&
git update-ref -d $m &&
- test_path_is_missing .git/$m
+ test_must_fail git show-ref --verify -q $m
'
test_expect_success "fail to create $n" '
@@ -80,26 +80,26 @@ test_expect_success "fail to delete $m (by HEAD) with stale ref" '
test $B = $(git show-ref -s --verify $m)
'
test_expect_success "delete $m (by HEAD)" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref -d HEAD $B &&
- test_path_is_missing .git/$m
+ test_must_fail git show-ref --verify -q $m
'
test_expect_success "deleting current branch adds message to HEAD's log" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref $m $A &&
git symbolic-ref HEAD $m &&
git update-ref -m delete-$m -d $m &&
- test_path_is_missing .git/$m &&
+ test_must_fail git show-ref --verify -q $m &&
grep "delete-$m$" .git/logs/HEAD
'
test_expect_success "deleting by HEAD adds message to HEAD's log" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref $m $A &&
git symbolic-ref HEAD $m &&
git update-ref -m delete-by-head -d HEAD &&
- test_path_is_missing .git/$m &&
+ test_must_fail git show-ref --verify -q $m &&
grep "delete-by-head$" .git/logs/HEAD
'
@@ -188,31 +188,37 @@ test_expect_success "move $m (by HEAD)" '
test $B = $(git show-ref -s --verify $m)
'
test_expect_success "delete $m (by HEAD) should remove both packed and loose $m" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
git update-ref -d HEAD $B &&
! grep "$m" .git/packed-refs &&
- test_path_is_missing .git/$m
+ test_must_fail git show-ref --verify -q $m
'
-cp -f .git/HEAD .git/HEAD.orig
test_expect_success 'delete symref without dereference' '
- test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
- git update-ref --no-deref -d HEAD &&
- test_path_is_missing .git/HEAD
+ test_when_finished "git update-ref -d $m" &&
+ echo foo >foo.c &&
+ git add foo.c &&
+ git commit -m foo &&
+ git symbolic-ref SYMREF $m &&
+ git update-ref --no-deref -d SYMREF &&
+ git show-ref --verify -q $m &&
+ test_must_fail git show-ref --verify -q SYMREF &&
+ test_must_fail git symbolic-ref SYMREF
'
test_expect_success 'delete symref without dereference when the referred ref is packed' '
- test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
+ test_when_finished "git update-ref -d $m" &&
echo foo >foo.c &&
git add foo.c &&
git commit -m foo &&
+ git symbolic-ref SYMREF $m &&
git pack-refs --all &&
- git update-ref --no-deref -d HEAD &&
- test_path_is_missing .git/HEAD
+ git update-ref --no-deref -d SYMREF &&
+ git show-ref --verify -q $m &&
+ test_must_fail git show-ref --verify -q SYMREF &&
+ test_must_fail git symbolic-ref SYMREF
'
-git update-ref -d $m
-
test_expect_success 'update-ref -d is not confused by self-reference' '
git symbolic-ref refs/heads/self refs/heads/self &&
test_when_finished "rm -f .git/refs/heads/self" &&
@@ -226,25 +232,25 @@ test_expect_success 'update-ref --no-deref -d can delete self-reference' '
test_when_finished "rm -f .git/refs/heads/self" &&
test_path_is_file .git/refs/heads/self &&
git update-ref --no-deref -d refs/heads/self &&
- test_path_is_missing .git/refs/heads/self
+ test_must_fail git show-ref --verify -q refs/heads/self
'
test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
>.git/refs/heads/bad &&
test_when_finished "rm -f .git/refs/heads/bad" &&
git symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&
- test_when_finished "rm -f .git/refs/heads/ref-to-bad" &&
+ test_when_finished "git update-ref -d refs/heads/ref-to-bad" &&
test_path_is_file .git/refs/heads/ref-to-bad &&
git update-ref --no-deref -d refs/heads/ref-to-bad &&
- test_path_is_missing .git/refs/heads/ref-to-bad
+ test_must_fail git show-ref --verify -q refs/heads/ref-to-bad
'
test_expect_success '(not) create HEAD with old sha1' '
test_must_fail git update-ref HEAD $A $B
'
test_expect_success "(not) prior created .git/$m" '
- test_when_finished "rm -f .git/$m" &&
- test_path_is_missing .git/$m
+ test_when_finished "git update-ref -d $m" &&
+ test_must_fail git show-ref --verify -q $m
'
test_expect_success 'create HEAD' '
@@ -254,7 +260,7 @@ test_expect_success '(not) change HEAD with wrong SHA1' '
test_must_fail git update-ref HEAD $B $Z
'
test_expect_success "(not) changed .git/$m" '
- test_when_finished "rm -f .git/$m" &&
+ test_when_finished "git update-ref -d $m" &&
! test $B = $(git show-ref -s --verify $m)
'
@@ -284,8 +290,8 @@ test_expect_success 'empty directory removal' '
test_path_is_file .git/refs/heads/d1/d2/r1 &&
test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
git branch -d d1/d2/r1 &&
- test_path_is_missing .git/refs/heads/d1/d2 &&
- test_path_is_missing .git/logs/refs/heads/d1/d2 &&
+ test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
+ test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
test_path_is_file .git/refs/heads/d1/r2 &&
test_path_is_file .git/logs/refs/heads/d1/r2
'
@@ -298,8 +304,8 @@ test_expect_success 'symref empty directory removal' '
test_path_is_file .git/refs/heads/e1/e2/r1 &&
test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
git update-ref -d HEAD &&
- test_path_is_missing .git/refs/heads/e1/e2 &&
- test_path_is_missing .git/logs/refs/heads/e1/e2 &&
+ test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
+ test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
test_path_is_file .git/refs/heads/e1/r2 &&
test_path_is_file .git/logs/refs/heads/e1/r2 &&
test_path_is_file .git/logs/HEAD
@@ -1388,7 +1394,8 @@ test_expect_success 'handle per-worktree refs in refs/bisect' '
git rev-parse refs/bisect/something >../worktree-head &&
git for-each-ref | grep refs/bisect/something
) &&
- test_path_is_missing .git/refs/bisect &&
+ git show-ref >actual &&
+ ! grep 'refs/bisect' actual &&
test_must_fail git rev-parse refs/bisect/something &&
git update-ref refs/bisect/something HEAD &&
git rev-parse refs/bisect/something >main-head &&
@@ -1500,7 +1507,7 @@ test_expect_success 'transaction can handle abort' '
git update-ref --stdin <stdin >actual &&
printf "%s: ok\n" start abort >expect &&
test_cmp expect actual &&
- test_path_is_missing .git/$b
+ test_must_fail git show-ref --verify -q $b
'
test_expect_success 'transaction aborts by default' '
@@ -1511,7 +1518,7 @@ test_expect_success 'transaction aborts by default' '
git update-ref --stdin <stdin >actual &&
printf "%s: ok\n" start >expect &&
test_cmp expect actual &&
- test_path_is_missing .git/$b
+ test_must_fail git show-ref --verify -q $b
'
test_expect_success 'transaction with prepare aborts by default' '
@@ -1523,7 +1530,68 @@ test_expect_success 'transaction with prepare aborts by default' '
git update-ref --stdin <stdin >actual &&
printf "%s: ok\n" start prepare >expect &&
test_cmp expect actual &&
- test_path_is_missing .git/$b
+ test_must_fail git show-ref --verify -q $b
+'
+
+test_expect_success 'transaction can commit multiple times' '
+ cat >stdin <<-EOF &&
+ start
+ create refs/heads/branch-1 $A
+ commit
+ start
+ create refs/heads/branch-2 $B
+ commit
+ EOF
+ git update-ref --stdin <stdin >actual &&
+ printf "%s: ok\n" start commit start commit >expect &&
+ test_cmp expect actual &&
+ echo "$A" >expect &&
+ git rev-parse refs/heads/branch-1 >actual &&
+ test_cmp expect actual &&
+ echo "$B" >expect &&
+ git rev-parse refs/heads/branch-2 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'transaction can create and delete' '
+ cat >stdin <<-EOF &&
+ start
+ create refs/heads/create-and-delete $A
+ commit
+ start
+ delete refs/heads/create-and-delete $A
+ commit
+ EOF
+ git update-ref --stdin <stdin >actual &&
+ printf "%s: ok\n" start commit start commit >expect &&
+ test_must_fail git show-ref --verify refs/heads/create-and-delete
+'
+
+test_expect_success 'transaction can commit after abort' '
+ cat >stdin <<-EOF &&
+ start
+ create refs/heads/abort $A
+ abort
+ start
+ create refs/heads/abort $A
+ commit
+ EOF
+ git update-ref --stdin <stdin >actual &&
+ printf "%s: ok\n" start abort start commit >expect &&
+ echo "$A" >expect &&
+ git rev-parse refs/heads/abort >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'transaction cannot restart ongoing transaction' '
+ cat >stdin <<-EOF &&
+ start
+ create refs/heads/restart $A
+ start
+ commit
+ EOF
+ test_must_fail git update-ref --stdin <stdin >actual &&
+ test_must_fail git show-ref --verify refs/heads/restart
'
test_done
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 492edffa9c..dc9fe3cbf1 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -144,4 +144,17 @@ test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' '
test_must_fail git rev-parse --verify broken
'
+test_expect_success 'options can appear after --verify' '
+ git rev-parse --verify HEAD >expect &&
+ git rev-parse --verify -q HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'verify respects --end-of-options' '
+ git update-ref refs/heads/-tricky HEAD &&
+ git rev-parse --verify HEAD >expect &&
+ git rev-parse --verify --end-of-options -tricky >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 3e657e693b..e2ae15a2cf 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -254,4 +254,29 @@ test_expect_success 'escaped char does not trigger wildcard rule' '
test_must_fail git rev-parse "foo\\*bar"
'
+test_expect_success 'arg after dashdash not interpreted as option' '
+ cat >expect <<-\EOF &&
+ --
+ --local-env-vars
+ EOF
+ git rev-parse -- --local-env-vars >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'arg after end-of-options not interpreted as option' '
+ test_must_fail git rev-parse --end-of-options --not-real -- 2>err &&
+ test_i18ngrep bad.revision.*--not-real err
+'
+
+test_expect_success 'end-of-options still allows --' '
+ cat >expect <<-EOF &&
+ --end-of-options
+ $(git rev-parse --verify HEAD)
+ --
+ path
+ EOF
+ git rev-parse --end-of-options HEAD -- path >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t2106-update-index-assume-unchanged.sh b/t/t2106-update-index-assume-unchanged.sh
index 99d858c6b7..2d450daf5c 100755
--- a/t/t2106-update-index-assume-unchanged.sh
+++ b/t/t2106-update-index-assume-unchanged.sh
@@ -5,20 +5,23 @@ test_description='git update-index --assume-unchanged test.
. ./test-lib.sh
-test_expect_success 'setup' \
- ': >file &&
- git add file &&
- git commit -m initial &&
- git branch other &&
- echo upstream >file &&
- git add file &&
- git commit -m upstream'
+test_expect_success 'setup' '
+ : >file &&
+ git add file &&
+ git commit -m initial &&
+ git branch other &&
+ echo upstream >file &&
+ git add file &&
+ git commit -m upstream
+'
-test_expect_success 'do not switch branches with dirty file' \
- 'git reset --hard &&
- git checkout other &&
- echo dirt >file &&
- git update-index --assume-unchanged file &&
- test_must_fail git checkout master'
+test_expect_success 'do not switch branches with dirty file' '
+ git reset --hard &&
+ git checkout other &&
+ echo dirt >file &&
+ git update-index --assume-unchanged file &&
+ test_must_fail git checkout - 2>err &&
+ test_i18ngrep overwritten err
+'
test_done
diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh
index b81eb5fd6f..6abdcbbc94 100755
--- a/t/t3040-subprojects-basic.sh
+++ b/t/t3040-subprojects-basic.sh
@@ -79,7 +79,4 @@ test_expect_success 'checkout in superproject' '
git diff-index --exit-code --raw --cached save -- sub1
'
-# just interesting what happened...
-# git diff --name-status -M save master
-
test_done
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 8f43303007..ca60faf480 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -672,6 +672,11 @@ test_expect_success 'notes.displayRef respects order' '
test_cmp expect-both-reversed actual
'
+test_expect_success 'notes.displayRef with no value handled gracefully' '
+ test_must_fail git -c notes.displayRef log -0 --notes &&
+ test_must_fail git -c notes.displayRef diff-tree --notes HEAD
+'
+
test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
git log -2 >actual &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 1e56696e4f..b06fc36159 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -12,7 +12,7 @@ Initial setup:
one - two - three - four (conflict-branch)
/
- A - B - C - D - E (master)
+ A - B - C - D - E (primary)
| \
| F - G - H (branch1)
| \
@@ -30,6 +30,7 @@ Initial setup:
. "$TEST_DIRECTORY"/lib-rebase.sh
test_expect_success 'setup' '
+ git switch -C primary &&
test_commit A file1 &&
test_commit B file1 &&
test_commit C file2 &&
@@ -65,7 +66,7 @@ SHELL=
export SHELL
test_expect_success 'rebase --keep-empty' '
- git checkout -b emptybranch master &&
+ git checkout -b emptybranch primary &&
git commit --allow-empty -m "empty" &&
git rebase --keep-empty -i HEAD~2 &&
git log --oneline >actual &&
@@ -86,7 +87,7 @@ test_expect_success 'rebase -i with empty todo list' '
'
test_expect_success 'rebase -i with the exec command' '
- git checkout master &&
+ git checkout primary &&
(
set_fake_editor &&
FAKE_LINES="1 exec_>touch-one
@@ -103,12 +104,12 @@ test_expect_success 'rebase -i with the exec command' '
test_path_is_file touch-three &&
test_path_is_file "touch-file name with spaces" &&
test_path_is_file touch-after-semicolon &&
- test_cmp_rev master HEAD &&
+ test_cmp_rev primary HEAD &&
rm -f touch-*
'
test_expect_success 'rebase -i with the exec command runs from tree root' '
- git checkout master &&
+ git checkout primary &&
mkdir subdir && (cd subdir &&
set_fake_editor &&
FAKE_LINES="1 exec_>touch-subdir" \
@@ -121,7 +122,7 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
test_expect_success 'rebase -i with exec allows git commands in subdirs' '
test_when_finished "rm -rf subdir" &&
test_when_finished "git rebase --abort ||:" &&
- git checkout master &&
+ git checkout primary &&
mkdir subdir && (cd subdir &&
set_fake_editor &&
FAKE_LINES="1 x_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
@@ -139,13 +140,13 @@ test_expect_success 'rebase -i sets work tree properly' '
'
test_expect_success 'rebase -i with the exec command checks tree cleanness' '
- git checkout master &&
+ git checkout primary &&
(
set_fake_editor &&
test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" \
git rebase -i HEAD^
) &&
- test_cmp_rev master^ HEAD &&
+ test_cmp_rev primary^ HEAD &&
git reset --hard &&
git rebase --continue
'
@@ -168,7 +169,7 @@ test_expect_success 'rebase -x with newline in command fails' '
'
test_expect_success 'rebase -i with exec of inexistent command' '
- git checkout master &&
+ git checkout primary &&
test_when_finished "git rebase --abort" &&
(
set_fake_editor &&
@@ -259,8 +260,8 @@ test_expect_success 'stop on conflicting pick' '
>>>>>>> $commit (G)
EOF
git tag new-branch1 &&
- test_must_fail git rebase -i master &&
- test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" &&
+ test_must_fail git rebase -i primary &&
+ test "$(git rev-parse HEAD~3)" = "$(git rev-parse primary)" &&
test_cmp expect .git/rebase-merge/patch &&
test_cmp expect2 file1 &&
test "$(git diff --name-status |
@@ -287,7 +288,7 @@ test_expect_success 'abort' '
test_expect_success 'abort with error when new base cannot be checked out' '
git rm --cached file1 &&
git commit -m "remove file in base" &&
- test_must_fail git rebase -i master > output 2>&1 &&
+ test_must_fail git rebase -i primary > output 2>&1 &&
test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
output &&
test_i18ngrep "file1" output &&
@@ -301,7 +302,7 @@ test_expect_success 'retain authorship' '
test_tick &&
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
git tag twerp &&
- git rebase -i --onto master HEAD^ &&
+ git rebase -i --onto primary HEAD^ &&
git show HEAD | grep "^Author: Twerp Snog"
'
@@ -336,10 +337,10 @@ test_expect_success 'squash' '
(
set_fake_editor &&
FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \
- git rebase -i --onto master HEAD~2
+ git rebase -i --onto primary HEAD~2
) &&
test B = $(cat file7) &&
- test_cmp_rev HEAD^ master
+ test_cmp_rev HEAD^ primary
'
test_expect_success 'retain authorship when squashing' '
@@ -366,12 +367,12 @@ test_expect_failure REBASE_P 'exchange two commits with -p' '
'
test_expect_success REBASE_P 'preserve merges with -p' '
- git checkout -b to-be-preserved master^ &&
+ git checkout -b to-be-preserved primary^ &&
: > unrelated-file &&
git add unrelated-file &&
test_tick &&
git commit -m "unrelated" &&
- git checkout -b another-branch master &&
+ git checkout -b another-branch primary &&
echo B > file1 &&
test_tick &&
git commit -m J file1 &&
@@ -394,7 +395,7 @@ test_expect_success REBASE_P 'preserve merges with -p' '
git commit -m M file1 &&
git checkout -b to-be-rebased &&
test_tick &&
- git rebase -i -p --onto branch1 master &&
+ git rebase -i -p --onto branch1 primary &&
git update-index --refresh &&
git diff-files --quiet &&
git diff-index --quiet --cached HEAD -- &&
@@ -437,7 +438,7 @@ test_expect_success '--continue tries to commit' '
'
test_expect_success 'verbose flag is heeded, even after --continue' '
- git reset --hard master@{1} &&
+ git reset --hard primary@{1} &&
test_tick &&
test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
echo resolved > file1 &&
@@ -802,7 +803,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' '
'
test_expect_success 'avoid unnecessary reset' '
- git checkout master &&
+ git checkout primary &&
git reset --hard &&
test-tool chmtime =123456789 file3 &&
git update-index --refresh &&
@@ -814,14 +815,14 @@ test_expect_success 'avoid unnecessary reset' '
'
test_expect_success 'reword' '
- git checkout -b reword-branch master &&
+ git checkout -b reword-branch primary &&
(
set_fake_editor &&
FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \
git rebase -i A &&
git show HEAD | grep "E changed" &&
- test $(git rev-parse master) != $(git rev-parse HEAD) &&
- test_cmp_rev master^ HEAD^ &&
+ test $(git rev-parse primary) != $(git rev-parse HEAD) &&
+ test_cmp_rev primary^ HEAD^ &&
FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
git rebase -i A &&
git show HEAD^ | grep "D changed" &&
@@ -918,7 +919,7 @@ test_expect_success 'rebase-i history with funny messages' '
'
test_expect_success 'prepare for rebase -i --exec' '
- git checkout master &&
+ git checkout primary &&
git checkout -b execute &&
test_commit one_exec main.txt one_exec &&
test_commit two_exec main.txt two_exec &&
@@ -1027,7 +1028,7 @@ test_expect_success 'rebase -i --exec without <CMD>' '
git reset --hard execute &&
test_must_fail git rebase -i --exec 2>actual &&
test_i18ngrep "requires a value" actual &&
- git checkout master
+ git checkout primary
'
test_expect_success 'rebase -i --root re-order and drop commits' '
@@ -1079,7 +1080,7 @@ test_expect_success 'rebase -i --root fixup root commit' '
test_expect_success 'rebase -i --root reword original root commit' '
test_when_finished "test_might_fail git rebase --abort" &&
- git checkout -b reword-original-root-branch master &&
+ git checkout -b reword-original-root-branch primary &&
(
set_fake_editor &&
FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
@@ -1091,7 +1092,7 @@ test_expect_success 'rebase -i --root reword original root commit' '
test_expect_success 'rebase -i --root reword new root commit' '
test_when_finished "test_might_fail git rebase --abort" &&
- git checkout -b reword-now-root-branch master &&
+ git checkout -b reword-now-root-branch primary &&
(
set_fake_editor &&
FAKE_LINES="reword 3 1" FAKE_COMMIT_MESSAGE="C changed" \
@@ -1251,7 +1252,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
'
test_expect_success 'short commit ID setup' '
- test_when_finished "git checkout master" &&
+ test_when_finished "git checkout primary" &&
git checkout --orphan collide &&
git rm -rf . &&
(
@@ -1292,7 +1293,7 @@ test_expect_success 'short commit ID collide' '
t3404_collider sha1:ac4f2ee
t3404_collider sha256:16697
EOF
- test_when_finished "reset_rebase && git checkout master" &&
+ test_when_finished "reset_rebase && git checkout primary" &&
git checkout collide &&
colliding_id=$(test_oid t3404_collision) &&
hexsz=$(test_oid hexsz) &&
@@ -1416,11 +1417,11 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
rebase_setup_and_clean () {
test_when_finished "
- git checkout master &&
+ git checkout primary &&
test_might_fail git branch -D $1 &&
test_might_fail git rebase --abort
" &&
- git checkout -b $1 ${2:-master}
+ git checkout -b $1 ${2:-primary}
}
test_expect_success 'drop' '
@@ -1451,7 +1452,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
cat >expect <<-EOF &&
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
To avoid this message, use "drop" to explicitly remove a commit.
EOF
test_config rebase.missingCommitsCheck warn &&
@@ -1469,8 +1470,8 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
cat >expect <<-EOF &&
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~2)
To avoid this message, use "drop" to explicitly remove a commit.
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1512,11 +1513,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ig
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
cat >expect <<-EOF &&
- error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
+ error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
To avoid this message, use "drop" to explicitly remove a commit.
EOF
head -n4 expect >expect.2 &&
@@ -1546,11 +1547,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
cat >expect <<-EOF &&
- error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
+ error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
- - $(git rev-list --pretty=oneline --abbrev-commit -1 master~4)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
+ - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
To avoid this message, use "drop" to explicitly remove a commit.
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1635,7 +1636,7 @@ test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and e
(
set_cat_todo_editor &&
test_must_fail git rebase -i --exec "git show HEAD" \
- --autosquash master >actual
+ --autosquash primary >actual
) &&
test_cmp expected actual
'
@@ -1646,7 +1647,7 @@ test_expect_success 'static check of bad command' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
git rebase -i --root 2>actual &&
- test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" \
+ test_i18ngrep "badcmd $(git rev-list --oneline -1 primary~1)" \
actual &&
test_i18ngrep "You can fix this with .git rebase --edit-todo.." \
actual &&
@@ -1798,13 +1799,13 @@ test_expect_success 'todo has correct onto hash' '
'
test_expect_success 'ORIG_HEAD is updated correctly' '
- test_when_finished "git checkout master && git branch -D test-orig-head" &&
+ test_when_finished "git checkout primary && git branch -D test-orig-head" &&
git checkout -b test-orig-head A &&
git commit --allow-empty -m A1 &&
git commit --allow-empty -m A2 &&
git commit --allow-empty -m A3 &&
git commit --allow-empty -m A4 &&
- git rebase master &&
+ git rebase primary &&
test_cmp_rev ORIG_HEAD test-orig-head@{1}
'
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index ca04fac417..cc3f434a97 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -589,6 +589,90 @@ test_expect_success 'diffs can be colorized' '
grep "$(printf "\\033")" output
'
+test_expect_success 'colors can be overridden' '
+ git reset --hard &&
+ test_when_finished "git rm -f color-test" &&
+ test_write_lines context old more-context >color-test &&
+ git add color-test &&
+ test_write_lines context new more-context another-one >color-test &&
+
+ echo trigger an error message >input &&
+ force_color git \
+ -c color.interactive.error=blue \
+ add -i 2>err.raw <input &&
+ test_decode_color <err.raw >err &&
+ grep "<BLUE>Huh (trigger)?<RESET>" err &&
+
+ test_write_lines help quit >input &&
+ force_color git \
+ -c color.interactive.header=red \
+ -c color.interactive.help=green \
+ -c color.interactive.prompt=yellow \
+ add -i >actual.raw <input &&
+ test_decode_color <actual.raw >actual &&
+ cat >expect <<-\EOF &&
+ <RED> staged unstaged path<RESET>
+ 1: +3/-0 +2/-1 color-test
+
+ <RED>*** Commands ***<RESET>
+ 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
+ 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
+ <YELLOW>What now<RESET>> <GREEN>status - show paths with changes<RESET>
+ <GREEN>update - add working tree state to the staged set of changes<RESET>
+ <GREEN>revert - revert staged set of changes back to the HEAD version<RESET>
+ <GREEN>patch - pick hunks and update selectively<RESET>
+ <GREEN>diff - view diff between HEAD and index<RESET>
+ <GREEN>add untracked - add contents of untracked files to the staged set of changes<RESET>
+ <RED>*** Commands ***<RESET>
+ 1: <YELLOW>s<RESET>tatus 2: <YELLOW>u<RESET>pdate 3: <YELLOW>r<RESET>evert 4: <YELLOW>a<RESET>dd untracked
+ 5: <YELLOW>p<RESET>atch 6: <YELLOW>d<RESET>iff 7: <YELLOW>q<RESET>uit 8: <YELLOW>h<RESET>elp
+ <YELLOW>What now<RESET>> Bye.
+ EOF
+ test_cmp expect actual &&
+
+ : exercise recolor_hunk by editing and then look at the hunk again &&
+ test_write_lines s e K q >input &&
+ force_color git \
+ -c color.interactive.prompt=yellow \
+ -c color.diff.meta=italic \
+ -c color.diff.frag=magenta \
+ -c color.diff.context=cyan \
+ -c color.diff.old=bold \
+ -c color.diff.new=blue \
+ -c core.editor=touch \
+ add -p >actual.raw <input &&
+ test_decode_color <actual.raw >actual.decoded &&
+ sed "s/index [0-9a-f]*\\.\\.[0-9a-f]* 100644/<INDEX-LINE>/" <actual.decoded >actual &&
+ cat >expect <<-\EOF &&
+ <ITALIC>diff --git a/color-test b/color-test<RESET>
+ <ITALIC><INDEX-LINE><RESET>
+ <ITALIC>--- a/color-test<RESET>
+ <ITALIC>+++ b/color-test<RESET>
+ <MAGENTA>@@ -1,3 +1,4 @@<RESET>
+ <CYAN> context<RESET>
+ <BOLD>-old<RESET>
+ <BLUE>+<RESET><BLUE>new<RESET>
+ <CYAN> more-context<RESET>
+ <BLUE>+<RESET><BLUE>another-one<RESET>
+ <YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
+ <MAGENTA>@@ -1,3 +1,3 @@<RESET>
+ <CYAN> context<RESET>
+ <BOLD>-old<RESET>
+ <BLUE>+<RESET><BLUE>new<RESET>
+ <CYAN> more-context<RESET>
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
+ <CYAN> more-context<RESET>
+ <BLUE>+<RESET><BLUE>another-one<RESET>
+ <YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
+ <CYAN> context<RESET>
+ <BOLD>-old<RESET>
+ <BLUE>+new<RESET>
+ <CYAN> more-context<RESET>
+ <YELLOW>(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? <RESET>
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
git reset --hard &&
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 42588bf6e1..c5e5e0da3f 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -313,6 +313,60 @@ test_expect_success 'multiple files' '
ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch
'
+test_expect_success 'filename length limit' '
+ test_when_finished "rm -f 000*" &&
+ rm -rf 000[1-9]-*.patch &&
+ for len in 15 25 35
+ do
+ git format-patch --filename-max-length=$len -3 side &&
+ max=$(
+ for patch in 000[1-9]-*.patch
+ do
+ echo "$patch" | wc -c
+ done |
+ sort -nr |
+ head -n 1
+ ) &&
+ test $max -le $len || return 1
+ done
+'
+
+test_expect_success 'filename length limit from config' '
+ test_when_finished "rm -f 000*" &&
+ rm -rf 000[1-9]-*.patch &&
+ for len in 15 25 35
+ do
+ git -c format.filenameMaxLength=$len format-patch -3 side &&
+ max=$(
+ for patch in 000[1-9]-*.patch
+ do
+ echo "$patch" | wc -c
+ done |
+ sort -nr |
+ head -n 1
+ ) &&
+ test $max -le $len || return 1
+ done
+'
+
+test_expect_success 'filename limit applies only to basename' '
+ test_when_finished "rm -rf patches/" &&
+ rm -rf patches/ &&
+ for len in 15 25 35
+ do
+ git format-patch -o patches --filename-max-length=$len -3 side &&
+ max=$(
+ for patch in patches/000[1-9]-*.patch
+ do
+ echo "${patch#patches/}" | wc -c
+ done |
+ sort -nr |
+ head -n 1
+ ) &&
+ test $max -le $len || return 1
+ done
+'
+
test_expect_success 'reroll count' '
rm -fr patches &&
git format-patch -o patches --cover-letter --reroll-count 4 master..side >list &&
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 8bdaa0a693..47f0e2889d 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -877,13 +877,13 @@ test_expect_success 'rename empty' '
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
- echo >x hello &&
- git commit -m "one side" x &&
+ test_commit "one side" x hello one-side &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
- test_must_fail git merge master &&
+ test_must_fail git merge one-side >actual &&
+ test_i18ngrep "Automatic merge failed" actual &&
git diff >actual.raw &&
sed -e "1,/^@@@/d" actual.raw >actual &&
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 8318781d2b..1d40fcad39 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -277,7 +277,7 @@ test_expect_success 'pack with missing parent' '
git pack-objects --stdout --revs <revs >/dev/null
'
-test_expect_success JGIT 'we can read jgit bitmaps' '
+test_expect_success JGIT,SHA1 'we can read jgit bitmaps' '
git clone --bare . compat-jgit.git &&
(
cd compat-jgit.git &&
@@ -287,7 +287,7 @@ test_expect_success JGIT 'we can read jgit bitmaps' '
)
'
-test_expect_success JGIT 'jgit can read our bitmaps' '
+test_expect_success JGIT,SHA1 'jgit can read our bitmaps' '
git clone --bare . compat-us.git &&
(
cd compat-us.git &&
diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
index ace469c95c..297de502a9 100755
--- a/t/t5319-multi-pack-index.sh
+++ b/t/t5319-multi-pack-index.sh
@@ -138,7 +138,7 @@ test_expect_success 'write midx with one v2 pack' '
compare_results_with_midx "one v2 pack"
-test_expect_success 'corrupt idx not opened' '
+test_expect_success 'corrupt idx reports errors' '
idx=$(test-tool read-midx $objdir | grep "\.idx\$") &&
mv $objdir/pack/$idx backup-$idx &&
test_when_finished "mv backup-\$idx \$objdir/pack/\$idx" &&
@@ -149,7 +149,7 @@ test_expect_success 'corrupt idx not opened' '
test_copy_bytes 1064 <backup-$idx >$objdir/pack/$idx &&
git -c core.multiPackIndex=true rev-list --objects --all 2>err &&
- test_must_be_empty err
+ grep "index unavailable" err
'
test_expect_success 'add more objects' '
@@ -755,4 +755,30 @@ test_expect_success 'repack --batch-size=<large> repacks everything' '
)
'
+test_expect_success 'load reverse index when missing .idx, .pack' '
+ git init repo &&
+ test_when_finished "rm -fr repo" &&
+ (
+ cd repo &&
+
+ git config core.multiPackIndex true &&
+
+ test_commit base &&
+ git repack -ad &&
+ git multi-pack-index write &&
+
+ git rev-parse HEAD >tip &&
+ pack=$(ls .git/objects/pack/pack-*.pack) &&
+ idx=$(ls .git/objects/pack/pack-*.idx) &&
+
+ mv $idx $idx.bak &&
+ git cat-file --batch-check="%(objectsize:disk)" <tip &&
+
+ mv $idx.bak $idx &&
+
+ mv $pack $pack.bak &&
+ git cat-file --batch-check="%(objectsize:disk)" <tip
+ )
+'
+
test_done
diff --git a/t/t5411/common-functions.sh b/t/t5411/common-functions.sh
index 521a347710..344d13f61a 100644
--- a/t/t5411/common-functions.sh
+++ b/t/t5411/common-functions.sh
@@ -42,7 +42,7 @@ create_commits_in () {
make_user_friendly_and_stable_output () {
sed \
-e "s/ *\$//" \
- -e "s/ */ /g" \
+ -e "s/ */ /g" \
-e "s/'/\"/g" \
-e "s/ / /g" \
-e "s/$A/<COMMIT-A>/g" \
@@ -54,3 +54,8 @@ make_user_friendly_and_stable_output () {
-e "s#To $URL_PREFIX/upstream.git#To <URL/of/upstream.git>#" \
-e "/^error: / d"
}
+
+filter_out_user_friendly_and_stable_output () {
+ make_user_friendly_and_stable_output |
+ sed -n ${1+"$@"}
+}
diff --git a/t/t5411/test-0000-standard-git-push.sh b/t/t5411/test-0000-standard-git-push.sh
index 2b04b49367..47b058af7e 100644
--- a/t/t5411/test-0000-standard-git-push.sh
+++ b/t/t5411/test-0000-standard-git-push.sh
@@ -36,11 +36,10 @@ test_expect_success "git-push --atomic ($PROTOCOL)" '
main \
$B:refs/heads/next \
>out 2>&1 &&
- make_user_friendly_and_stable_output <out |
- sed -n \
- -e "/^To / { s/ */ /g; p; }" \
- -e "/^ ! / { s/ */ /g; p; }" \
- >actual &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
cat >expect <<-EOF &&
To <URL/of/upstream.git>
! [rejected] main -> main (non-fast-forward)
diff --git a/t/t5411/test-0001-standard-git-push--porcelain.sh b/t/t5411/test-0001-standard-git-push--porcelain.sh
index 747307f8da..bbead12bbb 100644
--- a/t/t5411/test-0001-standard-git-push--porcelain.sh
+++ b/t/t5411/test-0001-standard-git-push--porcelain.sh
@@ -37,16 +37,15 @@ test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
main \
$B:refs/heads/next \
>out 2>&1 &&
- make_user_friendly_and_stable_output <out |
- sed -n \
- -e "s/^# GETTEXT POISON #//" \
- -e "/^To / { s/ */ /g; p; }" \
- -e "/^! / { s/ */ /g; p; }" \
- >actual &&
+ filter_out_user_friendly_and_stable_output \
+ -e "s/^# GETTEXT POISON #//" \
+ -e "/^To / { p; }" \
+ -e "/^! / { p; }" \
+ <out >actual &&
cat >expect <<-EOF &&
To <URL/of/upstream.git>
- ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
- ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
+ ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
+ ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
EOF
test_cmp expect actual &&
git -C "$upstream" show-ref >out &&
diff --git a/t/t5411/test-0013-bad-protocol.sh b/t/t5411/test-0013-bad-protocol.sh
index 854c3e884a..b9be12be77 100644
--- a/t/t5411/test-0013-bad-protocol.sh
+++ b/t/t5411/test-0013-bad-protocol.sh
@@ -16,7 +16,8 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" '
# Check status report for git-push
sed -n \
- -e "/^To / { p; n; p; }" \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
<actual >actual-report &&
cat >expect <<-EOF &&
To <URL/of/upstream.git>
@@ -41,32 +42,98 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL)" '
test_cmp expect actual
'
-test_expect_success "setup proc-receive hook (hook --die-version, $PROTOCOL)" '
+test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL)" '
write_script "$upstream/hooks/proc-receive" <<-EOF
printf >&2 "# proc-receive hook\n"
- test-tool proc-receive -v --die-version
+ test-tool proc-receive -v --die-read-version
EOF
'
# Refs of upstream : main(A)
# Refs of workbench: main(A) tags/v123
# git push : refs/for/main/topic(A)
-test_expect_success "proc-receive: bad protocol (hook --die-version, $PROTOCOL)" '
+test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL)" '
test_must_fail git -C workbench push origin \
HEAD:refs/for/main/topic \
>out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-version option" out &&
+ grep "remote: error: fail to negotiate version with proc-receive hook" out &&
+
+ git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-write-version
+ EOF
+'
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL)" '
+ test_must_fail git -C workbench push origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-write-version option" out &&
+ grep "remote: error: fail to negotiate version with proc-receive hook" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-read-commands
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL)" '
+ test_must_fail git -C workbench push origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
cat >expect <<-EOF &&
- remote: # pre-receive hook
- remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
- remote: # proc-receive hook
- remote: fatal: bad protocol version: 1
- remote: error: proc-receive version "0" is not supported
To <URL/of/upstream.git>
! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
EOF
test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-commands option" out &&
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
@@ -76,23 +143,65 @@ test_expect_success "proc-receive: bad protocol (hook --die-version, $PROTOCOL)"
test_cmp expect actual
'
-test_expect_success "setup proc-receive hook (hook --die-readline, $PROTOCOL)" '
+test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL)" '
write_script "$upstream/hooks/proc-receive" <<-EOF
printf >&2 "# proc-receive hook\n"
- test-tool proc-receive -v --die-readline
+ test-tool proc-receive -v --die-read-push-options
EOF
'
# Refs of upstream : main(A)
# Refs of workbench: main(A) tags/v123
# git push : refs/for/main/topic(A)
-test_expect_success "proc-receive: bad protocol (hook --die-readline, $PROTOCOL)" '
+test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $PROTOCOL)" '
+ git -C "$upstream" config receive.advertisePushOptions true &&
test_must_fail git -C workbench push origin \
+ -o reviewers=user1,user2 \
HEAD:refs/for/main/topic \
>out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-push-options option" out &&
+
+ git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-write-report
+ EOF
+'
- grep "remote: fatal: protocol error: expected \"old new ref\", got \"<ZERO-OID> <COMMIT-A> refs/for/main/topic\"" actual &&
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL)" '
+ test_must_fail git -C workbench push origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; }" \
+ -e "/^ ! / { p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! [remote rejected] HEAD -> refs/for/main/topic (fail to run proc-receive hook)
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-write-report option" out &&
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
@@ -130,6 +239,7 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL)" '
! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
@@ -173,6 +283,7 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL)" '
! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
@@ -208,6 +319,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL)" '
! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
diff --git a/t/t5411/test-0014-bad-protocol--porcelain.sh b/t/t5411/test-0014-bad-protocol--porcelain.sh
index 88c56311da..fdb4569109 100644
--- a/t/t5411/test-0014-bad-protocol--porcelain.sh
+++ b/t/t5411/test-0014-bad-protocol--porcelain.sh
@@ -42,6 +42,175 @@ test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porc
test_cmp expect actual
'
+test_expect_success "setup proc-receive hook (hook --die-read-version, $PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-read-version
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-read-version, $PROTOCOL/porcelain)" '
+ test_must_fail git -C workbench push --porcelain origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; n; p; n; p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
+ Done
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-version option" out &&
+ grep "remote: error: fail to negotiate version with proc-receive hook" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-write-version, $PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-write-version
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-write-version, $PROTOCOL/porcelain)" '
+ test_must_fail git -C workbench push --porcelain origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; n; p; n; p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
+ Done
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-write-version option" out &&
+ grep "remote: error: fail to negotiate version with proc-receive hook" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-read-commands, $PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-read-commands
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-read-commands, $PROTOCOL/porcelain)" '
+ test_must_fail git -C workbench push --porcelain origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; n; p; n; p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
+ Done
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-commands option" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-read-push-options, $PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-read-push-options
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-read-push-options, $PROTOCOL/porcelain)" '
+ git -C "$upstream" config receive.advertisePushOptions true &&
+ test_must_fail git -C workbench push --porcelain origin \
+ -o reviewers=user1,user2 \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; n; p; n; p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
+ Done
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-read-push-options option" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "setup proc-receive hook (hook --die-write-report, $PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v --die-write-report
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push : refs/for/main/topic(A)
+test_expect_success "proc-receive: bad protocol (hook --die-write-report, $PROTOCOL/porcelain)" '
+ test_must_fail git -C workbench push --porcelain origin \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ filter_out_user_friendly_and_stable_output \
+ -e "/^To / { p; n; p; n; p; }" \
+ <out >actual &&
+ cat >expect <<-EOF &&
+ To <URL/of/upstream.git>
+ ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
+ Done
+ EOF
+ test_cmp expect actual &&
+ grep "remote: fatal: die with the --die-write-report option" out &&
+
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" '
write_script "$upstream/hooks/proc-receive" <<-EOF
printf >&2 "# proc-receive hook\n"
@@ -71,6 +240,7 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)
Done
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
@@ -84,7 +254,6 @@ test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)
# Refs of workbench: main(A) tags/v123
test_expect_success "cleanup ($PROTOCOL/porcelain)" '
git -C "$upstream" update-ref -d refs/heads/next
-
'
test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" '
@@ -115,6 +284,7 @@ test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
Done
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
@@ -151,6 +321,7 @@ test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porce
Done
EOF
test_cmp expect actual &&
+
git -C "$upstream" show-ref >out &&
make_user_friendly_and_stable_output <out >actual &&
cat >expect <<-EOF &&
diff --git a/t/t5411/test-0026-push-options.sh b/t/t5411/test-0026-push-options.sh
index d414be87d0..e88edb16a4 100644
--- a/t/t5411/test-0026-push-options.sh
+++ b/t/t5411/test-0026-push-options.sh
@@ -32,6 +32,66 @@ test_expect_success "enable push options ($PROTOCOL)" '
git -C "$upstream" config receive.advertisePushOptions true
'
+test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v \
+ --version 0 \
+ -r "ok refs/for/main/topic"
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push -o ... : next(A) refs/for/main/topic
+test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL)" '
+ git -C workbench push \
+ --atomic \
+ -o issue=123 \
+ -o reviewer=user1 \
+ origin \
+ HEAD:refs/heads/next \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ remote: # pre-receive hook
+ remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
+ remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ remote: # proc-receive hook
+ remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ remote: proc-receive> ok refs/for/main/topic
+ remote: # post-receive hook
+ remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
+ remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ To <URL/of/upstream.git>
+ * [new branch] HEAD -> next
+ * [new reference] HEAD -> refs/for/main/topic
+ EOF
+ test_cmp expect actual &&
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ <COMMIT-A> refs/heads/next
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "restore proc-receive hook ($PROTOCOL)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v \
+ -r "ok refs/for/main/topic"
+ EOF
+'
+
+# Refs of upstream : main(A) next(A)
+# Refs of workbench: main(A) tags/v123
+test_expect_success "cleanup ($PROTOCOL)" '
+ git -C "$upstream" update-ref -d refs/heads/next
+'
+
# Refs of upstream : main(A)
# Refs of workbench: main(A) tags/v123
# git push -o ... : next(A) refs/for/main/topic
diff --git a/t/t5411/test-0027-push-options--porcelain.sh b/t/t5411/test-0027-push-options--porcelain.sh
index d5d0dcb172..3a6561b5ea 100644
--- a/t/t5411/test-0027-push-options--porcelain.sh
+++ b/t/t5411/test-0027-push-options--porcelain.sh
@@ -33,6 +33,68 @@ test_expect_success "enable push options ($PROTOCOL/porcelain)" '
git -C "$upstream" config receive.advertisePushOptions true
'
+test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v \
+ --version 0 \
+ -r "ok refs/for/main/topic"
+ EOF
+'
+
+# Refs of upstream : main(A)
+# Refs of workbench: main(A) tags/v123
+# git push -o ... : next(A) refs/for/main/topic
+test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/porcelain)" '
+ git -C workbench push \
+ --porcelain \
+ --atomic \
+ -o issue=123 \
+ -o reviewer=user1 \
+ origin \
+ HEAD:refs/heads/next \
+ HEAD:refs/for/main/topic \
+ >out 2>&1 &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ remote: # pre-receive hook
+ remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
+ remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ remote: # proc-receive hook
+ remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ remote: proc-receive> ok refs/for/main/topic
+ remote: # post-receive hook
+ remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
+ remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
+ To <URL/of/upstream.git>
+ * HEAD:refs/heads/next [new branch]
+ * HEAD:refs/for/main/topic [new reference]
+ Done
+ EOF
+ test_cmp expect actual &&
+ git -C "$upstream" show-ref >out &&
+ make_user_friendly_and_stable_output <out >actual &&
+ cat >expect <<-EOF &&
+ <COMMIT-A> refs/heads/main
+ <COMMIT-A> refs/heads/next
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" '
+ write_script "$upstream/hooks/proc-receive" <<-EOF
+ printf >&2 "# proc-receive hook\n"
+ test-tool proc-receive -v \
+ -r "ok refs/for/main/topic"
+ EOF
+'
+
+# Refs of upstream : main(A) next(A)
+# Refs of workbench: main(A) tags/v123
+test_expect_success "cleanup ($PROTOCOL/porcelain)" '
+ git -C "$upstream" update-ref -d refs/heads/next
+'
+
# Refs of upstream : main(A)
# Refs of workbench: main(A) tags/v123
# git push -o ... : next(A) refs/for/main/topic
diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh
index 1d75e3b12b..37fd06b0be 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -101,7 +101,12 @@ test_expect_success " --[no-]recurse-submodule and submodule.recurse" '
test_path_is_file super/sub/merge_strategy_4.t
'
-test_expect_success 'recursive rebasing pull' '
+test_expect_success 'pull --rebase --recurse-submodules (remote superproject submodule changes, local submodule changes)' '
+ # This tests the following scenario :
+ # - local submodule has new commits
+ # - local superproject does not have new commits
+ # - upstream superproject has new commits that change the submodule pointer
+
# change upstream
test_commit -C child rebase_strategy &&
git -C parent submodule update --remote &&
@@ -116,7 +121,10 @@ test_expect_success 'recursive rebasing pull' '
test_path_is_file super/sub/local_stuff.t
'
-test_expect_success 'pull rebase recursing fails with conflicts' '
+test_expect_success 'pull --rebase --recurse-submodules fails if both sides record submodule changes' '
+ # This tests the following scenario :
+ # - local superproject has new commits that change the submodule pointer
+ # - upstream superproject has new commits that change the submodule pointer
# local changes in submodule recorded in superproject:
test_commit -C super/sub local_stuff_2 &&
@@ -136,6 +144,50 @@ test_expect_success 'pull rebase recursing fails with conflicts' '
test_i18ngrep "locally recorded submodule modifications" err
'
+test_expect_success 'pull --rebase --recurse-submodules (no submodule changes, no fork-point)' '
+ # This tests the following scenario :
+ # - local submodule does not have new commits
+ # - local superproject has new commits that *do not* change the submodule pointer
+ # - upstream superproject has new commits that *do not* change the submodule pointer
+ # - local superproject branch has no fork-point with its remote-tracking counter-part
+
+ # create upstream superproject
+ test_create_repo submodule &&
+ test_commit -C submodule first_in_sub &&
+
+ test_create_repo superprojet &&
+ test_commit -C superprojet first_in_super &&
+ git -C superprojet submodule add ../submodule &&
+ git -C superprojet commit -m "add submodule" &&
+ test_commit -C superprojet third_in_super &&
+
+ # clone superproject
+ git clone --recurse-submodules superprojet superclone &&
+
+ # add commits upstream
+ test_commit -C superprojet fourth_in_super &&
+
+ # create topic branch in clone, not based on any remote-tracking branch
+ git -C superclone checkout -b feat HEAD~1 &&
+ test_commit -C superclone first_on_feat &&
+ git -C superclone pull --rebase --recurse-submodules origin master
+'
+
+# NOTE:
+#
+# This test is particular because there is only a single commit in the upstream superproject
+# 'parent' (which adds the submodule 'a-submodule'). The clone of the superproject
+# ('child') hard-resets its branch to a new root commit with the same tree as the one
+# from the upstream superproject, so that its branch has no merge-base with its
+# remote-tracking counterpart, and then calls 'git pull --recurse-submodules --rebase'.
+# The result is that the local branch is reset to the remote-tracking branch (as it was
+# originally before the hard-reset).
+
+# The only commit in the range generated by 'submodule.c::submodule_touches_in_range' and
+# passed to 'submodule.c::collect_changed_submodules' is the new (regenerated) initial commit,
+# which adds the submodule.
+# However, 'submodule_touches_in_range' does not error (even though this commit adds the submodule)
+# because 'combine-diff.c::diff_tree_combined' returns early, as the initial commit has no parents.
test_expect_success 'branch has no merge base with remote-tracking counterpart' '
rm -rf parent child &&
diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
index c5c4ea5fc0..6774e9d86f 100755
--- a/t/t7601-merge-pull-config.sh
+++ b/t/t7601-merge-pull-config.sh
@@ -29,8 +29,11 @@ test_expect_success 'setup' '
test_expect_success 'pull.rebase not set' '
git reset --hard c0 &&
- git pull . c1 2>err &&
- test_i18ngrep "Pulling without specifying how to reconcile" err
+ git -c color.advice=always pull . c1 2>err &&
+ test_decode_color <err >decoded &&
+ test_i18ngrep "<YELLOW>hint: " decoded &&
+ test_i18ngrep "Pulling without specifying how to reconcile" decoded
+
'
test_expect_success 'pull.rebase not set and pull.ff=true' '
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 524f30f7dc..a578b35761 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -728,6 +728,19 @@ test_expect_success 'add -N and difftool -d' '
git difftool --dir-diff --extcmd ls
'
+test_expect_success 'difftool --cached with unmerged files' '
+ test_when_finished git reset --hard &&
+
+ test_commit conflicting &&
+ test_commit conflict-a conflict.t a &&
+ git reset --hard conflicting &&
+ test_commit conflict-b conflict.t b &&
+ test_must_fail git merge conflict-a &&
+
+ git difftool --cached --no-prompt >output &&
+ test_must_be_empty output
+'
+
test_expect_success 'outside worktree' '
echo 1 >1 &&
echo 2 >2 &&
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 2be9190425..5c01c75d40 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2195,6 +2195,25 @@ test_expect_success 'complete files' '
test_completion "git add mom" "momified"
'
+test_expect_success "simple alias" '
+ test_config alias.co checkout &&
+ test_completion "git co m" <<-\EOF
+ master Z
+ mybranch Z
+ mytag Z
+ EOF
+'
+
+test_expect_success "recursive alias" '
+ test_config alias.co checkout &&
+ test_config alias.cod "co --detached" &&
+ test_completion "git cod m" <<-\EOF
+ master Z
+ mybranch Z
+ mytag Z
+ EOF
+'
+
test_expect_success "completion uses <cmd> completion for alias: !sh -c 'git <cmd> ...'" '
test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
test_completion "git co m" <<-\EOF
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 59bbf75e83..7ba3011b90 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -423,7 +423,7 @@ write_script () {
# - Explicitly using test_have_prereq.
#
# - Implicitly by specifying the prerequisite tag in the calls to
-# test_expect_{success,failure,code}.
+# test_expect_{success,failure} and test_external{,_without_stderr}.
#
# The single parameter is the prerequisite tag (a simple word, in all
# capital letters by convention).
@@ -474,15 +474,15 @@ test_lazy_prereq () {
test_run_lazy_prereq_ () {
script='
-mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" &&
+mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&
(
- cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"'
+ cd "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&'"$2"'
)'
say >&3 "checking prerequisite: $1"
say >&3 "$script"
test_eval_ "$script"
eval_ret=$?
- rm -rf "$TRASH_DIRECTORY/prereq-test-dir"
+ rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1"
if test "$eval_ret" = 0; then
say >&3 "prerequisite $1 ok"
else
diff --git a/upload-pack.c b/upload-pack.c
index 5dc8e1f844..1006bebd50 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -321,6 +321,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
pack_objects.in = -1;
pack_objects.out = -1;
pack_objects.err = -1;
+ pack_objects.clean_on_exit = 1;
if (start_command(&pack_objects))
die("git upload-pack: unable to fork git-pack-objects");
diff --git a/usage.c b/usage.c
index 06665823a2..1868a24f7a 100644
--- a/usage.c
+++ b/usage.c
@@ -81,6 +81,12 @@ static void error_builtin(const char *err, va_list params)
static void warn_builtin(const char *warn, va_list params)
{
+ /*
+ * We call this trace2 function first and expect it to va_copy 'params'
+ * before using it (because an 'ap' can only be walked once).
+ */
+ trace2_cmd_error_va(warn, params);
+
vreportf("warning: ", warn, params);
}